@messenger-box/platform-mobile 10.0.3-alpha.18 → 10.0.3-alpha.180

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.
Files changed (98) hide show
  1. package/lib/compute.js +2 -3
  2. package/lib/compute.js.map +1 -1
  3. package/lib/index.js.map +1 -1
  4. package/lib/module.js.map +1 -1
  5. package/lib/queries/inboxQueries.js +65 -0
  6. package/lib/queries/inboxQueries.js.map +1 -0
  7. package/lib/routes.json +2 -3
  8. package/lib/screens/inbox/DialogMessages.js +8 -3
  9. package/lib/screens/inbox/DialogMessages.js.map +1 -1
  10. package/lib/screens/inbox/DialogThreadMessages.js +6 -11
  11. package/lib/screens/inbox/DialogThreadMessages.js.map +1 -1
  12. package/lib/screens/inbox/DialogThreads.js +58 -20
  13. package/lib/screens/inbox/DialogThreads.js.map +1 -1
  14. package/lib/screens/inbox/Inbox.js.map +1 -1
  15. package/lib/screens/inbox/components/CachedImage/consts.js.map +1 -1
  16. package/lib/screens/inbox/components/CachedImage/index.js +125 -115
  17. package/lib/screens/inbox/components/CachedImage/index.js.map +1 -1
  18. package/lib/screens/inbox/components/DialogItem.js +160 -0
  19. package/lib/screens/inbox/components/DialogItem.js.map +1 -0
  20. package/lib/screens/inbox/components/GiftedChatInboxComponent.js +313 -0
  21. package/lib/screens/inbox/components/GiftedChatInboxComponent.js.map +1 -0
  22. package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.js +2 -0
  23. package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.js.map +1 -1
  24. package/lib/screens/inbox/components/SlackMessageContainer/PaymentMessage.js +194 -0
  25. package/lib/screens/inbox/components/SlackMessageContainer/PaymentMessage.js.map +1 -0
  26. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js +144 -32
  27. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js.map +1 -1
  28. package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js +3 -4
  29. package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js.map +1 -1
  30. package/lib/screens/inbox/components/SubscriptionHandler.js +22 -0
  31. package/lib/screens/inbox/components/SubscriptionHandler.js.map +1 -0
  32. package/lib/screens/inbox/components/ThreadsViewItem.js +67 -47
  33. package/lib/screens/inbox/components/ThreadsViewItem.js.map +1 -1
  34. package/lib/screens/inbox/config/config.js +4 -2
  35. package/lib/screens/inbox/config/config.js.map +1 -1
  36. package/lib/screens/inbox/containers/ConversationView.js +1098 -1093
  37. package/lib/screens/inbox/containers/ConversationView.js.map +1 -1
  38. package/lib/screens/inbox/containers/Dialogs.js +179 -333
  39. package/lib/screens/inbox/containers/Dialogs.js.map +1 -1
  40. package/lib/screens/inbox/containers/ThreadConversationView.js +873 -866
  41. package/lib/screens/inbox/containers/ThreadConversationView.js.map +1 -1
  42. package/lib/screens/inbox/containers/ThreadsView.js +81 -54
  43. package/lib/screens/inbox/containers/ThreadsView.js.map +1 -1
  44. package/lib/screens/inbox/hooks/useInboxMessages.js +31 -0
  45. package/lib/screens/inbox/hooks/useInboxMessages.js.map +1 -0
  46. package/lib/screens/inbox/hooks/useSafeDialogThreadsMachine.js +108 -0
  47. package/lib/screens/inbox/hooks/useSafeDialogThreadsMachine.js.map +1 -0
  48. package/lib/screens/inbox/workflow/dialog-threads-xstate.js +151 -0
  49. package/lib/screens/inbox/workflow/dialog-threads-xstate.js.map +1 -0
  50. package/package.json +5 -5
  51. package/CHANGELOG.md +0 -156
  52. package/jest.config.js +0 -24
  53. package/lib/screens/inbox/components/DialogsListItem.js +0 -175
  54. package/lib/screens/inbox/components/DialogsListItem.js.map +0 -1
  55. package/lib/screens/inbox/components/ServiceDialogsListItem.js +0 -165
  56. package/lib/screens/inbox/components/ServiceDialogsListItem.js.map +0 -1
  57. package/lib/screens/inbox/containers/workflow/conversation-xstate.js +0 -380
  58. package/lib/screens/inbox/containers/workflow/conversation-xstate.js.map +0 -1
  59. package/lib/screens/inbox/containers/workflow/dialogs-xstate.js +0 -235
  60. package/lib/screens/inbox/containers/workflow/dialogs-xstate.js.map +0 -1
  61. package/lib/screens/inbox/containers/workflow/thread-conversation-xstate.js +0 -438
  62. package/lib/screens/inbox/containers/workflow/thread-conversation-xstate.js.map +0 -1
  63. package/rollup.config.mjs +0 -45
  64. package/src/components/index.ts +0 -0
  65. package/src/compute.ts +0 -63
  66. package/src/index.ts +0 -7
  67. package/src/module.ts +0 -10
  68. package/src/navigation/InboxNavigation.tsx +0 -102
  69. package/src/navigation/index.ts +0 -1
  70. package/src/screens/inbox/DialogMessages.tsx +0 -21
  71. package/src/screens/inbox/DialogThreadMessages.tsx +0 -97
  72. package/src/screens/inbox/DialogThreads.tsx +0 -129
  73. package/src/screens/inbox/Inbox.tsx +0 -17
  74. package/src/screens/inbox/components/CachedImage/consts.ts +0 -6
  75. package/src/screens/inbox/components/CachedImage/index.tsx +0 -223
  76. package/src/screens/inbox/components/DialogsHeader.tsx +0 -30
  77. package/src/screens/inbox/components/DialogsListItem.tsx +0 -302
  78. package/src/screens/inbox/components/ServiceDialogsListItem.tsx +0 -287
  79. package/src/screens/inbox/components/SlackMessageContainer/ImageViewerModal.tsx +0 -113
  80. package/src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx +0 -313
  81. package/src/screens/inbox/components/SlackMessageContainer/SlackMessage.tsx +0 -145
  82. package/src/screens/inbox/components/SlackMessageContainer/index.ts +0 -3
  83. package/src/screens/inbox/components/SupportServiceDialogsListItem.tsx +0 -283
  84. package/src/screens/inbox/components/ThreadsViewItem.tsx +0 -321
  85. package/src/screens/inbox/config/config.ts +0 -15
  86. package/src/screens/inbox/config/index.ts +0 -1
  87. package/src/screens/inbox/containers/ConversationView.tsx +0 -1782
  88. package/src/screens/inbox/containers/Dialogs.tsx +0 -544
  89. package/src/screens/inbox/containers/SupportServiceDialogs.tsx +0 -119
  90. package/src/screens/inbox/containers/ThreadConversationView.tsx +0 -1537
  91. package/src/screens/inbox/containers/ThreadsView.tsx +0 -305
  92. package/src/screens/inbox/containers/workflow/apollo/handleResult.ts +0 -20
  93. package/src/screens/inbox/containers/workflow/conversation-xstate.ts +0 -313
  94. package/src/screens/inbox/containers/workflow/dialogs-xstate.ts +0 -196
  95. package/src/screens/inbox/containers/workflow/thread-conversation-xstate.ts +0 -401
  96. package/src/screens/index.ts +0 -4
  97. package/tsconfig.json +0 -13
  98. package/webpack.config.js +0 -58
