@messenger-box/platform-mobile 0.0.1-alpha.411 → 0.0.1-alpha.421
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/index.js +217 -456
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/screens/inbox/components/SupportServiceDialogsListItem.tsx +97 -42
- package/src/screens/inbox/components/ThreadsViewItem.tsx +58 -26
- package/src/screens/inbox/containers/ConversationView.tsx +13 -33
- package/src/screens/inbox/containers/ThreadConversationView.tsx +66 -418
- package/src/screens/inbox/containers/ThreadsView.tsx +96 -34
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@messenger-box/platform-mobile",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.421",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"watch": "yarn build:lib:watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@messenger-box/core": "0.0.1-alpha.
|
|
23
|
-
"@messenger-box/platform-client": "0.0.1-alpha.
|
|
22
|
+
"@messenger-box/core": "0.0.1-alpha.421",
|
|
23
|
+
"@messenger-box/platform-client": "0.0.1-alpha.421",
|
|
24
24
|
"base-64": "1.0.0",
|
|
25
25
|
"react-native-gifted-chat": "1.0.4"
|
|
26
26
|
},
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"typescript": {
|
|
41
41
|
"definition": "lib/index.d.ts"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "452fdad1b1680b8bd0babb47f5d4f2e781f933bc"
|
|
44
44
|
}
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
useUserAccountQuery,
|
|
11
11
|
useOnThreadCreatedUpdatedSubscription,
|
|
12
12
|
useOnThreadChatMessageAddedSubscription,
|
|
13
|
+
OnThreadCreatedUpdatedDocument as THREAD_CHAT_ADDED,
|
|
14
|
+
OnThreadChatMessageAddedDocument as CHAT_MESSAGE_ADDED,
|
|
13
15
|
} from '@messenger-box/platform-client';
|
|
14
16
|
import { startCase } from 'lodash';
|
|
15
17
|
|
|
@@ -49,11 +51,13 @@ export const SupportServiceDialogsListItemComponent: React.FC<IDialogListItemPro
|
|
|
49
51
|
refreshing,
|
|
50
52
|
role,
|
|
51
53
|
}) {
|
|
54
|
+
const [servicePostParentId, setServicePostParentId] = React.useState(null);
|
|
52
55
|
const {
|
|
53
56
|
data: threadMessages,
|
|
54
57
|
loading: threadMessageLoading,
|
|
55
58
|
error,
|
|
56
59
|
refetch: refetchThreadMessages,
|
|
60
|
+
subscribeToMore,
|
|
57
61
|
} = useThreadMessagesQuery({
|
|
58
62
|
variables: {
|
|
59
63
|
channelId: channel?.id?.toString(),
|
|
@@ -101,6 +105,13 @@ export const SupportServiceDialogsListItemComponent: React.FC<IDialogListItemPro
|
|
|
101
105
|
}
|
|
102
106
|
}, [threadMessages]);
|
|
103
107
|
|
|
108
|
+
React.useEffect(() => {
|
|
109
|
+
if (lastMessage) {
|
|
110
|
+
const sParentId = lastMessage?.parentId ? lastMessage?.parentId : lastMessage?.id;
|
|
111
|
+
setServicePostParentId(sParentId);
|
|
112
|
+
}
|
|
113
|
+
}, [lastMessage]);
|
|
114
|
+
|
|
104
115
|
const creatorAndMembersId = React.useMemo(() => {
|
|
105
116
|
if (!channel?.members) return null;
|
|
106
117
|
const membersIds: any =
|
|
@@ -122,23 +133,23 @@ export const SupportServiceDialogsListItemComponent: React.FC<IDialogListItemPro
|
|
|
122
133
|
: lastMessage?.id ?? 0;
|
|
123
134
|
}, [creatorAndMembersId, lastMessage]);
|
|
124
135
|
|
|
125
|
-
const { data: threadCreatedUpdated } = useOnThreadCreatedUpdatedSubscription({
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
});
|
|
136
|
+
// const { data: threadCreatedUpdated } = useOnThreadCreatedUpdatedSubscription({
|
|
137
|
+
// variables: {
|
|
138
|
+
// channelId: channel?.id?.toString(),
|
|
139
|
+
// postParentId:
|
|
140
|
+
// postParentId == null
|
|
141
|
+
// ? null
|
|
142
|
+
// : lastMessage?.parentId
|
|
143
|
+
// ? lastMessage?.parentId ?? null
|
|
144
|
+
// : lastMessage?.id ?? null,
|
|
145
|
+
// },
|
|
146
|
+
// });
|
|
136
147
|
|
|
137
|
-
React.useEffect(() => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}, [threadCreatedUpdated]);
|
|
148
|
+
// React.useEffect(() => {
|
|
149
|
+
// if (threadCreatedUpdated?.threadCreatedUpdated?.data) {
|
|
150
|
+
// refetchThreadMessages({ channelId: channel?.id?.toString(), role, limit: 2 });
|
|
151
|
+
// }
|
|
152
|
+
// }, [threadCreatedUpdated]);
|
|
142
153
|
|
|
143
154
|
return (
|
|
144
155
|
<Pressable
|
|
@@ -194,32 +205,44 @@ export const SupportServiceDialogsListItemComponent: React.FC<IDialogListItemPro
|
|
|
194
205
|
</Avatar.Group>
|
|
195
206
|
</Box>
|
|
196
207
|
<Box flex={0.9}>
|
|
197
|
-
<
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
208
|
+
<ServiceChannelWithLastMessage
|
|
209
|
+
channel={channel}
|
|
210
|
+
lastMessage={lastMessage}
|
|
211
|
+
subscribeToNewMessages={() =>
|
|
212
|
+
subscribeToMore({
|
|
213
|
+
document: THREAD_CHAT_ADDED,
|
|
214
|
+
variables: {
|
|
215
|
+
channelId: channel?.id?.toString(),
|
|
216
|
+
postParentId: postParentId ? servicePostParentId : null,
|
|
217
|
+
},
|
|
218
|
+
updateQuery: (prev, { subscriptionData }: any) => {
|
|
219
|
+
if (!subscriptionData.data) return prev;
|
|
220
|
+
|
|
221
|
+
const newPostThreadData: any = subscriptionData?.data?.threadCreatedUpdated?.data;
|
|
222
|
+
const newMessage: any = subscriptionData?.data?.threadCreatedUpdated?.lastMessage;
|
|
223
|
+
const data = prev?.threadMessages?.data?.map((t: any) =>
|
|
224
|
+
t.id === newPostThreadData?.id
|
|
225
|
+
? {
|
|
226
|
+
...t,
|
|
227
|
+
replies: [...t?.replies, newMessage],
|
|
228
|
+
replyCount: newPostThreadData?.replyCount,
|
|
229
|
+
lastReplyAt: newPostThreadData?.lastReplyAt,
|
|
230
|
+
updatedAt: newPostThreadData?.updatedAt,
|
|
231
|
+
}
|
|
232
|
+
: t,
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
return Object.assign({}, prev, {
|
|
236
|
+
threadMessages: {
|
|
237
|
+
...prev?.threadMessages,
|
|
238
|
+
// totalCount: prev?.threadMessages?.totalCount + 1,
|
|
239
|
+
data: data,
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
/>
|
|
223
246
|
{/* <Text
|
|
224
247
|
flex={1}
|
|
225
248
|
color="gray.600"
|
|
@@ -244,4 +267,36 @@ export const SupportServiceDialogsListItemComponent: React.FC<IDialogListItemPro
|
|
|
244
267
|
);
|
|
245
268
|
};
|
|
246
269
|
|
|
270
|
+
const ServiceChannelWithLastMessage = React.memo(({ channel, lastMessage, subscribeToNewMessages }: any) => {
|
|
271
|
+
React.useEffect(() => subscribeToNewMessages(), []);
|
|
272
|
+
return (
|
|
273
|
+
<HStack space={1} flex={1} direction={'row'} justifyContent={'center'} alignItems={'center'}>
|
|
274
|
+
<Box flex={0.8}>
|
|
275
|
+
<Text color="gray.600" fontSize="lg" flexWrap={'wrap'} fontWeight="semibold">
|
|
276
|
+
{channel?.title}
|
|
277
|
+
</Text>
|
|
278
|
+
<Text color="gray.600" noOfLines={1}>
|
|
279
|
+
{/* {creatorAndMembersId?.length && creatorAndMembersId?.includes(currentUser?.id)
|
|
280
|
+
? lastMessageCreatorAndMembers?.message ?? ''
|
|
281
|
+
: lastMessage?.message ?? ''} */}
|
|
282
|
+
{lastMessage?.message ?? ''}
|
|
283
|
+
</Text>
|
|
284
|
+
</Box>
|
|
285
|
+
|
|
286
|
+
<Box flex={0.2}>
|
|
287
|
+
{/* {creatorAndMembersId?.length && creatorAndMembersId?.includes(currentUser?.id) ? (
|
|
288
|
+
<Text color="gray.500">
|
|
289
|
+
{lastMessageCreatorAndMembers
|
|
290
|
+
? createdAtText(lastMessageCreatorAndMembers?.createdAt)
|
|
291
|
+
: ''}
|
|
292
|
+
</Text>
|
|
293
|
+
) : (
|
|
294
|
+
<Text color="gray.500">{lastMessage ? createdAtText(lastMessage?.createdAt) : ''}</Text>
|
|
295
|
+
)} */}
|
|
296
|
+
<Text color="gray.500">{lastMessage ? createdAtText(lastMessage?.createdAt) : ''}</Text>
|
|
297
|
+
</Box>
|
|
298
|
+
</HStack>
|
|
299
|
+
);
|
|
300
|
+
});
|
|
301
|
+
|
|
247
302
|
export const SupportServiceDialogsListItem = React.memo(SupportServiceDialogsListItemComponent);
|
|
@@ -47,12 +47,12 @@ export const ThreadViewItemComponent: React.FC<IDialogListItemProps> = function
|
|
|
47
47
|
role,
|
|
48
48
|
setData,
|
|
49
49
|
}) {
|
|
50
|
-
const { data: threadCreatedUpdated } = useOnThreadCreatedUpdatedSubscription({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
50
|
+
// const { data: threadCreatedUpdated } = useOnThreadCreatedUpdatedSubscription({
|
|
51
|
+
// variables: {
|
|
52
|
+
// channelId: thread?.channel?.id?.toString(),
|
|
53
|
+
// postParentId: thread?.post?.id?.toString(),
|
|
54
|
+
// },
|
|
55
|
+
// });
|
|
56
56
|
|
|
57
57
|
useFocusEffect(
|
|
58
58
|
React.useCallback(() => {
|
|
@@ -64,16 +64,21 @@ export const ThreadViewItemComponent: React.FC<IDialogListItemProps> = function
|
|
|
64
64
|
}, []),
|
|
65
65
|
);
|
|
66
66
|
|
|
67
|
-
React.useEffect(() => {
|
|
68
|
-
if (threadCreatedUpdated?.threadCreatedUpdated?.data) setData(threadCreatedUpdated?.threadCreatedUpdated?.data);
|
|
69
|
-
}, [threadCreatedUpdated?.threadCreatedUpdated]);
|
|
70
|
-
|
|
71
67
|
const threadPostReply = React.useMemo(() => {
|
|
72
68
|
if (!thread?.replies) return null;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
return thread?.replies;
|
|
70
|
+
}, [thread]);
|
|
71
|
+
|
|
72
|
+
// React.useEffect(() => {
|
|
73
|
+
// if (threadCreatedUpdated?.threadCreatedUpdated?.data) setData(threadCreatedUpdated?.threadCreatedUpdated?.data);
|
|
74
|
+
// }, [threadCreatedUpdated?.threadCreatedUpdated]);
|
|
75
|
+
|
|
76
|
+
// const threadPostReply = React.useMemo(() => {
|
|
77
|
+
// if (!thread?.replies) return null;
|
|
78
|
+
// if (threadCreatedUpdated?.threadCreatedUpdated?.data?.replies?.length) {
|
|
79
|
+
// return threadCreatedUpdated?.threadCreatedUpdated?.data?.replies;
|
|
80
|
+
// } else return thread?.replies;
|
|
81
|
+
// }, [thread, threadCreatedUpdated]);
|
|
77
82
|
|
|
78
83
|
// const lastMessage = useMemo(() => {
|
|
79
84
|
// if (!threadPost) {
|
|
@@ -232,18 +237,45 @@ export const ThreadViewItemComponent: React.FC<IDialogListItemProps> = function
|
|
|
232
237
|
{/* {lastMessage ? createdAtText(lastMessage?.createdAt) : ''} */}
|
|
233
238
|
</Text>
|
|
234
239
|
</HStack>
|
|
235
|
-
<
|
|
236
|
-
{reply?.message
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
240
|
+
<VStack space={1}>
|
|
241
|
+
{reply?.message && (
|
|
242
|
+
<Text color="gray.600" noOfLines={2}>
|
|
243
|
+
{reply?.message.length < 70
|
|
244
|
+
? `${reply?.message}`
|
|
245
|
+
: `${reply?.message.substring(0, 68)}....`}
|
|
246
|
+
</Text>
|
|
247
|
+
)}
|
|
248
|
+
{/* <Text color="gray.600" noOfLines={2}>
|
|
249
|
+
{reply?.message
|
|
250
|
+
? reply?.message.length < 70
|
|
251
|
+
? `${reply?.message}`
|
|
252
|
+
: `${reply?.message.substring(0, 68)}....`
|
|
253
|
+
: ''}
|
|
254
|
+
</Text> */}
|
|
255
|
+
|
|
256
|
+
<>
|
|
257
|
+
{reply?.files?.data?.length > 0 &&
|
|
258
|
+
reply?.files?.data?.map((f: any) => (
|
|
259
|
+
<Box>
|
|
260
|
+
<Avatar
|
|
261
|
+
bg={'transparent'}
|
|
262
|
+
size={8}
|
|
263
|
+
_image={{
|
|
264
|
+
borderRadius: 6,
|
|
265
|
+
borderWidth: 2,
|
|
266
|
+
borderColor: '#fff',
|
|
267
|
+
}}
|
|
268
|
+
source={{
|
|
269
|
+
uri: f?.url,
|
|
270
|
+
}}
|
|
271
|
+
>
|
|
272
|
+
I
|
|
273
|
+
</Avatar>
|
|
274
|
+
</Box>
|
|
275
|
+
))}
|
|
276
|
+
</>
|
|
277
|
+
</VStack>
|
|
278
|
+
|
|
247
279
|
{(threadPostReply?.length == 1 || index !== 0) && (
|
|
248
280
|
<Button
|
|
249
281
|
size={'xs'}
|
|
@@ -1,45 +1,29 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useMemo,
|
|
2
|
-
import {
|
|
3
|
-
Box,
|
|
4
|
-
Button,
|
|
5
|
-
HStack,
|
|
6
|
-
Icon,
|
|
7
|
-
Image,
|
|
8
|
-
Spinner,
|
|
9
|
-
Text,
|
|
10
|
-
useColorModeValue,
|
|
11
|
-
Avatar,
|
|
12
|
-
ScrollView,
|
|
13
|
-
Center,
|
|
14
|
-
} from 'native-base';
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { Avatar, Box, Button, HStack, Icon, Image, Spinner, Text, useColorModeValue, } from 'native-base';
|
|
15
3
|
import { Platform, TouchableHighlight } from 'react-native';
|
|
16
|
-
import {
|
|
4
|
+
import { useFocusEffect, useIsFocused, useNavigation } from '@react-navigation/native';
|
|
17
5
|
import { useSelector } from 'react-redux';
|
|
18
|
-
import { orderBy,
|
|
6
|
+
import { orderBy, startCase, uniqBy } from 'lodash';
|
|
19
7
|
import * as ImagePicker from 'expo-image-picker';
|
|
20
8
|
import { encode as atob } from 'base-64';
|
|
21
9
|
import { Ionicons, MaterialCommunityIcons } from '@expo/vector-icons';
|
|
22
10
|
import { Actions, GiftedChat, IMessage, MessageText, Send } from 'react-native-gifted-chat';
|
|
23
11
|
import {
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
IPreDefinedRole,
|
|
13
|
+
OnChatMessageAddedDocument as CHAT_MESSAGE_ADDED,
|
|
26
14
|
useMessagesQuery,
|
|
15
|
+
useSendExpoNotificationOnPostMutation,
|
|
27
16
|
useSendMessagesMutation,
|
|
28
|
-
useViewChannelDetailQuery,
|
|
29
17
|
useUploadFilesNative,
|
|
30
|
-
|
|
31
|
-
useOnChatMessageAddedSubscription,
|
|
32
|
-
IPreDefinedRole,
|
|
33
|
-
useSendExpoNotificationOnPostMutation,
|
|
34
|
-
OnChatMessageAddedDocument as CHAT_MESSAGE_ADDED,
|
|
35
|
-
IPost,
|
|
18
|
+
useViewChannelDetailQuery,
|
|
36
19
|
} from '@messenger-box/platform-client';
|
|
37
|
-
import { IExpoNotificationData, IFileInfo } from '@messenger-box/core';
|
|
20
|
+
import { IExpoNotificationData, IFileInfo, objectId } from '@messenger-box/core';
|
|
38
21
|
import { config } from '../config';
|
|
39
22
|
import { userSelector } from '@adminide-stack/user-auth0-client';
|
|
40
|
-
import {
|
|
23
|
+
import { ImageViewerModal, SlackMessage } from '../components/SlackMessageContainer';
|
|
41
24
|
import CachedImage from '../components/CachedImage';
|
|
42
25
|
import { format, isToday, isYesterday } from 'date-fns';
|
|
26
|
+
|
|
43
27
|
const {
|
|
44
28
|
MESSAGES_PER_PAGE,
|
|
45
29
|
CALL_TO_ACTION_BOX_BGCOLOR,
|
|
@@ -99,9 +83,6 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
|
|
|
99
83
|
const [skip, setSkip] = useState(0);
|
|
100
84
|
const messageRootListRef = useRef<any>(null);
|
|
101
85
|
const isFocused = useIsFocused();
|
|
102
|
-
const { data: mongooseObjectId, refetch: refetchNewPostId } = useGetNewMongooseObjectIdQuery({
|
|
103
|
-
fetchPolicy: 'network-only',
|
|
104
|
-
});
|
|
105
86
|
|
|
106
87
|
const { startUpload } = useUploadFilesNative();
|
|
107
88
|
|
|
@@ -265,8 +246,7 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
|
|
|
265
246
|
};
|
|
266
247
|
|
|
267
248
|
if (images && images.length > 0) {
|
|
268
|
-
const
|
|
269
|
-
const postId: any = newPostId?.data?.getNewMongooseObjectId?.toString();
|
|
249
|
+
const postId = objectId()
|
|
270
250
|
|
|
271
251
|
setLoading(true);
|
|
272
252
|
const uploadResponse = await startUpload({
|
|
@@ -331,7 +311,7 @@ const ConversationViewComponent = ({ channelId, role }: any) => {
|
|
|
331
311
|
});
|
|
332
312
|
}
|
|
333
313
|
},
|
|
334
|
-
[
|
|
314
|
+
[setChannelMessages, channelId, images, channelToTop, expoTokens],
|
|
335
315
|
);
|
|
336
316
|
|
|
337
317
|
const messageList = useMemo(() => {
|