@messenger-box/platform-mobile 10.0.2-alpha.5 → 10.0.3-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/lib/compute.js +14 -14
- package/lib/compute.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/module.js +1 -2
- package/lib/module.js.map +1 -1
- package/lib/screens/inbox/DialogMessages.js +44 -20
- package/lib/screens/inbox/DialogMessages.js.map +1 -1
- package/lib/screens/inbox/DialogThreadMessages.js +13 -48
- package/lib/screens/inbox/DialogThreadMessages.js.map +1 -1
- package/lib/screens/inbox/DialogThreads.js +13 -70
- package/lib/screens/inbox/DialogThreads.js.map +1 -1
- package/lib/screens/inbox/Inbox.js +18 -9
- package/lib/screens/inbox/Inbox.js.map +1 -1
- package/lib/screens/inbox/components/CachedImage/consts.js.map +1 -1
- package/lib/screens/inbox/components/CachedImage/index.js +41 -27
- package/lib/screens/inbox/components/CachedImage/index.js.map +1 -1
- package/lib/screens/inbox/components/DialogsListItem.js +96 -146
- package/lib/screens/inbox/components/DialogsListItem.js.map +1 -1
- package/lib/screens/inbox/components/ServiceDialogsListItem.js +95 -148
- package/lib/screens/inbox/components/ServiceDialogsListItem.js.map +1 -1
- package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.js +37 -51
- package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.js.map +1 -1
- package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js +113 -97
- package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js.map +1 -1
- package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js +50 -42
- package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js.map +1 -1
- package/lib/screens/inbox/components/ThreadsViewItem.js +41 -149
- package/lib/screens/inbox/components/ThreadsViewItem.js.map +1 -1
- package/lib/screens/inbox/config/config.js +8 -10
- package/lib/screens/inbox/config/config.js.map +1 -1
- package/lib/screens/inbox/containers/ConversationView.js +357 -501
- package/lib/screens/inbox/containers/ConversationView.js.map +1 -1
- package/lib/screens/inbox/containers/Dialogs.js +49 -140
- package/lib/screens/inbox/containers/Dialogs.js.map +1 -1
- package/lib/screens/inbox/containers/ThreadConversationView.js +297 -400
- package/lib/screens/inbox/containers/ThreadConversationView.js.map +1 -1
- package/lib/screens/inbox/containers/ThreadsView.js +83 -190
- package/lib/screens/inbox/containers/ThreadsView.js.map +1 -1
- package/package.json +4 -4
- package/rollup.config.mjs +5 -1
- package/lib/compute.d.ts +0 -5
- package/lib/index.d.ts +0 -4
- package/lib/module.d.ts +0 -3
- package/lib/navigation/InboxNavigation.d.ts +0 -2
- package/lib/navigation/index.d.ts +0 -1
- package/lib/screens/inbox/DialogMessages.d.ts +0 -8
- package/lib/screens/inbox/DialogThreadMessages.d.ts +0 -8
- package/lib/screens/inbox/DialogThreads.d.ts +0 -7
- package/lib/screens/inbox/Inbox.d.ts +0 -2
- package/lib/screens/inbox/components/CachedImage/consts.d.ts +0 -2
- package/lib/screens/inbox/components/CachedImage/index.d.ts +0 -8
- package/lib/screens/inbox/components/DialogsHeader.d.ts +0 -8
- package/lib/screens/inbox/components/DialogsListItem.d.ts +0 -19
- package/lib/screens/inbox/components/ServiceDialogsListItem.d.ts +0 -21
- package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.d.ts +0 -3
- package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.d.ts +0 -34
- package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.d.ts +0 -25
- package/lib/screens/inbox/components/SlackMessageContainer/index.d.ts +0 -3
- package/lib/screens/inbox/components/SupportServiceDialogsListItem.d.ts +0 -21
- package/lib/screens/inbox/components/ThreadsViewItem.d.ts +0 -20
- package/lib/screens/inbox/config/config.d.ts +0 -11
- package/lib/screens/inbox/config/index.d.ts +0 -1
- package/lib/screens/inbox/containers/ConversationView.d.ts +0 -11
- package/lib/screens/inbox/containers/Dialogs.d.ts +0 -7
- package/lib/screens/inbox/containers/SupportServiceDialogs.d.ts +0 -6
- package/lib/screens/inbox/containers/ThreadConversationView.d.ts +0 -11
- package/lib/screens/inbox/containers/ThreadsView.d.ts +0 -13
- package/lib/screens/index.d.ts +0 -4
|
@@ -1,16 +1,38 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default,{useState,useRef,useEffect,useCallback,useMemo}from'react';import {Button,Spinner,VStack,HStack,Avatar,AvatarFallbackText,AvatarImage,Box,Text,Center,Image,ButtonText}from'@admin-layout/gluestack-ui-mobile';import {Platform}from'react-native';import {useRoute,useNavigation,useFocusEffect}from'@react-navigation/native';import {useSelector}from'react-redux';import {uniqBy,orderBy,startCase}from'lodash-es';import*as ImagePicker from'expo-image-picker';import {encode}from'base-64';import {MaterialIcons,Ionicons,MaterialCommunityIcons}from'@expo/vector-icons';import {GiftedChat,Actions,MessageText,Send}from'react-native-gifted-chat';import {PreDefinedRole}from'common';import {useCreatePostThreadMutation,useSendExpoNotificationOnPostMutation,useGetPostThreadLazyQuery,OnThreadChatMessageAddedDocument}from'common/lib/generated/generated.js';import {useUploadFilesNative}from'@messenger-box/platform-client';import {objectId}from'@messenger-box/core';import {format,isToday,isYesterday}from'date-fns';import {userSelector}from'@adminide-stack/user-auth0-client';import {config}from'../config/config.js';import Message from'../components/SlackMessageContainer/SlackMessage.js';import ImageViewerModal from'../components/SlackMessageContainer/ImageViewerModal.js';import CachedImage from'../components/CachedImage/index.js';var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
const {
|
|
2
21
|
MESSAGES_PER_PAGE,
|
|
3
22
|
CALL_TO_ACTION_BOX_BGCOLOR,
|
|
4
23
|
CALL_TO_ACTION_PATH,
|
|
5
24
|
CALL_TO_ACTION_BUTTON_BORDERCOLOR,
|
|
6
25
|
CALL_TO_ACTION_TEXT_COLOR
|
|
7
26
|
} = config;
|
|
8
|
-
const createdAtText = value => {
|
|
9
|
-
if (!value)
|
|
27
|
+
const createdAtText = (value) => {
|
|
28
|
+
if (!value)
|
|
29
|
+
return "";
|
|
10
30
|
let date = new Date(value);
|
|
11
|
-
if (isToday(date))
|
|
12
|
-
|
|
13
|
-
|
|
31
|
+
if (isToday(date))
|
|
32
|
+
return "Today";
|
|
33
|
+
if (isYesterday(date))
|
|
34
|
+
return "Yesterday";
|
|
35
|
+
return format(new Date(value), "MMM dd, yyyy");
|
|
14
36
|
};
|
|
15
37
|
const ThreadConversationViewComponent = ({
|
|
16
38
|
channelId,
|
|
@@ -18,7 +40,7 @@ const ThreadConversationViewComponent = ({
|
|
|
18
40
|
isPostParentIdThread,
|
|
19
41
|
role
|
|
20
42
|
}) => {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s
|
|
43
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
22
44
|
const {
|
|
23
45
|
params
|
|
24
46
|
} = useRoute();
|
|
@@ -26,13 +48,13 @@ const ThreadConversationViewComponent = ({
|
|
|
26
48
|
const [channelMessages, setChannelMessages] = useState([]);
|
|
27
49
|
const auth = useSelector(userSelector);
|
|
28
50
|
const [totalCount, setTotalCount] = useState(0);
|
|
29
|
-
const [selectedImage, setImage] = useState(
|
|
51
|
+
const [selectedImage, setImage] = useState("");
|
|
30
52
|
const [loadingOldMessages, setLoadingOldMessages] = useState(false);
|
|
31
53
|
const [loadEarlierMsg, setLoadEarlierMsg] = useState(false);
|
|
32
54
|
const navigation = useNavigation();
|
|
33
55
|
const [files, setFiles] = useState([]);
|
|
34
56
|
const [images, setImages] = useState([]);
|
|
35
|
-
const [msg, setMsg] = useState(
|
|
57
|
+
const [msg, setMsg] = useState("");
|
|
36
58
|
const [loading, setLoading] = useState(false);
|
|
37
59
|
const [imageLoading, setImageLoading] = useState(false);
|
|
38
60
|
const [expoTokens, setExpoTokens] = useState([]);
|
|
@@ -46,7 +68,6 @@ const ThreadConversationViewComponent = ({
|
|
|
46
68
|
const [threadPost, setThreadPost] = useState([]);
|
|
47
69
|
const [isScrollToBottom, setIsScrollToBottom] = useState(false);
|
|
48
70
|
const threadMessageListRef = useRef(null);
|
|
49
|
-
// const [sendThreadMessage] = useSendThreadMessageMutation();
|
|
50
71
|
const [sendThreadMessage] = useCreatePostThreadMutation();
|
|
51
72
|
const [sendExpoNotificationOnPostMutation] = useSendExpoNotificationOnPostMutation();
|
|
52
73
|
const [getThreadMessages, {
|
|
@@ -56,30 +77,20 @@ const ThreadConversationViewComponent = ({
|
|
|
56
77
|
refetch: refetchThreadMessages,
|
|
57
78
|
subscribeToMore
|
|
58
79
|
}] = useGetPostThreadLazyQuery({
|
|
59
|
-
fetchPolicy:
|
|
80
|
+
fetchPolicy: "cache-and-network"
|
|
60
81
|
});
|
|
61
82
|
useFocusEffect(React__default.useCallback(() => {
|
|
62
|
-
|
|
63
|
-
var _a;
|
|
83
|
+
var _a2;
|
|
64
84
|
navigation.setOptions({
|
|
65
|
-
title: (
|
|
66
|
-
headerLeft: props => React__default.createElement(Button, {
|
|
67
|
-
bg: 'transparent',
|
|
68
|
-
"$pressed-bg": "$trueGray200",
|
|
69
|
-
"$active-bg": '$trueGray200',
|
|
70
|
-
onPress: () => navigation.goBack()
|
|
71
|
-
}, React__default.createElement(MaterialIcons, {
|
|
72
|
-
size: 20,
|
|
73
|
-
name: "arrow-back-ios",
|
|
74
|
-
color: 'black'
|
|
75
|
-
}))
|
|
85
|
+
title: (_a2 = params == null ? void 0 : params.title) != null ? _a2 : "Thread",
|
|
86
|
+
headerLeft: (props) => /* @__PURE__ */ React__default.createElement(Button, { bg: "transparent", "$pressed-bg": "$trueGray200", "$active-bg": "$trueGray200", onPress: () => navigation.goBack() }, /* @__PURE__ */ React__default.createElement(MaterialIcons, { size: 20, name: "arrow-back-ios", color: "black" }))
|
|
76
87
|
});
|
|
77
88
|
if (postParentId) {
|
|
78
89
|
refetchThreadMessages({
|
|
79
|
-
channelId: channelId
|
|
80
|
-
role: role
|
|
81
|
-
postParentId: postParentId
|
|
82
|
-
selectedFields:
|
|
90
|
+
channelId: channelId == null ? void 0 : channelId.toString(),
|
|
91
|
+
role: role == null ? void 0 : role.toString(),
|
|
92
|
+
postParentId: postParentId == null ? void 0 : postParentId.toString(),
|
|
93
|
+
selectedFields: "id channel post replies replyCount lastReplyAt createdAt updatedAt",
|
|
83
94
|
limit: MESSAGES_PER_PAGE
|
|
84
95
|
});
|
|
85
96
|
}
|
|
@@ -91,49 +102,45 @@ const ThreadConversationViewComponent = ({
|
|
|
91
102
|
};
|
|
92
103
|
}, [postParentId]));
|
|
93
104
|
useEffect(() => {
|
|
94
|
-
//if (parentId && parentId == 0) {
|
|
95
105
|
if (channelId && parentId) {
|
|
96
106
|
getThreadMessages({
|
|
97
107
|
variables: {
|
|
98
|
-
channelId: channelId
|
|
99
|
-
role: role
|
|
100
|
-
postParentId: !parentId || parentId == 0 ? null : parentId
|
|
101
|
-
selectedFields:
|
|
108
|
+
channelId: channelId == null ? void 0 : channelId.toString(),
|
|
109
|
+
role: role == null ? void 0 : role.toString(),
|
|
110
|
+
postParentId: !parentId || parentId == 0 ? null : parentId == null ? void 0 : parentId.toString(),
|
|
111
|
+
selectedFields: "id channel post replies replyCount lastReplyAt createdAt updatedAt",
|
|
102
112
|
limit: MESSAGES_PER_PAGE
|
|
103
113
|
}
|
|
104
114
|
});
|
|
105
115
|
}
|
|
106
116
|
}, [parentId]);
|
|
107
117
|
React__default.useEffect(() => {
|
|
108
|
-
var
|
|
109
|
-
if (data
|
|
118
|
+
var _a2, _b2, _c2;
|
|
119
|
+
if (data == null ? void 0 : data.getPostThread) {
|
|
110
120
|
const threads = data.getPostThread;
|
|
111
|
-
const
|
|
112
|
-
const threadReplies = (
|
|
113
|
-
const messeageTotalCount = (
|
|
114
|
-
const messages = [
|
|
115
|
-
if (messages.length > 0 && messeageTotalCount > totalCount || messages.length > 0 && channelMessages.length === 0) {
|
|
121
|
+
const threadPost2 = (_a2 = threads == null ? void 0 : threads.post) != null ? _a2 : [];
|
|
122
|
+
const threadReplies = (_b2 = threads == null ? void 0 : threads.replies) != null ? _b2 : [];
|
|
123
|
+
const messeageTotalCount = (_c2 = threads == null ? void 0 : threads.replyCount) != null ? _c2 : 0;
|
|
124
|
+
const messages = [threadPost2, ...threadReplies];
|
|
125
|
+
if (messages && messages.length > 0 && messeageTotalCount > totalCount || messages && messages.length > 0 && channelMessages.length === 0) {
|
|
116
126
|
setThreadMessages(messages, messeageTotalCount);
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
|
-
if (isScrollToBottom && channelMessages)
|
|
120
|
-
|
|
121
|
-
// if (!isPostParentIdThread) {
|
|
122
|
-
// // setTotalCount((pc: any) => pc + threadTotalCount);
|
|
123
|
-
// setChannelMessages((oldMessages: any) => uniqBy([...threadMessage, ...oldMessages], ({ id }) => id));
|
|
124
|
-
// }
|
|
129
|
+
if (isScrollToBottom && channelMessages)
|
|
130
|
+
scrollToBottom();
|
|
125
131
|
}, [data, channelMessages, loadingOldMessages, totalCount, isPostParentIdThread, isScrollToBottom]);
|
|
126
132
|
const setThreadMessages = (messages, messagesTotalCount) => {
|
|
127
|
-
setChannelMessages(oldMessages => uniqBy([...messages, ...oldMessages], ({
|
|
133
|
+
setChannelMessages((oldMessages) => uniqBy([...messages, ...oldMessages], ({
|
|
128
134
|
id
|
|
129
135
|
}) => id));
|
|
130
136
|
setTotalCount(messagesTotalCount);
|
|
131
137
|
};
|
|
132
138
|
React__default.useEffect(() => {
|
|
133
|
-
if (selectedImage)
|
|
139
|
+
if (selectedImage)
|
|
140
|
+
setImageLoading(false);
|
|
134
141
|
}, [selectedImage]);
|
|
135
142
|
const scrollToBottom = React__default.useCallback(() => {
|
|
136
|
-
if (threadMessageListRef
|
|
143
|
+
if (threadMessageListRef == null ? void 0 : threadMessageListRef.current) {
|
|
137
144
|
setIsScrollToBottom(false);
|
|
138
145
|
threadMessageListRef.current.scrollTop = threadMessageListRef.current.scrollHeight;
|
|
139
146
|
}
|
|
@@ -143,33 +150,30 @@ const ThreadConversationViewComponent = ({
|
|
|
143
150
|
setLoadEarlierMsg(true);
|
|
144
151
|
fetchMoreMessages({
|
|
145
152
|
variables: {
|
|
146
|
-
channelId: channelId
|
|
147
|
-
role: role
|
|
148
|
-
postParentId: parentId
|
|
149
|
-
selectedFields:
|
|
153
|
+
channelId: channelId == null ? void 0 : channelId.toString(),
|
|
154
|
+
role: role == null ? void 0 : role.toString(),
|
|
155
|
+
postParentId: parentId == null ? void 0 : parentId.toString(),
|
|
156
|
+
selectedFields: "id channel post replies replyCount lastReplyAt createdAt updatedAt",
|
|
150
157
|
limit: MESSAGES_PER_PAGE,
|
|
151
158
|
skip: channelMessages.length - 1
|
|
152
159
|
}
|
|
153
|
-
}).then(res => {
|
|
154
|
-
var
|
|
155
|
-
if ((
|
|
156
|
-
const threads = (
|
|
157
|
-
const threadReplies = (
|
|
158
|
-
const messeageTotalCount = (
|
|
160
|
+
}).then((res) => {
|
|
161
|
+
var _a2, _b2, _c2, _d2;
|
|
162
|
+
if ((_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.getPostThread) {
|
|
163
|
+
const threads = (_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.getPostThread;
|
|
164
|
+
const threadReplies = (_c2 = threads == null ? void 0 : threads.replies) != null ? _c2 : [];
|
|
165
|
+
const messeageTotalCount = (_d2 = threads == null ? void 0 : threads.replyCount) != null ? _d2 : 0;
|
|
159
166
|
setThreadMessages(threadReplies, messeageTotalCount);
|
|
160
167
|
}
|
|
161
168
|
}).finally(() => {
|
|
162
169
|
setLoadEarlierMsg(false);
|
|
163
170
|
setLoadingOldMessages(false);
|
|
164
|
-
}).catch(error => {
|
|
171
|
+
}).catch((error) => {
|
|
165
172
|
setLoadEarlierMsg(false);
|
|
166
173
|
setLoadingOldMessages(false);
|
|
167
174
|
});
|
|
168
175
|
}
|
|
169
176
|
}, [parentId, channelId, totalCount, channelMessages]);
|
|
170
|
-
// const isCloseToTop = ({ layoutMeasurement, contentOffset, contentSize }) => {
|
|
171
|
-
// return contentOffset.y <= 100; // 100px from top
|
|
172
|
-
// };
|
|
173
177
|
const isCloseToTop = ({
|
|
174
178
|
layoutMeasurement,
|
|
175
179
|
contentOffset,
|
|
@@ -179,11 +183,7 @@ const ThreadConversationViewComponent = ({
|
|
|
179
183
|
return contentSize.height - layoutMeasurement.height - paddingToTop <= contentOffset.y;
|
|
180
184
|
};
|
|
181
185
|
const dataURLtoFile = (dataurl, filename) => {
|
|
182
|
-
var arr = dataurl.split(
|
|
183
|
-
mime = arr[0].match(/:(.*?);/)[1],
|
|
184
|
-
bstr = encode(arr[1]),
|
|
185
|
-
n = bstr.length,
|
|
186
|
-
u8arr = new Uint8Array(n);
|
|
186
|
+
var arr = dataurl.split(","), mime = arr[0].match(/:(.*?);/)[1], bstr = encode(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
|
187
187
|
while (n--) {
|
|
188
188
|
u8arr[n] = bstr.charCodeAt(n);
|
|
189
189
|
}
|
|
@@ -191,10 +191,10 @@ const ThreadConversationViewComponent = ({
|
|
|
191
191
|
type: mime
|
|
192
192
|
});
|
|
193
193
|
};
|
|
194
|
-
const onSelectImages = () =>
|
|
195
|
-
var
|
|
194
|
+
const onSelectImages = async () => {
|
|
195
|
+
var _a2;
|
|
196
196
|
setImageLoading(true);
|
|
197
|
-
let imageSource =
|
|
197
|
+
let imageSource = await ImagePicker.launchImageLibraryAsync({
|
|
198
198
|
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
|
199
199
|
allowsEditing: true,
|
|
200
200
|
aspect: [4, 3],
|
|
@@ -202,22 +202,25 @@ const ThreadConversationViewComponent = ({
|
|
|
202
202
|
base64: true
|
|
203
203
|
});
|
|
204
204
|
if (!imageSource.canceled) {
|
|
205
|
-
const image =
|
|
205
|
+
const image = "data:image/jpeg;base64," + ((_a2 = imageSource.assets[0]) == null ? void 0 : _a2.base64);
|
|
206
206
|
setImage(image);
|
|
207
|
-
const file = dataURLtoFile(image,
|
|
208
|
-
setFiles(
|
|
209
|
-
setImages(
|
|
207
|
+
const file = dataURLtoFile(image, "inputImage.jpg");
|
|
208
|
+
setFiles((files2) => files2.concat(file));
|
|
209
|
+
setImages((images2) => images2.concat(imageSource.assets[0]));
|
|
210
210
|
}
|
|
211
|
-
if (imageSource.canceled)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (!
|
|
211
|
+
if (imageSource.canceled)
|
|
212
|
+
setLoading(false);
|
|
213
|
+
};
|
|
214
|
+
const handleSend = useCallback(async (message) => {
|
|
215
|
+
var _a2;
|
|
216
|
+
if (!channelId)
|
|
217
|
+
return;
|
|
218
|
+
if (!message && message != " " && images.length == 0)
|
|
219
|
+
return;
|
|
217
220
|
const postId = objectId();
|
|
218
221
|
if (images && images.length > 0) {
|
|
219
222
|
setLoading(true);
|
|
220
|
-
const uploadResponse =
|
|
223
|
+
const uploadResponse = await startUpload({
|
|
221
224
|
file: images,
|
|
222
225
|
saveUploadedFile: {
|
|
223
226
|
variables: {
|
|
@@ -230,53 +233,53 @@ const ThreadConversationViewComponent = ({
|
|
|
230
233
|
}
|
|
231
234
|
}
|
|
232
235
|
});
|
|
233
|
-
if (uploadResponse
|
|
236
|
+
if (uploadResponse == null ? void 0 : uploadResponse.error)
|
|
237
|
+
setLoading(false);
|
|
234
238
|
const uploadedFiles = uploadResponse.data;
|
|
235
239
|
if (uploadResponse.data) {
|
|
236
|
-
setImage(
|
|
240
|
+
setImage("");
|
|
237
241
|
setFiles([]);
|
|
238
242
|
setImages([]);
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
yield sendThreadMessage({
|
|
243
|
+
const files2 = (_a2 = uploadedFiles == null ? void 0 : uploadedFiles.map((f) => f.id)) != null ? _a2 : null;
|
|
244
|
+
await sendThreadMessage({
|
|
242
245
|
variables: {
|
|
243
246
|
postId,
|
|
244
247
|
channelId,
|
|
245
|
-
postThreadId: postThread && (postThread
|
|
248
|
+
postThreadId: postThread && (postThread == null ? void 0 : postThread.id),
|
|
246
249
|
postParentId: !parentId || parentId == 0 ? null : parentId,
|
|
247
250
|
threadMessageInput: {
|
|
248
251
|
content: message,
|
|
249
|
-
files,
|
|
252
|
+
files: files2,
|
|
250
253
|
role
|
|
251
254
|
}
|
|
252
255
|
},
|
|
253
256
|
update: (cache, {
|
|
254
|
-
data,
|
|
257
|
+
data: data2,
|
|
255
258
|
errors
|
|
256
259
|
}) => {
|
|
257
|
-
var
|
|
258
|
-
if (!
|
|
260
|
+
var _a3, _b2, _c2, _d2, _e2, _f2, _g2;
|
|
261
|
+
if (!data2 || errors) {
|
|
259
262
|
setLoading(false);
|
|
260
263
|
return;
|
|
261
264
|
}
|
|
262
|
-
setPostThread((
|
|
263
|
-
const lastMessageId = (
|
|
265
|
+
setPostThread((_a3 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _a3.data);
|
|
266
|
+
const lastMessageId = (_c2 = (_b2 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _b2.lastMessage) == null ? void 0 : _c2.id;
|
|
264
267
|
if (!parentId || parentId == 0) {
|
|
265
|
-
setParentId((
|
|
268
|
+
setParentId((_e2 = (_d2 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _d2.lastMessage) == null ? void 0 : _e2.id);
|
|
266
269
|
}
|
|
267
270
|
setChannelToTop(channelToTop + 1);
|
|
268
271
|
setLoading(false);
|
|
269
|
-
setMsg(
|
|
270
|
-
sendPushNotification(lastMessageId, channelId, parentId, (
|
|
272
|
+
setMsg("");
|
|
273
|
+
sendPushNotification(lastMessageId, channelId, parentId, (_g2 = (_f2 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _f2.data) == null ? void 0 : _g2.id);
|
|
271
274
|
}
|
|
272
275
|
});
|
|
273
276
|
}
|
|
274
277
|
} else {
|
|
275
278
|
setLoading(true);
|
|
276
|
-
|
|
279
|
+
await sendThreadMessage({
|
|
277
280
|
variables: {
|
|
278
281
|
channelId,
|
|
279
|
-
postThreadId: postThread && (postThread
|
|
282
|
+
postThreadId: postThread && (postThread == null ? void 0 : postThread.id),
|
|
280
283
|
postParentId: !parentId || parentId == 0 ? null : parentId,
|
|
281
284
|
threadMessageInput: {
|
|
282
285
|
content: message,
|
|
@@ -284,383 +287,286 @@ const ThreadConversationViewComponent = ({
|
|
|
284
287
|
}
|
|
285
288
|
},
|
|
286
289
|
update: (cache, {
|
|
287
|
-
data,
|
|
290
|
+
data: data2,
|
|
288
291
|
errors
|
|
289
292
|
}) => {
|
|
290
|
-
var
|
|
291
|
-
if (!
|
|
293
|
+
var _a3, _b2, _c2, _d2, _e2, _f2;
|
|
294
|
+
if (!data2 || errors) {
|
|
292
295
|
setLoading(false);
|
|
293
296
|
return;
|
|
294
297
|
}
|
|
295
|
-
setPostThread(
|
|
296
|
-
const lastMessageId = (
|
|
298
|
+
setPostThread(data2 == null ? void 0 : data2.createPostThread.data);
|
|
299
|
+
const lastMessageId = (_b2 = (_a3 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _a3.lastMessage) == null ? void 0 : _b2.id;
|
|
297
300
|
if (!parentId || parentId == 0) {
|
|
298
|
-
setParentId((
|
|
301
|
+
setParentId((_d2 = (_c2 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _c2.lastMessage) == null ? void 0 : _d2.id);
|
|
299
302
|
}
|
|
300
303
|
setChannelToTop(channelToTop + 1);
|
|
301
304
|
setLoading(false);
|
|
302
|
-
setMsg(
|
|
303
|
-
sendPushNotification(lastMessageId, channelId, parentId, (
|
|
305
|
+
setMsg("");
|
|
306
|
+
sendPushNotification(lastMessageId, channelId, parentId, (_f2 = (_e2 = data2 == null ? void 0 : data2.createPostThread) == null ? void 0 : _e2.data) == null ? void 0 : _f2.id);
|
|
304
307
|
}
|
|
305
308
|
});
|
|
306
309
|
}
|
|
307
|
-
}
|
|
308
|
-
const sendPushNotification = (messageId,
|
|
309
|
-
var
|
|
310
|
+
}, [setChannelMessages, channelId, images, parentId, expoTokens]);
|
|
311
|
+
const sendPushNotification = async (messageId, channelId2, parentId2, threadId) => {
|
|
312
|
+
var _a2;
|
|
310
313
|
const notificationData = {
|
|
311
314
|
url: config.THREAD_MESSEGE_PATH,
|
|
312
315
|
params: {
|
|
313
|
-
channelId,
|
|
314
|
-
title: (
|
|
315
|
-
postParentId:
|
|
316
|
+
channelId: channelId2,
|
|
317
|
+
title: (_a2 = params == null ? void 0 : params.title) != null ? _a2 : "Thread",
|
|
318
|
+
postParentId: parentId2,
|
|
316
319
|
hideTabBar: true
|
|
317
320
|
},
|
|
318
|
-
screen:
|
|
321
|
+
screen: "DialogThreadMessages",
|
|
319
322
|
thread: {
|
|
320
323
|
id: threadId
|
|
321
324
|
},
|
|
322
325
|
other: {
|
|
323
|
-
sound: Platform.OS ===
|
|
326
|
+
sound: Platform.OS === "android" ? void 0 : "default"
|
|
324
327
|
}
|
|
325
328
|
};
|
|
326
|
-
if (
|
|
327
|
-
|
|
329
|
+
if (parentId2 || parentId2 == 0) {
|
|
330
|
+
await sendExpoNotificationOnPostMutation({
|
|
328
331
|
variables: {
|
|
329
|
-
postId: messageId
|
|
332
|
+
postId: messageId == null ? void 0 : messageId.toString(),
|
|
330
333
|
notificationData
|
|
331
334
|
}
|
|
332
335
|
});
|
|
333
336
|
}
|
|
334
|
-
}
|
|
337
|
+
};
|
|
335
338
|
const messageList = useMemo(() => {
|
|
336
339
|
let res = [];
|
|
337
|
-
const filteredMessages = channelMessages && (channelMessages
|
|
340
|
+
const filteredMessages = channelMessages && (channelMessages == null ? void 0 : channelMessages.length) > 0 ? uniqBy([...channelMessages], ({
|
|
338
341
|
id
|
|
339
342
|
}) => id) : [];
|
|
340
|
-
if (filteredMessages
|
|
341
|
-
orderBy(filteredMessages, [
|
|
342
|
-
var
|
|
343
|
+
if (filteredMessages == null ? void 0 : filteredMessages.length) {
|
|
344
|
+
orderBy(filteredMessages, ["createdAt"], ["desc"]).map((msg2) => {
|
|
345
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
|
|
343
346
|
let message = {
|
|
344
|
-
_id:
|
|
345
|
-
text:
|
|
347
|
+
_id: "",
|
|
348
|
+
text: "",
|
|
346
349
|
createdAt: 0,
|
|
347
350
|
user: {
|
|
348
|
-
_id:
|
|
349
|
-
name:
|
|
350
|
-
avatar:
|
|
351
|
+
_id: "",
|
|
352
|
+
name: "",
|
|
353
|
+
avatar: ""
|
|
351
354
|
},
|
|
352
|
-
type:
|
|
355
|
+
type: ""
|
|
353
356
|
};
|
|
354
|
-
const date = new Date(
|
|
355
|
-
message._id =
|
|
356
|
-
message.text =
|
|
357
|
+
const date = new Date(msg2.createdAt);
|
|
358
|
+
message._id = msg2.id;
|
|
359
|
+
message.text = msg2.message;
|
|
357
360
|
message.createdAt = date;
|
|
358
361
|
message.user = {
|
|
359
|
-
_id: (
|
|
360
|
-
name: (
|
|
361
|
-
avatar: (
|
|
362
|
-
}, message.image = (
|
|
363
|
-
message.type =
|
|
364
|
-
message.propsConfiguration =
|
|
362
|
+
_id: (_c2 = (_a2 = msg2 == null ? void 0 : msg2.author) == null ? void 0 : _a2.id) != null ? _c2 : (_b2 = auth == null ? void 0 : auth.profile) == null ? void 0 : _b2.id,
|
|
363
|
+
name: (_i2 = (_g2 = (_d2 = msg2 == null ? void 0 : msg2.author) == null ? void 0 : _d2.givenName) != null ? _g2 : ((_e2 = auth == null ? void 0 : auth.profile) == null ? void 0 : _e2.given_name) + " " + ((_f2 = msg2 == null ? void 0 : msg2.author) == null ? void 0 : _f2.familyName)) != null ? _i2 : (_h2 = auth == null ? void 0 : auth.profile) == null ? void 0 : _h2.family_name,
|
|
364
|
+
avatar: (_l2 = (_j2 = msg2 == null ? void 0 : msg2.author) == null ? void 0 : _j2.picture) != null ? _l2 : (_k2 = auth == null ? void 0 : auth.profile) == null ? void 0 : _k2.picture
|
|
365
|
+
}, message.image = (_n2 = (_m2 = msg2.files) == null ? void 0 : _m2.data[0]) == null ? void 0 : _n2.url, message.sent = msg2 == null ? void 0 : msg2.isDelivered, message.received = msg2 == null ? void 0 : msg2.isRead;
|
|
366
|
+
message.type = msg2 == null ? void 0 : msg2.type;
|
|
367
|
+
message.propsConfiguration = msg2 == null ? void 0 : msg2.propsConfiguration;
|
|
365
368
|
res.push(message);
|
|
366
369
|
});
|
|
367
370
|
}
|
|
368
|
-
return (res
|
|
371
|
+
return (res == null ? void 0 : res.length) > 0 ? uniqBy([...res], ({
|
|
369
372
|
_id
|
|
370
373
|
}) => _id) : [];
|
|
371
|
-
//return res;
|
|
372
374
|
}, [channelMessages]);
|
|
373
|
-
const renderSend = props => {
|
|
374
|
-
return React__default.createElement(Send,
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
marginRight: 5
|
|
379
|
-
},
|
|
380
|
-
size: 32,
|
|
381
|
-
color: "#2e64e5"
|
|
382
|
-
})));
|
|
375
|
+
const renderSend = (props) => {
|
|
376
|
+
return /* @__PURE__ */ React__default.createElement(Send, __spreadValues({}, props), /* @__PURE__ */ React__default.createElement(Box, null, /* @__PURE__ */ React__default.createElement(MaterialCommunityIcons, { name: "send-circle", style: {
|
|
377
|
+
marginBottom: 5,
|
|
378
|
+
marginRight: 5
|
|
379
|
+
}, size: 32, color: "#2e64e5" })));
|
|
383
380
|
};
|
|
384
|
-
const renderMessageText = props => {
|
|
385
|
-
var
|
|
381
|
+
const renderMessageText = (props) => {
|
|
382
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t, _u, _v, _w, _x, _y;
|
|
386
383
|
const {
|
|
387
384
|
currentMessage
|
|
388
385
|
} = props;
|
|
389
|
-
if (currentMessage.type ===
|
|
390
|
-
const attachment = (
|
|
391
|
-
let action =
|
|
392
|
-
let actionId =
|
|
393
|
-
let
|
|
394
|
-
if ((
|
|
395
|
-
const extraParams = (
|
|
396
|
-
const route = (
|
|
386
|
+
if (currentMessage.type === "ALERT") {
|
|
387
|
+
const attachment = (_b2 = (_a2 = currentMessage == null ? void 0 : currentMessage.propsConfiguration) == null ? void 0 : _a2.contents) == null ? void 0 : _b2.attachment;
|
|
388
|
+
let action = "";
|
|
389
|
+
let actionId = "";
|
|
390
|
+
let params2 = {};
|
|
391
|
+
if ((_c2 = attachment == null ? void 0 : attachment.callToAction) == null ? void 0 : _c2.extraParams) {
|
|
392
|
+
const extraParams = (_d2 = attachment == null ? void 0 : attachment.callToAction) == null ? void 0 : _d2.extraParams;
|
|
393
|
+
const route = (_e2 = extraParams == null ? void 0 : extraParams.route) != null ? _e2 : null;
|
|
397
394
|
let path = null;
|
|
398
395
|
let param = null;
|
|
399
396
|
if (role && role == PreDefinedRole.Guest) {
|
|
400
|
-
path = ((
|
|
401
|
-
param = ((
|
|
397
|
+
path = ((_f2 = route == null ? void 0 : route.guest) == null ? void 0 : _f2.name) ? (_h2 = (_g2 = route == null ? void 0 : route.guest) == null ? void 0 : _g2.name) != null ? _h2 : null : null;
|
|
398
|
+
param = ((_i2 = route == null ? void 0 : route.guest) == null ? void 0 : _i2.params) ? (_k2 = (_j2 = route == null ? void 0 : route.guest) == null ? void 0 : _j2.params) != null ? _k2 : null : null;
|
|
402
399
|
} else if (role && role == PreDefinedRole.Owner) {
|
|
403
|
-
path = ((
|
|
404
|
-
param = ((
|
|
400
|
+
path = ((_l2 = route == null ? void 0 : route.host) == null ? void 0 : _l2.name) ? (_n2 = (_m2 = route == null ? void 0 : route.host) == null ? void 0 : _m2.name) != null ? _n2 : null : null;
|
|
401
|
+
param = ((_o2 = route == null ? void 0 : route.host) == null ? void 0 : _o2.params) ? (_q2 = (_p2 = route == null ? void 0 : route.host) == null ? void 0 : _p2.params) != null ? _q2 : null : null;
|
|
405
402
|
} else {
|
|
406
|
-
path = ((
|
|
407
|
-
param = ((
|
|
403
|
+
path = ((_r2 = route == null ? void 0 : route.host) == null ? void 0 : _r2.name) ? (_t = (_s2 = route == null ? void 0 : route.host) == null ? void 0 : _s2.name) != null ? _t : null : null;
|
|
404
|
+
param = ((_u = route == null ? void 0 : route.host) == null ? void 0 : _u.params) ? (_w = (_v = route == null ? void 0 : route.host) == null ? void 0 : _v.params) != null ? _w : null : null;
|
|
408
405
|
}
|
|
409
406
|
action = path;
|
|
410
|
-
|
|
411
|
-
} else if ((
|
|
407
|
+
params2 = __spreadValues({}, param);
|
|
408
|
+
} else if ((_x = attachment == null ? void 0 : attachment.callToAction) == null ? void 0 : _x.link) {
|
|
412
409
|
action = CALL_TO_ACTION_PATH;
|
|
413
|
-
actionId = (
|
|
414
|
-
|
|
410
|
+
actionId = (_y = attachment == null ? void 0 : attachment.callToAction) == null ? void 0 : _y.link.split("/").pop();
|
|
411
|
+
params2 = {
|
|
415
412
|
reservationId: actionId
|
|
416
413
|
};
|
|
417
414
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
color: CALL_TO_ACTION_TEXT_COLOR
|
|
433
|
-
}, attachment.callToAction.title)), React__default.createElement(MessageText, Object.assign({}, props, {
|
|
434
|
-
textStyle: {
|
|
435
|
-
left: {
|
|
436
|
-
marginLeft: 5,
|
|
437
|
-
color: CALL_TO_ACTION_TEXT_COLOR,
|
|
438
|
-
paddingHorizontal: 2
|
|
439
|
-
}
|
|
415
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, (attachment == null ? void 0 : attachment.callToAction) && action ? /* @__PURE__ */ React__default.createElement(Box, { bg: CALL_TO_ACTION_BOX_BGCOLOR, borderRadius: 15, pb: 2 }, /* @__PURE__ */ React__default.createElement(
|
|
416
|
+
Button,
|
|
417
|
+
{
|
|
418
|
+
variant: "outline",
|
|
419
|
+
size: "sm",
|
|
420
|
+
borderColor: CALL_TO_ACTION_BUTTON_BORDERCOLOR,
|
|
421
|
+
onPress: () => action && params2 && navigation.navigate(action, params2)
|
|
422
|
+
},
|
|
423
|
+
/* @__PURE__ */ React__default.createElement(ButtonText, { color: CALL_TO_ACTION_TEXT_COLOR }, attachment.callToAction.title)
|
|
424
|
+
), /* @__PURE__ */ React__default.createElement(MessageText, __spreadProps(__spreadValues({}, props), { textStyle: {
|
|
425
|
+
left: {
|
|
426
|
+
marginLeft: 5,
|
|
427
|
+
color: CALL_TO_ACTION_TEXT_COLOR,
|
|
428
|
+
paddingHorizontal: 2
|
|
440
429
|
}
|
|
441
|
-
}))) : React__default.createElement(MessageText,
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
marginLeft: 5
|
|
445
|
-
}
|
|
430
|
+
} }))) : /* @__PURE__ */ React__default.createElement(MessageText, __spreadProps(__spreadValues({}, props), { textStyle: {
|
|
431
|
+
left: {
|
|
432
|
+
marginLeft: 5
|
|
446
433
|
}
|
|
447
|
-
})));
|
|
434
|
+
} })));
|
|
448
435
|
} else {
|
|
449
|
-
return React__default.createElement(MessageText,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
marginLeft: 5
|
|
453
|
-
}
|
|
436
|
+
return /* @__PURE__ */ React__default.createElement(MessageText, __spreadProps(__spreadValues({}, props), { textStyle: {
|
|
437
|
+
left: {
|
|
438
|
+
marginLeft: 5
|
|
454
439
|
}
|
|
455
|
-
}));
|
|
440
|
+
} }));
|
|
456
441
|
}
|
|
457
442
|
};
|
|
458
|
-
const renderActions = props => {
|
|
459
|
-
return React__default.createElement(Actions,
|
|
460
|
-
icon: () => React__default.createElement(Ionicons, {
|
|
461
|
-
name: 'image',
|
|
462
|
-
size: 30,
|
|
463
|
-
color: 'black',
|
|
464
|
-
onPress: onSelectImages
|
|
465
|
-
})
|
|
466
|
-
}));
|
|
443
|
+
const renderActions = (props) => {
|
|
444
|
+
return /* @__PURE__ */ React__default.createElement(Actions, __spreadProps(__spreadValues({}, props), { icon: () => /* @__PURE__ */ React__default.createElement(Ionicons, { name: "image", size: 30, color: "black", onPress: onSelectImages }) }));
|
|
467
445
|
};
|
|
468
|
-
const renderAccessory = props => {
|
|
469
|
-
return React__default.createElement(Box, null, selectedImage !==
|
|
470
|
-
|
|
471
|
-
}, React__default.createElement(
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
446
|
+
const renderAccessory = (props) => {
|
|
447
|
+
return /* @__PURE__ */ React__default.createElement(Box, null, selectedImage !== "" ? /* @__PURE__ */ React__default.createElement(HStack, { alignItems: "center" }, /* @__PURE__ */ React__default.createElement(Image, { ml: "$3", key: selectedImage, alt: "image", source: {
|
|
448
|
+
uri: selectedImage
|
|
449
|
+
}, size: "xs" }), /* @__PURE__ */ React__default.createElement(
|
|
450
|
+
Button,
|
|
451
|
+
{
|
|
452
|
+
variant: "solid",
|
|
453
|
+
bg: "transparent",
|
|
454
|
+
onPress: () => {
|
|
455
|
+
setFiles([]);
|
|
456
|
+
setImage("");
|
|
457
|
+
setImages([]);
|
|
458
|
+
}
|
|
477
459
|
},
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
variant: 'solid',
|
|
481
|
-
//bg={'$secondary400'}
|
|
482
|
-
bg: 'transparent',
|
|
483
|
-
onPress: () => {
|
|
484
|
-
setFiles([]);
|
|
485
|
-
setImage('');
|
|
486
|
-
setImages([]);
|
|
487
|
-
}
|
|
488
|
-
}, React__default.createElement(ButtonText, {
|
|
489
|
-
color: '$black'
|
|
490
|
-
}, "Cancel"))) : null);
|
|
460
|
+
/* @__PURE__ */ React__default.createElement(ButtonText, { color: "$black" }, "Cancel")
|
|
461
|
+
)) : null);
|
|
491
462
|
};
|
|
492
463
|
const setImageViewerObject = (obj, v) => {
|
|
493
464
|
setImageObject(obj);
|
|
494
465
|
setImageViewer(v);
|
|
495
466
|
};
|
|
496
467
|
const modalContent = React__default.useMemo(() => {
|
|
497
|
-
if (!imageObject)
|
|
468
|
+
if (!imageObject)
|
|
469
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
|
|
498
470
|
const {
|
|
499
471
|
image,
|
|
500
472
|
_id
|
|
501
473
|
} = imageObject;
|
|
502
|
-
return React__default.createElement(
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
474
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
475
|
+
CachedImage,
|
|
476
|
+
{
|
|
477
|
+
style: {
|
|
478
|
+
width: "100%",
|
|
479
|
+
height: "100%"
|
|
480
|
+
},
|
|
481
|
+
resizeMode: "cover",
|
|
482
|
+
cacheKey: `${_id}-slack-bubble-imageKey`,
|
|
483
|
+
source: {
|
|
484
|
+
uri: image,
|
|
485
|
+
expiresIn: 86400
|
|
486
|
+
},
|
|
487
|
+
alt: "image"
|
|
488
|
+
}
|
|
489
|
+
);
|
|
517
490
|
}, [imageObject]);
|
|
518
|
-
const renderMessage = props => {
|
|
519
|
-
return React__default.createElement(Message,
|
|
520
|
-
isShowImageViewer: isShowImageViewer,
|
|
521
|
-
setImageViewer: setImageViewerObject
|
|
522
|
-
}));
|
|
491
|
+
const renderMessage = (props) => {
|
|
492
|
+
return /* @__PURE__ */ React__default.createElement(Message, __spreadProps(__spreadValues({}, props), { isShowImageViewer, setImageViewer: setImageViewerObject }));
|
|
523
493
|
};
|
|
524
494
|
let onScroll = false;
|
|
525
495
|
const onMomentumScrollBegin = ({
|
|
526
496
|
nativeEvent
|
|
527
497
|
}) => {
|
|
528
498
|
onScroll = true;
|
|
529
|
-
console.log(
|
|
530
|
-
if (!loadingOldMessages && isCloseToTop(nativeEvent) && totalCount > (channelMessages
|
|
499
|
+
console.log("scroll top");
|
|
500
|
+
if (!loadingOldMessages && isCloseToTop(nativeEvent) && totalCount > (channelMessages == null ? void 0 : channelMessages.length)) {
|
|
531
501
|
onFetchOld();
|
|
532
502
|
}
|
|
533
503
|
};
|
|
534
504
|
const onEndReached = () => {
|
|
535
|
-
console.log(
|
|
536
|
-
if (!onScroll)
|
|
537
|
-
|
|
505
|
+
console.log("on end reached");
|
|
506
|
+
if (!onScroll)
|
|
507
|
+
return;
|
|
538
508
|
onScroll = false;
|
|
539
|
-
// setLoadingOldMessages(true);
|
|
540
509
|
};
|
|
541
|
-
return React__default.createElement(React__default.Fragment, null, (loadingOldMessages || loadEarlierMsg) && React__default.createElement(Spinner, {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
py: '$2',
|
|
581
|
-
borderColor: '$trueGray200'
|
|
582
|
-
}, React__default.createElement(Text, {
|
|
583
|
-
color: '$trueGray600',
|
|
584
|
-
fontWeight: '$bold'
|
|
585
|
-
}, (_s = (_r = threadPost[0]) === null || _r === void 0 ? void 0 : _r.replies) === null || _s === void 0 ? void 0 : _s.totalCount, ' ', ((_u = (_t = threadPost[0]) === null || _t === void 0 ? void 0 : _t.replies) === null || _u === void 0 ? void 0 : _u.totalCount) > 0 ? 'replies' : 'reply'))))), React__default.createElement(GiftedChat, {
|
|
586
|
-
ref: threadMessageListRef,
|
|
587
|
-
wrapInSafeArea: false,
|
|
588
|
-
renderLoading: () => React__default.createElement(Spinner, {
|
|
589
|
-
color: '$blue500'
|
|
590
|
-
}),
|
|
591
|
-
messages: messageList,
|
|
592
|
-
listViewProps: {
|
|
593
|
-
onEndReached: onEndReached,
|
|
594
|
-
onEndReachedThreshold: 0.5,
|
|
595
|
-
onMomentumScrollBegin: onMomentumScrollBegin
|
|
596
|
-
},
|
|
597
|
-
onSend: messages => {
|
|
598
|
-
var _a, _b;
|
|
599
|
-
return handleSend((_b = (_a = messages[0]) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : ' ');
|
|
600
|
-
},
|
|
601
|
-
text: msg ? msg : ' ',
|
|
602
|
-
onInputTextChanged: text => setMsg(text),
|
|
603
|
-
renderFooter: () => loading ? React__default.createElement(Spinner, {
|
|
604
|
-
color: '$blue500'
|
|
605
|
-
}) : imageLoading ? React__default.createElement(Spinner, {
|
|
606
|
-
color: '$blue500'
|
|
607
|
-
}) : '',
|
|
608
|
-
scrollToBottom: true,
|
|
609
|
-
user: {
|
|
610
|
-
_id: (auth === null || auth === void 0 ? void 0 : auth.id) || ''
|
|
611
|
-
},
|
|
612
|
-
isTyping: true,
|
|
613
|
-
alwaysShowSend: loading ? false : true,
|
|
614
|
-
// onLoadEarlier={onFetchOld}
|
|
615
|
-
infiniteScroll: true,
|
|
616
|
-
renderSend: renderSend,
|
|
617
|
-
// loadEarlier={data?.messages?.totalCount > channelMessages.length}
|
|
618
|
-
// isLoadingEarlier={loadEarlierMsg}
|
|
619
|
-
// renderLoadEarlier={() =>
|
|
620
|
-
// !loadEarlierMsg && (
|
|
621
|
-
// <Center py={2}>
|
|
622
|
-
// <Button
|
|
623
|
-
// onPress={() => onFetchOld(channelMessages?.length)}
|
|
624
|
-
// variant={'outline'}
|
|
625
|
-
// _text={{ color: 'black', fontSize: 15, fontWeight: 'bold' }}
|
|
626
|
-
// >
|
|
627
|
-
// Load earlier messages
|
|
628
|
-
// </Button>
|
|
629
|
-
// </Center>
|
|
630
|
-
// )
|
|
631
|
-
// }
|
|
632
|
-
renderMessageText: renderMessageText,
|
|
633
|
-
minInputToolbarHeight: 50,
|
|
634
|
-
renderActions: renderActions,
|
|
635
|
-
renderAccessory: renderAccessory,
|
|
636
|
-
renderMessage: renderMessage,
|
|
637
|
-
renderChatFooter: () => React__default.createElement(React__default.Fragment, null, React__default.createElement(ImageViewerModal, {
|
|
638
|
-
isVisible: isShowImageViewer,
|
|
639
|
-
setVisible: setImageViewer,
|
|
640
|
-
modalContent: modalContent
|
|
641
|
-
}), React__default.createElement(SubscriptionHandler, {
|
|
642
|
-
channelId: channelId,
|
|
643
|
-
subscribeToNewMessages: () => subscribeToMore({
|
|
510
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, (loadingOldMessages || loadEarlierMsg) && /* @__PURE__ */ React__default.createElement(Spinner, { color: "$blue500" }), isPostParentIdThread && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, (threadPost == null ? void 0 : threadPost.length) > 0 && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(VStack, { px: "$2", pt: "$2", pb: "$0", space: "sm" }, /* @__PURE__ */ React__default.createElement(HStack, { space: "sm", alignItems: "center" }, /* @__PURE__ */ React__default.createElement(Avatar, { bg: "transparent", size: "md" }, /* @__PURE__ */ React__default.createElement(AvatarFallbackText, null, startCase((_c = (_b = (_a = threadPost[0]) == null ? void 0 : _a.author) == null ? void 0 : _b.username) == null ? void 0 : _c.charAt(0))), /* @__PURE__ */ React__default.createElement(AvatarImage, { alt: "image", style: {
|
|
511
|
+
borderRadius: 6,
|
|
512
|
+
borderWidth: 2,
|
|
513
|
+
borderColor: "#fff"
|
|
514
|
+
}, source: {
|
|
515
|
+
uri: (_e = (_d = threadPost[0]) == null ? void 0 : _d.author) == null ? void 0 : _e.picture
|
|
516
|
+
} })), /* @__PURE__ */ React__default.createElement(Box, null, /* @__PURE__ */ React__default.createElement(Text, { color: "$black", fontWeight: "$bold" }, (_h = (_g = (_f = threadPost[0]) == null ? void 0 : _f.author) == null ? void 0 : _g.givenName) != null ? _h : "", " ", (_k = (_j = (_i = threadPost[0]) == null ? void 0 : _i.author) == null ? void 0 : _j.familyName) != null ? _k : ""), /* @__PURE__ */ React__default.createElement(Text, { color: "$trueGray500", pl: "$0" }, createdAtText((_l = threadPost[0]) == null ? void 0 : _l.createdAt), " at", " ", format(new Date((_m = threadPost[0]) == null ? void 0 : _m.createdAt), "hh:ss:a")))), /* @__PURE__ */ React__default.createElement(HStack, { px: "$2", space: "sm", alignItems: "center" }, /* @__PURE__ */ React__default.createElement(Text, null, (_o = (_n = threadPost[0]) == null ? void 0 : _n.message) != null ? _o : ""))), /* @__PURE__ */ React__default.createElement(Box, { py: "$4" }, /* @__PURE__ */ React__default.createElement(Box, { px: "$4", borderTopWidth: "$1", borderBottomWidth: "$1", py: "$2", borderColor: "$trueGray200" }, /* @__PURE__ */ React__default.createElement(Text, { color: "$trueGray600", fontWeight: "$bold" }, (_q = (_p = threadPost[0]) == null ? void 0 : _p.replies) == null ? void 0 : _q.totalCount, " ", ((_s = (_r = threadPost[0]) == null ? void 0 : _r.replies) == null ? void 0 : _s.totalCount) > 0 ? "replies" : "reply"))))), /* @__PURE__ */ React__default.createElement(
|
|
517
|
+
GiftedChat,
|
|
518
|
+
{
|
|
519
|
+
ref: threadMessageListRef,
|
|
520
|
+
wrapInSafeArea: false,
|
|
521
|
+
renderLoading: () => /* @__PURE__ */ React__default.createElement(Spinner, { color: "$blue500" }),
|
|
522
|
+
messages: messageList,
|
|
523
|
+
listViewProps: {
|
|
524
|
+
onEndReached,
|
|
525
|
+
onEndReachedThreshold: 0.5,
|
|
526
|
+
onMomentumScrollBegin
|
|
527
|
+
},
|
|
528
|
+
onSend: (messages) => {
|
|
529
|
+
var _a2, _b2;
|
|
530
|
+
return handleSend((_b2 = (_a2 = messages[0]) == null ? void 0 : _a2.text) != null ? _b2 : " ");
|
|
531
|
+
},
|
|
532
|
+
text: msg ? msg : " ",
|
|
533
|
+
onInputTextChanged: (text) => setMsg(text),
|
|
534
|
+
renderFooter: () => loading ? /* @__PURE__ */ React__default.createElement(Spinner, { color: "$blue500" }) : imageLoading ? /* @__PURE__ */ React__default.createElement(Spinner, { color: "$blue500" }) : "",
|
|
535
|
+
scrollToBottom: true,
|
|
536
|
+
user: {
|
|
537
|
+
_id: (auth == null ? void 0 : auth.id) || ""
|
|
538
|
+
},
|
|
539
|
+
isTyping: true,
|
|
540
|
+
alwaysShowSend: loading ? false : true,
|
|
541
|
+
infiniteScroll: true,
|
|
542
|
+
renderSend,
|
|
543
|
+
renderMessageText,
|
|
544
|
+
minInputToolbarHeight: 50,
|
|
545
|
+
renderActions,
|
|
546
|
+
renderAccessory,
|
|
547
|
+
renderMessage,
|
|
548
|
+
renderChatFooter: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(ImageViewerModal, { isVisible: isShowImageViewer, setVisible: setImageViewer, modalContent }), /* @__PURE__ */ React__default.createElement(SubscriptionHandler, { channelId, subscribeToNewMessages: () => subscribeToMore({
|
|
644
549
|
document: OnThreadChatMessageAddedDocument,
|
|
645
550
|
variables: {
|
|
646
|
-
channelId: channelId
|
|
647
|
-
postParentId: !parentId || parentId == 0 ? null : parentId
|
|
551
|
+
channelId: channelId == null ? void 0 : channelId.toString(),
|
|
552
|
+
postParentId: !parentId || parentId == 0 ? null : parentId == null ? void 0 : parentId.toString()
|
|
648
553
|
},
|
|
649
554
|
updateQuery: (prev, {
|
|
650
555
|
subscriptionData
|
|
651
556
|
}) => {
|
|
652
|
-
var
|
|
653
|
-
if (!subscriptionData.data)
|
|
654
|
-
|
|
655
|
-
const
|
|
557
|
+
var _a2, _b2, _c2;
|
|
558
|
+
if (!subscriptionData.data)
|
|
559
|
+
return prev;
|
|
560
|
+
const newMessage = (_a2 = subscriptionData == null ? void 0 : subscriptionData.data) == null ? void 0 : _a2.threadChatMessageAdded;
|
|
561
|
+
const prevReplyCount = (_b2 = prev == null ? void 0 : prev.getPostThread) == null ? void 0 : _b2.replyCount;
|
|
656
562
|
const newReplyCount = prevReplyCount || 0 + 1;
|
|
657
|
-
const replies = ((
|
|
658
|
-
setChannelMessages(oldMessages => uniqBy([...oldMessages, newMessage], ({
|
|
563
|
+
const replies = ((_c2 = prev == null ? void 0 : prev.getPostThread) == null ? void 0 : _c2.replies) || [];
|
|
564
|
+
setChannelMessages((oldMessages) => uniqBy([...oldMessages, newMessage], ({
|
|
659
565
|
id
|
|
660
566
|
}) => id));
|
|
661
567
|
setTotalCount(newReplyCount);
|
|
662
568
|
return Object.assign({}, prev, {
|
|
663
|
-
getPostThread:
|
|
569
|
+
getPostThread: __spreadProps(__spreadValues({}, prev == null ? void 0 : prev.getPostThread), {
|
|
664
570
|
lastReplyAt: newMessage.createdAt,
|
|
665
571
|
replies: [newMessage, ...replies],
|
|
666
572
|
replyCount: newReplyCount,
|
|
@@ -668,38 +574,29 @@ const ThreadConversationViewComponent = ({
|
|
|
668
574
|
})
|
|
669
575
|
});
|
|
670
576
|
}
|
|
671
|
-
})
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}]
|
|
677
|
-
},
|
|
678
|
-
renderChatEmpty: () => React__default.createElement(React__default.Fragment, null, !threadLoading && messageList && (messageList === null || messageList === void 0 ? void 0 : messageList.length) == 0 && React__default.createElement(Box, {
|
|
679
|
-
p: '$5'
|
|
680
|
-
}, React__default.createElement(Center, {
|
|
681
|
-
mt: '$6'
|
|
682
|
-
}, React__default.createElement(Ionicons, {
|
|
683
|
-
name: "chatbubbles",
|
|
684
|
-
size: 30
|
|
685
|
-
}), React__default.createElement(Text, null, "You don't have any message yet!")))),
|
|
686
|
-
lightboxProps: {
|
|
687
|
-
underlayColor: 'transparent',
|
|
688
|
-
springConfig: {
|
|
689
|
-
tension: 90000,
|
|
690
|
-
friction: 90000
|
|
577
|
+
}) })),
|
|
578
|
+
messagesContainerStyle: (messageList == null ? void 0 : messageList.length) == 0 && {
|
|
579
|
+
transform: [{
|
|
580
|
+
scaleY: -1
|
|
581
|
+
}]
|
|
691
582
|
},
|
|
692
|
-
|
|
583
|
+
renderChatEmpty: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, !threadLoading && messageList && (messageList == null ? void 0 : messageList.length) == 0 && /* @__PURE__ */ React__default.createElement(Box, { p: "$5" }, /* @__PURE__ */ React__default.createElement(Center, { mt: "$6" }, /* @__PURE__ */ React__default.createElement(Ionicons, { name: "chatbubbles", size: 30 }), /* @__PURE__ */ React__default.createElement(Text, null, "You don't have any message yet!")))),
|
|
584
|
+
lightboxProps: {
|
|
585
|
+
underlayColor: "transparent",
|
|
586
|
+
springConfig: {
|
|
587
|
+
tension: 9e4,
|
|
588
|
+
friction: 9e4
|
|
589
|
+
},
|
|
590
|
+
disabled: true
|
|
591
|
+
}
|
|
693
592
|
}
|
|
694
|
-
|
|
593
|
+
));
|
|
695
594
|
};
|
|
696
595
|
const SubscriptionHandler = ({
|
|
697
596
|
subscribeToNewMessages,
|
|
698
597
|
channelId
|
|
699
598
|
}) => {
|
|
700
599
|
useEffect(() => subscribeToNewMessages(), [channelId]);
|
|
701
|
-
return React__default.createElement(React__default.Fragment, null);
|
|
600
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
|
|
702
601
|
};
|
|
703
|
-
const ThreadConversationView = ThreadConversationViewComponent;
|
|
704
|
-
// export const ThreadConversationView = React.memo(ThreadConversationViewComponent);
|
|
705
|
-
export{ThreadConversationView};//# sourceMappingURL=ThreadConversationView.js.map
|
|
602
|
+
const ThreadConversationView = ThreadConversationViewComponent;export{ThreadConversationView};//# sourceMappingURL=ThreadConversationView.js.map
|