@@ -1,287 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import {
3
- Text,
4
- Image,
5
- Pressable,
6
- HStack,
7
- Box,
8
- AvatarGroup,
9
- Avatar,
10
- AvatarFallbackText,
11
- AvatarImage,
12
- AvatarBadge,
13
- View,
14
- } from '@admin-layout/gluestack-ui-mobile';
15
- import { format, isToday, isYesterday } from 'date-fns';
16
- import { useFocusEffect } from '@react-navigation/native';
17
- import { IChannel, IUserAccount } from 'common';
18
- import {
19
- useOnThreadCreatedUpdatedSubscription,
20
- useOnThreadChatMessageAddedSubscription,
21
- useThreadMessagesQuery,
22
- OnThreadCreatedUpdatedDocument as THREAD_CHAT_ADDED,
23
- OnThreadChatMessageAddedDocument as CHAT_MESSAGE_ADDED,
24
- } from 'common/graphql';
25
- import { startCase } from 'lodash-es';
26
- import colors from 'tailwindcss/colors';
27
-
28
- const createdAtText = (value: string) => {
29
- if (!value) return '';
30
- let date = new Date(value);
31
- if (isToday(date)) return 'Today';
32
- if (isYesterday(date)) return 'Yesterday';
33
- return format(new Date(value), 'MMM dd, yyyy');
34
- };
35
-
36
- export interface IDialogListChannel extends IChannel {
37
- users: IUserAccount[];
38
- }
39
-
40
- export interface IDialogListItemProps {
41
- currentUser?: any;
42
- users?: any;
43
- selectedChannelId?: any;
44
- channel?: any;
45
- onOpen: (id: any, title: any, postParentId?: any) => void;
46
- refreshing: boolean;
47
- role: any;
48
- }
49
-
50
- /**
51
- * TODO:
52
- * - Get Reservation info: reservation date, status
53
- * - Add ability to get property information: name, logo
54
- */
55
- export const ServiceDialogsListItemComponent: React.FC<IDialogListItemProps> = function DialogsListItem({
56
- currentUser,
57
- // users,
58
- selectedChannelId,
59
- channel,
60
- onOpen,
61
- refreshing,
62
- role,
63
- }) {
64
- const [servicePostParentId, setServicePostParentId] = React.useState(null);
65
- const {
66
- data: threadMessages,
67
- loading: threadMessageLoading,
68
- error,
69
- refetch: refetchThreadMessages,
70
- subscribeToMore,
71
- } = useThreadMessagesQuery({
72
- variables: {
73
- channelId: channel?.id?.toString(),
74
- role,
75
- limit: 2,
76
- },
77
- fetchPolicy: 'cache-and-network',
78
- });
79
-
80
- useFocusEffect(
81
- React.useCallback(() => {
82
- // Do something when the screen is focused
83
- // refetchMessages({ channelId: channel?.id?.toString(), limit: 25 });
84
- refetchThreadMessages({ channelId: channel?.id?.toString(), role, limit: 2 });
85
- return () => {
86
- // Do something when the screen is unfocused
87
- // Useful for cleanup functions
88
- };
89
- }, [refreshing]),
90
- );
91
-
92
- const lastMessage = useMemo(() => {
93
- if (!threadMessages?.threadMessages?.data?.length) {
94
- return null;
95
- }
96
- const { data }: any = threadMessages.threadMessages;
97
- const replies =
98
- data
99
- ?.map((t: any) => t?.replies)
100
- ?.flat(1)
101
- ?.filter((p: any) => p?.message !== '') ?? [];
102
- if (replies?.length) {
103
- return replies[0];
104
- // return replies[replies.length - 1];
105
- } else {
106
- const post =
107
- data?.find((t: any) => {
108
- return t?.post?.message !== '';
109
- }) ??
110
- data?.find((t: any) => {
111
- return t?.post;
112
- }) ??
113
- null;
114
- return post ? post?.post : null;
115
- }
116
- }, [threadMessages]);
117
-
118
- React.useEffect(() => {
119
- if (lastMessage) {
120
- const sParentId = lastMessage?.parentId ? lastMessage?.parentId : lastMessage?.id;
121
- setServicePostParentId(sParentId);
122
- }
123
- }, [lastMessage]);
124
-
125
- const creatorAndMembersId = React.useMemo(() => {
126
- if (!channel?.members) return null;
127
- const membersIds: any =
128
- channel?.members
129
- ?.filter((m: any) => m !== null && m?.user?.id !== currentUser?.id)
130
- ?.map((mu: any) => mu?.user?.id) ?? [];
131
- const creatorId: any = channel?.creator?.id;
132
- const mergedIds: any = [].concat(membersIds, creatorId) ?? [];
133
- return mergedIds?.filter((m: any, pos: any) => mergedIds?.indexOf(m) === pos) ?? [];
134
- }, [channel]);
135
-
136
- const postParentId = React.useMemo(() => {
137
- if (!creatorAndMembersId?.length) return null;
138
-
139
- return creatorAndMembersId?.length && creatorAndMembersId?.includes(currentUser?.id)
140
- ? null
141
- : lastMessage?.parentId
142
- ? lastMessage?.parentId
143
- : lastMessage?.id ?? 0;
144
- }, [creatorAndMembersId, lastMessage]);
145
-
146
- // const { data: threadCreatedUpdated } = useOnThreadCreatedUpdatedSubscription({
147
- // variables: {
148
- // channelId: channel?.id?.toString(),
149
- // postParentId:
150
- // postParentId == null
151
- // ? null
152
- // : lastMessage?.parentId
153
- // ? lastMessage?.parentId ?? null
154
- // : lastMessage?.id ?? null,
155
- // },
156
- // });
157
-
158
- // React.useEffect(() => {
159
- // if (threadCreatedUpdated?.threadCreatedUpdated?.data) {
160
- // refetchThreadMessages({ channelId: channel?.id?.toString(), role, limit: 2 });
161
- // }
162
- // }, [threadCreatedUpdated]);
163
-
164
- return (
165
- <Pressable
166
- onPress={() => channel?.id !== selectedChannelId && onOpen(channel?.id, channel?.title, postParentId)}
167
- className="flex-1 rounded-md border-gray-200 dark:border-gray-600 dark:bg-gray-700"
168
- style={{ borderBottomWidth: 1, borderColor: '#e5e7eb', marginVertical: 0 }}
169
- >
170
- <HStack space={'md'} className="flex-1 w-[100%] px-2 py-3 items-center">
171
- <Box className="flex-[0.1] items-start pl-3">
172
- <Avatar
173
- key={'service-channels-key-' + channel?.id}
174
- size={'sm'}
175
- className="bg-transparent top-0 right-0 z-[1]"
176
- >
177
- <AvatarFallbackText> {startCase(channel?.creator?.username?.charAt(0))}</AvatarFallbackText>
178
- <AvatarImage
179
- alt="user image"
180
- style={{ borderRadius: 6, borderWidth: 2, borderColor: '#fff' }}
181
- source={{
182
- uri: channel?.creator?.picture,
183
- }}
184
- />
185
- </Avatar>
186
- </Box>
187
- <Box className="flex-1">
188
- <ServiceChannelWithLastMessage
189
- channel={channel}
190
- lastMessage={lastMessage}
191
- subscribeToNewMessages={() =>
192
- subscribeToMore({
193
- document: THREAD_CHAT_ADDED,
194
- variables: {
195
- channelId: channel?.id?.toString(),
196
- postParentId: postParentId ? servicePostParentId : null,
197
- },
198
- updateQuery: (prev, { subscriptionData }: any) => {
199
- if (!subscriptionData.data) return prev;
200
-
201
- const newPostThreadData: any = subscriptionData?.data?.threadCreatedUpdated?.data;
202
- const newMessage: any = subscriptionData?.data?.threadCreatedUpdated?.lastMessage;
203
- const data =
204
- prev?.threadMessages?.data?.map((t: any) =>
205
- t.id === newPostThreadData?.id
206
- ? {
207
- ...t,
208
- replies: [...t?.replies, newMessage],
209
- replyCount: newPostThreadData?.replyCount,
210
- lastReplyAt: newPostThreadData?.lastReplyAt,
211
- updatedAt: newPostThreadData?.updatedAt,
212
- }
213
- : t,
214
- ) ?? [];
215
-
216
- return Object.assign({}, prev, {
217
- threadMessages: {
218
- ...prev?.threadMessages,
219
- totalCount: newPostThreadData?.totalCount ?? 0,
220
- data: data?.length > 0 ? data : [newPostThreadData],
221
- // totalCount: prev?.threadMessages?.totalCount + 1,
222
- //data: data,
223
- },
224
- });
225
- },
226
- })
227
- }
228
- />
229
- {/* <Text
230
- flex={1}
231
- color="gray.600"
232
- p={0}
233
- m={0}
234
- w={'100%'}
235
- justifyContent={''}
236
- fontSize="lg"
237
- fontWeight="semibold"
238
- >
239
- {title}
240
- </Text> */}
241
- {/* <Text flex={0.1} color="gray.600">
242
- {lastMessage?.message ?? ''}
243
- </Text> */}
244
- </Box>
245
- {/* <Text flex={0.2} color="gray.500">
246
- {lastMessage ? createdAtText(lastMessage?.createdAt) : ''}
247
- </Text> */}
248
- </HStack>
249
- </Pressable>
250
- );
251
- };
252
-
253
- const ServiceChannelWithLastMessage = React.memo(({ channel, lastMessage, subscribeToNewMessages }: any) => {
254
- React.useEffect(() => subscribeToNewMessages(), []);
255
- const count = 20;
256
- const title = channel?.title.slice(0, count) + (channel?.title.length > count ? '...' : '');
257
- return (
258
- <HStack space={'sm'} className="flex-1 justify-between">
259
- <Box className="flex-[0.8]">
260
- <Text color={colors.gray[600]} className="text-base text-wrap flex-wrap font-semibold">
261
- {title}
262
- </Text>
263
- <Text color={colors.gray[600]} numberOfLines={1}>
264
- {/* {creatorAndMembersId?.length && creatorAndMembersId?.includes(currentUser?.id)
265
- ? lastMessageCreatorAndMembers?.message ?? ''
266
- : lastMessage?.message ?? ''} */}
267
- {lastMessage?.message ?? ''}
268
- </Text>
269
- </Box>
270
-
271
- <Box className="flex-[0.2]">
272
- {/* {creatorAndMembersId?.length && creatorAndMembersId?.includes(currentUser?.id) ? (
273
- <Text color="gray.500">
274
- {lastMessageCreatorAndMembers
275
- ? createdAtText(lastMessageCreatorAndMembers?.createdAt)
276
- : ''}
277
- </Text>
278
- ) : (
279
- <Text color="gray.500">{lastMessage ? createdAtText(lastMessage?.createdAt) : ''}</Text>
280
- )} */}
281
- <Text color={colors.gray[500]}>{lastMessage ? createdAtText(lastMessage?.createdAt) : ''}</Text>
282
- </Box>
283
- </HStack>
284
- );
285
- });
286
-
287
- export const ServiceDialogsListItem = React.memo(ServiceDialogsListItemComponent);
@@ -1,113 +0,0 @@
1
- import React, {useState} from 'react';
2
- import {Alert, Modal, StyleSheet, Text, Pressable, View,SafeAreaView,StatusBar} from 'react-native';
3
-
4
- const ImageViewerModal = ({children,isVisible=false,setVisible,modalContent=null}:any) => {
5
-
6
- return (
7
- <Modal
8
- animationType="slide"
9
- // transparent={true}
10
- visible={isVisible}
11
- presentationStyle={'fullScreen'}
12
- style={{flex:1}}
13
- onRequestClose={() => {
14
- setVisible(false);
15
- }}>
16
- <View style={styles.container}>
17
- <View style={styles.headerView}>
18
- {/* <View><Text></Text></View>
19
- <View><Text></Text></View> */}
20
- <View style={{alignSelf:'flex-end',paddingRight:5}} >
21
- <Pressable
22
- style={[styles.button, styles.buttonClose]}
23
- onPress={() => setVisible(false)}>
24
- <Text style={styles.headerTextStyle}>X</Text>
25
- </Pressable></View>
26
- </View>
27
- <View style={styles.centeredView}>
28
- {modalContent ? modalContent : children}
29
- </View>
30
- <View style={styles.footerView}>
31
-
32
- </View>
33
- </View>
34
- </Modal>
35
- );
36
- };
37
-
38
- const styles = StyleSheet.create({
39
- container:{
40
- flex:1,
41
- },
42
- headerView:{
43
- width:'100%',
44
- alignItems: 'center',
45
- justifyContent:'space-between',
46
- // backgroundColor:'rgba(r, g, b, a)',
47
- backgroundColor:'#000',
48
- paddingTop:50,
49
- paddingBottom:10,
50
- },
51
- centeredView: {
52
- flex: 1,
53
- justifyContent: 'center',
54
- alignItems: 'center',
55
- backgroundColor: 'white',
56
-
57
- borderRadius: 20,
58
- shadowColor: '#000',
59
- shadowOffset: {
60
- width: 0,
61
- height: 2,
62
- },
63
- shadowOpacity: 0.25,
64
- shadowRadius: 4,
65
- elevation: 5,
66
- },
67
- footerView:{
68
- minHeight:100,
69
- backgroundColor:'#000'
70
- },
71
- modalView: {
72
- flex:1,
73
- backgroundColor: 'white',
74
- borderRadius: 20,
75
- alignItems: 'center',
76
- shadowColor: '#000',
77
- shadowOffset: {
78
- width: 0,
79
- height: 2,
80
- },
81
- shadowOpacity: 0.25,
82
- shadowRadius: 4,
83
- elevation: 5,
84
- },
85
- button: {
86
- borderRadius: 20,
87
- padding: 10,
88
- elevation: 2,
89
- },
90
- buttonOpen: {
91
- backgroundColor: '#F194FF',
92
- },
93
- buttonClose: {
94
- backgroundColor: 'transparent',
95
- },
96
- textStyle: {
97
- color: 'white',
98
- fontWeight: 'bold',
99
- textAlign: 'center',
100
- },
101
- headerTextStyle:{
102
- color: '#fff',
103
- // fontWeight: 'bold',
104
- textAlign: 'center',
105
- fontSize:20,
106
- },
107
- modalText: {
108
- marginBottom: 15,
109
- textAlign: 'center',
110
- },
111
- });
112
-
113
- export default ImageViewerModal;