@messenger-box/platform-mobile 10.0.3-alpha.20 → 10.0.3-alpha.201

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 (112) hide show
  1. package/lib/components/messages-container-ui/BuildModeView.js +428 -0
  2. package/lib/components/messages-container-ui/BuildModeView.js.map +1 -0
  3. package/lib/components/messages-container-ui/MessagesContainerUI.js +55 -0
  4. package/lib/components/messages-container-ui/MessagesContainerUI.js.map +1 -0
  5. package/lib/components/messages-container-ui/PlanModeView.js +336 -0
  6. package/lib/components/messages-container-ui/PlanModeView.js.map +1 -0
  7. package/lib/compute.js +2 -3
  8. package/lib/compute.js.map +1 -1
  9. package/lib/index.js +1 -1
  10. package/lib/index.js.map +1 -1
  11. package/lib/module.js.map +1 -1
  12. package/lib/queries/inboxQueries.js +62 -0
  13. package/lib/queries/inboxQueries.js.map +1 -0
  14. package/lib/routes.json +2 -3
  15. package/lib/screens/inbox/DialogMessages.js +8 -3
  16. package/lib/screens/inbox/DialogMessages.js.map +1 -1
  17. package/lib/screens/inbox/DialogThreadMessages.js +6 -11
  18. package/lib/screens/inbox/DialogThreadMessages.js.map +1 -1
  19. package/lib/screens/inbox/DialogThreads.js +58 -20
  20. package/lib/screens/inbox/DialogThreads.js.map +1 -1
  21. package/lib/screens/inbox/Inbox.js.map +1 -1
  22. package/lib/screens/inbox/components/CachedImage/consts.js +1 -1
  23. package/lib/screens/inbox/components/CachedImage/consts.js.map +1 -1
  24. package/lib/screens/inbox/components/CachedImage/index.js +125 -115
  25. package/lib/screens/inbox/components/CachedImage/index.js.map +1 -1
  26. package/lib/screens/inbox/components/DialogItem.js +160 -0
  27. package/lib/screens/inbox/components/DialogItem.js.map +1 -0
  28. package/lib/screens/inbox/components/GiftedChatInboxComponent.js +315 -0
  29. package/lib/screens/inbox/components/GiftedChatInboxComponent.js.map +1 -0
  30. package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.js +3 -1
  31. package/lib/screens/inbox/components/SlackMessageContainer/ImageViewerModal.js.map +1 -1
  32. package/lib/screens/inbox/components/SlackMessageContainer/PaymentMessage.js +194 -0
  33. package/lib/screens/inbox/components/SlackMessageContainer/PaymentMessage.js.map +1 -0
  34. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js +149 -36
  35. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js.map +1 -1
  36. package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js +4 -5
  37. package/lib/screens/inbox/components/SlackMessageContainer/SlackMessage.js.map +1 -1
  38. package/lib/screens/inbox/components/SubscriptionHandler.js +22 -0
  39. package/lib/screens/inbox/components/SubscriptionHandler.js.map +1 -0
  40. package/lib/screens/inbox/components/ThreadsViewItem.js +67 -47
  41. package/lib/screens/inbox/components/ThreadsViewItem.js.map +1 -1
  42. package/lib/screens/inbox/config/config.js +4 -2
  43. package/lib/screens/inbox/config/config.js.map +1 -1
  44. package/lib/screens/inbox/containers/ConversationView.js +1099 -1094
  45. package/lib/screens/inbox/containers/ConversationView.js.map +1 -1
  46. package/lib/screens/inbox/containers/Dialogs.js +132 -534
  47. package/lib/screens/inbox/containers/Dialogs.js.map +1 -1
  48. package/lib/screens/inbox/containers/ThreadConversationView.js +876 -1357
  49. package/lib/screens/inbox/containers/ThreadConversationView.js.map +1 -1
  50. package/lib/screens/inbox/containers/ThreadsView.js +81 -54
  51. package/lib/screens/inbox/containers/ThreadsView.js.map +1 -1
  52. package/lib/screens/inbox/hooks/useInboxMessages.js +31 -0
  53. package/lib/screens/inbox/hooks/useInboxMessages.js.map +1 -0
  54. package/lib/screens/inbox/hooks/useSafeDialogThreadsMachine.js +108 -0
  55. package/lib/screens/inbox/hooks/useSafeDialogThreadsMachine.js.map +1 -0
  56. package/lib/screens/inbox/workflow/dialog-threads-xstate.js +151 -0
  57. package/lib/screens/inbox/workflow/dialog-threads-xstate.js.map +1 -0
  58. package/package.json +9 -7
  59. package/CHANGELOG.md +0 -164
  60. package/jest.config.js +0 -24
  61. package/lib/screens/inbox/components/DialogsListItem.js +0 -548
  62. package/lib/screens/inbox/components/DialogsListItem.js.map +0 -1
  63. package/lib/screens/inbox/components/ServiceDialogsListItem.js +0 -489
  64. package/lib/screens/inbox/components/ServiceDialogsListItem.js.map +0 -1
  65. package/lib/screens/inbox/components/workflow/dialogs-list-item-xstate.js +0 -175
  66. package/lib/screens/inbox/components/workflow/dialogs-list-item-xstate.js.map +0 -1
  67. package/lib/screens/inbox/components/workflow/service-dialogs-list-item-xstate.js +0 -191
  68. package/lib/screens/inbox/components/workflow/service-dialogs-list-item-xstate.js.map +0 -1
  69. package/lib/screens/inbox/containers/workflow/conversation-xstate.js +0 -380
  70. package/lib/screens/inbox/containers/workflow/conversation-xstate.js.map +0 -1
  71. package/lib/screens/inbox/containers/workflow/dialogs-xstate.js +0 -211
  72. package/lib/screens/inbox/containers/workflow/dialogs-xstate.js.map +0 -1
  73. package/lib/screens/inbox/containers/workflow/thread-conversation-xstate.js +0 -438
  74. package/lib/screens/inbox/containers/workflow/thread-conversation-xstate.js.map +0 -1
  75. package/rollup.config.mjs +0 -45
  76. package/src/components/index.ts +0 -0
  77. package/src/compute.ts +0 -63
  78. package/src/index.ts +0 -7
  79. package/src/module.ts +0 -10
  80. package/src/navigation/InboxNavigation.tsx +0 -102
  81. package/src/navigation/index.ts +0 -1
  82. package/src/screens/inbox/DialogMessages.tsx +0 -21
  83. package/src/screens/inbox/DialogThreadMessages.tsx +0 -97
  84. package/src/screens/inbox/DialogThreads.tsx +0 -129
  85. package/src/screens/inbox/Inbox.tsx +0 -17
  86. package/src/screens/inbox/components/CachedImage/consts.ts +0 -6
  87. package/src/screens/inbox/components/CachedImage/index.tsx +0 -223
  88. package/src/screens/inbox/components/DialogsHeader.tsx +0 -30
  89. package/src/screens/inbox/components/DialogsListItem.tsx +0 -819
  90. package/src/screens/inbox/components/ServiceDialogsListItem.tsx +0 -679
  91. package/src/screens/inbox/components/SlackMessageContainer/ImageViewerModal.tsx +0 -113
  92. package/src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx +0 -313
  93. package/src/screens/inbox/components/SlackMessageContainer/SlackMessage.tsx +0 -145
  94. package/src/screens/inbox/components/SlackMessageContainer/index.ts +0 -3
  95. package/src/screens/inbox/components/SupportServiceDialogsListItem.tsx +0 -301
  96. package/src/screens/inbox/components/ThreadsViewItem.tsx +0 -321
  97. package/src/screens/inbox/components/workflow/dialogs-list-item-xstate.ts +0 -145
  98. package/src/screens/inbox/components/workflow/service-dialogs-list-item-xstate.ts +0 -159
  99. package/src/screens/inbox/config/config.ts +0 -15
  100. package/src/screens/inbox/config/index.ts +0 -1
  101. package/src/screens/inbox/containers/ConversationView.tsx +0 -1782
  102. package/src/screens/inbox/containers/Dialogs.tsx +0 -794
  103. package/src/screens/inbox/containers/SupportServiceDialogs.tsx +0 -119
  104. package/src/screens/inbox/containers/ThreadConversationView.tsx +0 -2312
  105. package/src/screens/inbox/containers/ThreadsView.tsx +0 -305
  106. package/src/screens/inbox/containers/workflow/apollo/handleResult.ts +0 -20
  107. package/src/screens/inbox/containers/workflow/conversation-xstate.ts +0 -313
  108. package/src/screens/inbox/containers/workflow/dialogs-xstate.ts +0 -196
  109. package/src/screens/inbox/containers/workflow/thread-conversation-xstate.ts +0 -401
  110. package/src/screens/index.ts +0 -4
  111. package/tsconfig.json +0 -13
  112. package/webpack.config.js +0 -58
@@ -1,301 +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
- useThreadMessagesQuery,
20
- useMessagesQuery,
21
- useUserAccountQuery,
22
- useOnThreadCreatedUpdatedSubscription,
23
- useOnThreadChatMessageAddedSubscription,
24
- OnThreadCreatedUpdatedDocument as THREAD_CHAT_ADDED,
25
- OnThreadChatMessageAddedDocument as CHAT_MESSAGE_ADDED,
26
- } from 'common/graphql';
27
- import { startCase } from 'lodash-es';
28
- import colors from 'tailwindcss/colors';
29
-
30
- const createdAtText = (value: string) => {
31
- if (!value) return '';
32
-
33
- try {
34
- // Validate the date before processing
35
- const timestamp = new Date(value).getTime();
36
- if (isNaN(timestamp)) {
37
- console.warn(`Invalid date value in createdAtText: ${value}`);
38
- return 'Unknown date';
39
- }
40
-
41
- let date = new Date(value);
42
- if (isToday(date)) return 'Today';
43
- if (isYesterday(date)) return 'Yesterday';
44
- return format(date, 'MMM dd, yyyy');
45
- } catch (error) {
46
- console.error(`Error processing date in createdAtText: ${value}`, error);
47
- return 'Unknown date';
48
- }
49
- };
50
-
51
- export interface IDialogListChannel extends IChannel {
52
- users: IUserAccount[];
53
- }
54
-
55
- export interface IDialogListItemProps {
56
- currentUser?: any;
57
- users?: any;
58
- selectedChannelId?: any;
59
- channel?: any;
60
- onOpen: (id: any, title: any, postParentId?: any) => void;
61
- refreshing: boolean;
62
- role: any;
63
- }
64
-
65
- /**
66
- * TODO:
67
- * - Get Reservation info: reservation date, status
68
- * - Add ability to get property information: name, logo
69
- */
70
- export const SupportServiceDialogsListItemComponent: React.FC<IDialogListItemProps> = function DialogsListItem({
71
- currentUser,
72
- // users,
73
- selectedChannelId,
74
- channel,
75
- onOpen,
76
- refreshing,
77
- role,
78
- }) {
79
- const [servicePostParentId, setServicePostParentId] = React.useState(null);
80
- const {
81
- data: threadMessages,
82
- loading: threadMessageLoading,
83
- error,
84
- refetch: refetchThreadMessages,
85
- subscribeToMore,
86
- } = useThreadMessagesQuery({
87
- variables: {
88
- channelId: channel?.id?.toString(),
89
- role,
90
- limit: 2,
91
- },
92
- fetchPolicy: 'cache-and-network',
93
- });
94
-
95
- useFocusEffect(
96
- React.useCallback(() => {
97
- // Do something when the screen is focused
98
- // refetchMessages({ channelId: channel?.id?.toString(), limit: 25 });
99
- refetchThreadMessages({ channelId: channel?.id?.toString(), role, limit: 2 });
100
- return () => {
101
- // Do something when the screen is unfocused
102
- // Useful for cleanup functions
103
- };
104
- }, [refreshing]),
105
- );
106
-
107
- const lastMessage = useMemo(() => {
108
- if (!threadMessages?.threadMessages?.data?.length) {
109
- return null;
110
- }
111
- const { data }: any = threadMessages.threadMessages;
112
- const replies =
113
- data
114
- ?.map((t: any) => t?.replies)
115
- ?.flat(1)
116
- ?.filter((p: any) => p?.message !== '') ?? [];
117
- if (replies?.length) {
118
- return replies[0];
119
- // return replies[replies.length - 1];
120
- } else {
121
- const post =
122
- data?.find((t: any) => {
123
- return t?.post?.message !== '';
124
- }) ??
125
- data?.find((t: any) => {
126
- return t?.post;
127
- }) ??
128
- null;
129
- return post ? post?.post : null;
130
- }
131
- }, [threadMessages]);
132
-
133
- React.useEffect(() => {
134
- if (lastMessage) {
135
- const sParentId = lastMessage?.parentId ? lastMessage?.parentId : lastMessage?.id;
136
- setServicePostParentId(sParentId);
137
- }
138
- }, [lastMessage]);
139
-
140
- const creatorAndMembersId = React.useMemo(() => {
141
- if (!channel?.members) return null;
142
- const membersIds: any =
143
- channel?.members
144
- ?.filter((m: any) => m !== null && m?.user?.id !== currentUser?.id)
145
- ?.map((mu: any) => mu?.user?.id) ?? [];
146
- const creatorId: any = channel?.creator?.id;
147
- const mergedIds: any = [].concat(membersIds, creatorId) ?? [];
148
- return mergedIds?.filter((m: any, pos: any) => mergedIds?.indexOf(m) === pos) ?? [];
149
- }, [channel]);
150
-
151
- const postParentId = React.useMemo(() => {
152
- if (!creatorAndMembersId?.length) return null;
153
-
154
- return creatorAndMembersId?.length && creatorAndMembersId?.includes(currentUser?.id)
155
- ? null
156
- : lastMessage?.parentId
157
- ? lastMessage?.parentId
158
- : lastMessage?.id ?? 0;
159
- }, [creatorAndMembersId, lastMessage]);
160
-
161
- // const { data: threadCreatedUpdated } = useOnThreadCreatedUpdatedSubscription({
162
- // variables: {
163
- // channelId: channel?.id?.toString(),
164
- // postParentId:
165
- // postParentId == null
166
- // ? null
167
- // : lastMessage?.parentId
168
- // ? lastMessage?.parentId ?? null
169
- // : lastMessage?.id ?? null,
170
- // },
171
- // });
172
-
173
- // React.useEffect(() => {
174
- // if (threadCreatedUpdated?.threadCreatedUpdated?.data) {
175
- // refetchThreadMessages({ channelId: channel?.id?.toString(), role, limit: 2 });
176
- // }
177
- // }, [threadCreatedUpdated]);
178
-
179
- return (
180
- <Pressable
181
- onPress={() => channel?.id !== selectedChannelId && onOpen(channel?.id, channel?.title, postParentId)}
182
- className="flex-1 border rounded-md border-gray-200 dark:border-gray-600 dark:bg-gray-700"
183
- >
184
- <HStack space={'sm'} className="flex-1 w-[100%] py-3 justify-between items-center">
185
- <Box className="flex-[0.1] items-start pl-3">
186
- <Avatar
187
- key={'support-service-channels-key-' + channel?.id}
188
- size={'sm'}
189
- className="bg-transparent top-0 right-0 z-[1]"
190
- >
191
- <AvatarFallbackText> {startCase(channel?.creator?.username?.charAt(0))}</AvatarFallbackText>
192
- <AvatarImage
193
- alt="user image"
194
- style={{ borderRadius: 6, borderWidth: 2, borderColor: '#fff' }}
195
- source={{
196
- uri: channel?.creator?.picture,
197
- }}
198
- />
199
- </Avatar>
200
- </Box>
201
- <Box className="flex-[0.9]">
202
- <ServiceChannelWithLastMessage
203
- channel={channel}
204
- lastMessage={lastMessage}
205
- subscribeToNewMessages={() =>
206
- subscribeToMore({
207
- document: THREAD_CHAT_ADDED,
208
- variables: {
209
- channelId: channel?.id?.toString(),
210
- postParentId: postParentId ? servicePostParentId : null,
211
- },
212
- updateQuery: (prev, { subscriptionData }: any) => {
213
- if (!subscriptionData.data) return prev;
214
-
215
- const newPostThreadData: any = subscriptionData?.data?.threadCreatedUpdated?.data;
216
- const newMessage: any = subscriptionData?.data?.threadCreatedUpdated?.lastMessage;
217
- const data = prev?.threadMessages?.data?.map((t: any) =>
218
- t.id === newPostThreadData?.id
219
- ? {
220
- ...t,
221
- replies: [...t?.replies, newMessage],
222
- replyCount: newPostThreadData?.replyCount,
223
- lastReplyAt: newPostThreadData?.lastReplyAt,
224
- updatedAt: newPostThreadData?.updatedAt,
225
- }
226
- : t,
227
- );
228
-
229
- return Object.assign({}, prev, {
230
- threadMessages: {
231
- ...prev?.threadMessages,
232
- // totalCount: prev?.threadMessages?.totalCount + 1,
233
- data: data,
234
- },
235
- });
236
- },
237
- })
238
- }
239
- />
240
- {/* <Text
241
- flex={1}
242
- color="gray.600"
243
- p={0}
244
- m={0}
245
- w={'100%'}
246
- justifyContent={''}
247
- fontSize="lg"
248
- fontWeight="semibold"
249
- >
250
- {title}
251
- </Text> */}
252
- {/* <Text flex={0.1} color="gray.600">
253
- {lastMessage?.message ?? ''}
254
- </Text> */}
255
- </Box>
256
- {/* <Text flex={0.2} color="gray.500">
257
- {lastMessage ? createdAtText(lastMessage?.createdAt) : ''}
258
- </Text> */}
259
- </HStack>
260
- </Pressable>
261
- );
262
- };
263
-
264
- const ServiceChannelWithLastMessage = React.memo(({ channel, lastMessage, subscribeToNewMessages }: any) => {
265
- React.useEffect(() => subscribeToNewMessages(), []);
266
-
267
- // Define message display text
268
- let displayMessage = 'No messages yet';
269
-
270
- if (lastMessage) {
271
- // Check for file attachments
272
- const hasFileAttachments = lastMessage.files?.data?.length > 0;
273
-
274
- if (hasFileAttachments) {
275
- displayMessage = '📎 File attachment';
276
- } else if (lastMessage.message && lastMessage.message.trim() !== '') {
277
- displayMessage = lastMessage.message;
278
- } else {
279
- displayMessage = '(Empty message)';
280
- }
281
- }
282
-
283
- return (
284
- <HStack space={'sm'} className="flex-1 justify-center items-center">
285
- <Box className="flex-[0.8]">
286
- <Text color={colors.gray[600]} className="text-lg flex-wrap font-semibold">
287
- {channel?.title}
288
- </Text>
289
- <Text color={colors.gray[600]} numberOfLines={1}>
290
- {displayMessage}
291
- </Text>
292
- </Box>
293
-
294
- <Box className="flex-[0.2]">
295
- <Text color={colors.gray[500]}>{lastMessage ? createdAtText(lastMessage?.createdAt) : ''}</Text>
296
- </Box>
297
- </HStack>
298
- );
299
- });
300
-
301
- export const SupportServiceDialogsListItem = React.memo(SupportServiceDialogsListItemComponent);
@@ -1,321 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import {
3
- VStack,
4
- Text,
5
- Image,
6
- Pressable,
7
- HStack,
8
- Box,
9
- AvatarGroup,
10
- Avatar,
11
- AvatarFallbackText,
12
- AvatarImage,
13
- AvatarBadge,
14
- View,
15
- Button,
16
- ButtonText,
17
- } from '@admin-layout/gluestack-ui-mobile';
18
- import { format, isToday, isYesterday } from 'date-fns';
19
- import { useFocusEffect } from '@react-navigation/native';
20
- import { IChannel, IUserAccount } from 'common';
21
- import {
22
- useThreadMessagesQuery,
23
- useMessagesQuery,
24
- useUserAccountQuery,
25
- useOnThreadChatMessageAddedSubscription,
26
- useOnThreadCreatedUpdatedSubscription,
27
- } from 'common/graphql';
28
- import { startCase } from 'lodash-es';
29
- import colors from 'tailwindcss/colors';
30
-
31
- const createdAtText = (value: string) => {
32
- if (!value) return '';
33
- let date = new Date(value);
34
- if (isToday(date)) return 'Today';
35
- if (isYesterday(date)) return 'Yesterday';
36
- return format(new Date(value), 'MMM dd, yyyy');
37
- };
38
-
39
- export interface IDialogListChannel extends IChannel {
40
- users: IUserAccount[];
41
- }
42
-
43
- export interface IDialogListItemProps {
44
- currentUser?: any;
45
- users?: any;
46
- thread?: any;
47
- onOpen: (id: any, title: any, postParentId?: any) => void;
48
- role?: any;
49
- setData?: any;
50
- }
51
-
52
- /**
53
- * TODO:
54
- * - Get Reservation info: reservation date, status
55
- * - Add ability to get property information: name, logo
56
- */
57
- export const ThreadViewItemComponent: React.FC<IDialogListItemProps> = function DialogsListItem({
58
- currentUser,
59
- // users,
60
- thread,
61
- onOpen,
62
- role,
63
- setData,
64
- }) {
65
- // const { data: threadCreatedUpdated } = useOnThreadCreatedUpdatedSubscription({
66
- // variables: {
67
- // channelId: thread?.channel?.id?.toString(),
68
- // postParentId: thread?.post?.id?.toString(),
69
- // },
70
- // });
71
-
72
- useFocusEffect(
73
- React.useCallback(() => {
74
- // Do something when the screen is focused
75
- return () => {
76
- // Do something when the screen is unfocused
77
- // Useful for cleanup functions
78
- };
79
- }, []),
80
- );
81
-
82
- const threadPostReply = React.useMemo(() => {
83
- if (!thread?.replies) return null;
84
- return thread?.replies;
85
- }, [thread]);
86
-
87
- // React.useEffect(() => {
88
- // if (threadCreatedUpdated?.threadCreatedUpdated?.data) setData(threadCreatedUpdated?.threadCreatedUpdated?.data);
89
- // }, [threadCreatedUpdated?.threadCreatedUpdated]);
90
-
91
- // const threadPostReply = React.useMemo(() => {
92
- // if (!thread?.replies) return null;
93
- // if (threadCreatedUpdated?.threadCreatedUpdated?.data?.replies?.length) {
94
- // return threadCreatedUpdated?.threadCreatedUpdated?.data?.replies;
95
- // } else return thread?.replies;
96
- // }, [thread, threadCreatedUpdated]);
97
-
98
- // const lastMessage = useMemo(() => {
99
- // if (!threadPost) {
100
- // return null;
101
- // }
102
- // const replies = threadPost?.replies?.filter((p: any) => p?.message !== '') ?? [];
103
- // if (replies?.length) {
104
- // return replies[0];
105
- // // return replies[replies.length - 1];
106
- // } else {
107
- // const post = threadPost?.post ?? null;
108
- // return post ? post?.post : null;
109
- // }
110
- // }, [threadPost]);
111
-
112
- // const participants: any = React.useMemo(() => {
113
- // if (!thread?.participants?.length) return null;
114
- // return thread?.participants?.filter((u: any) => u?.user?.id !== currentUser?.id) ?? [];
115
- // }, [thread]);
116
-
117
- // const allParticipantsNames: any = React.useMemo(() => {
118
- // if (!participants?.length) return null;
119
- // return (
120
- // participants
121
- // ?.map((p: any) => {
122
- // return p?.user?.givenName + ' ' + p?.user?.familyName ?? '';
123
- // })
124
- // ?.join(', ') ?? ''
125
- // );
126
- // }, [participants]);
127
-
128
- if (!threadPostReply || threadPostReply?.length == 0) {
129
- return <></>;
130
- }
131
-
132
- return (
133
- <VStack
134
- space={'sm'}
135
- className="flex-1 py-2 px-2 border rounded-md bg-white border-gray-200 dark:border-white dark:bg-white"
136
- >
137
- <HStack space={'sm'} className="py-2 w-[100%] flex-1 justify-between items-center">
138
- <Box className="flex-1">
139
- {/* <HStack flex={1} space={5} py={2} alignItems={'baseline'}>
140
- <Box>
141
- <Avatar.Badge size={4} left={0} zIndex={1} bg="green.800" />
142
- </Box>
143
- <Box>
144
- <Text color="gray.600" fontSize="lg" flexWrap={'wrap'} fontWeight="semibold">
145
- {allParticipantsNames || ''}
146
- </Text>
147
- </Box>
148
- </HStack> */}
149
- <HStack space={'sm'} className="flex-1 justify-center items-center">
150
- <Box className="flex-1">
151
- {/* <HStack space={2} py={2}>
152
- <Box>
153
- <Avatar
154
- bg={'transparent'}
155
- size={8}
156
- _image={{ borderRadius: 6, borderWidth: 2, borderColor: '#fff' }}
157
- source={{
158
- uri: thread?.post?.author?.picture,
159
- }}
160
- >
161
- {startCase(thread?.post?.author?.username?.charAt(0))}
162
- </Avatar>
163
- </Box>
164
- <Box>
165
- <HStack space={4}>
166
- <Text>
167
- {thread?.post?.author?.givenName + ' ' + thread?.post?.author?.familyName ??
168
- ''}
169
- </Text>
170
- <Text color="gray.500">
171
- {thread?.post ? createdAtText(thread?.post?.createdAt) : ''}
172
- </Text>
173
- </HStack>
174
- <Text color="gray.600" noOfLines={2}>
175
- {thread?.post?.message ?? ''}
176
- </Text>
177
- {!thread?.replies?.length && (
178
- <Button
179
- size={'xs'}
180
- w={150}
181
- variant={'outline'}
182
- _text={{ fontSize: 12, color: '#000' }}
183
- onPress={() =>
184
- onOpen(thread?.channel?.id, thread?.channel?.title, thread?.post?.id)
185
- }
186
- >
187
- Reply
188
- </Button>
189
- )}
190
- </Box>
191
- </HStack> */}
192
- {threadPostReply?.length > 0 && (
193
- <>
194
- {threadPostReply
195
- ?.slice(0, 2)
196
- ?.reverse()
197
- ?.map((reply: any, index: any) => (
198
- <HStack key={index} space={'sm'} className="pb-2 pt-1">
199
- <Box>
200
- <Avatar
201
- key={'thread-view-key-' + index}
202
- size={'md'}
203
- className="bg-transparent top-0 right-0 z-[1]"
204
- >
205
- <AvatarFallbackText>
206
- {' '}
207
- {startCase(reply?.author?.username?.charAt(0))}
208
- </AvatarFallbackText>
209
- <AvatarImage
210
- alt="image"
211
- style={{
212
- borderRadius: 6,
213
- borderWidth: 2,
214
- borderColor: '#fff',
215
- }}
216
- source={{
217
- uri: reply?.author?.picture,
218
- }}
219
- />
220
- </Avatar>
221
- </Box>
222
- <Box>
223
- <HStack space={'md'}>
224
- <Text>
225
- {reply?.author?.givenName ?? '' ?? ''}{' '}
226
- {reply?.author?.familyName ?? '' ?? ''}
227
- {/* {lastMessage?.author?.givenName +
228
- ' ' +
229
- lastMessage?.author?.familyName ?? ''} */}
230
- </Text>
231
- <Text color={colors.gray[500]}>
232
- {reply?.createdAt ? createdAtText(reply?.createdAt) : ''}
233
- {/* {lastMessage ? createdAtText(lastMessage?.createdAt) : ''} */}
234
- </Text>
235
- </HStack>
236
- <VStack space={'sm'}>
237
- {reply?.message && (
238
- <Text color={colors.gray[600]} numberOfLines={2}>
239
- {reply?.message.length < 70
240
- ? `${reply?.message}`
241
- : `${reply?.message.substring(0, 68)}....`}
242
- </Text>
243
- )}
244
- {/* <Text color="gray.600" noOfLines={2}>
245
- {reply?.message
246
- ? reply?.message.length < 70
247
- ? `${reply?.message}`
248
- : `${reply?.message.substring(0, 68)}....`
249
- : ''}
250
- </Text> */}
251
-
252
- <>
253
- {reply?.files?.data?.length > 0 &&
254
- reply?.files?.data?.map((f: any, index: any) => (
255
- <Box>
256
- <Avatar
257
- key={'thread-view-other-key-' + index}
258
- className="bg-transparent"
259
- size={'md'}
260
- >
261
- <AvatarFallbackText> I</AvatarFallbackText>
262
- <AvatarImage
263
- alt="image"
264
- style={{
265
- borderRadius: 6,
266
- borderWidth: 2,
267
- borderColor: '#fff',
268
- }}
269
- source={{
270
- uri: f?.url,
271
- }}
272
- />
273
- </Avatar>
274
- </Box>
275
- ))}
276
- </>
277
- </VStack>
278
-
279
- {(threadPostReply?.length == 1 || index !== 0) && (
280
- <Button
281
- size={'xs'}
282
- className="w-[150]"
283
- variant={'outline'}
284
- onPress={() =>
285
- onOpen(
286
- thread?.channel?.id,
287
- thread?.channel?.title,
288
- thread?.post?.id,
289
- )
290
- }
291
- >
292
- <ButtonText style={{ fontSize: 12, color: '#000' }}>
293
- Reply
294
- </ButtonText>
295
- </Button>
296
- )}
297
- </Box>
298
- </HStack>
299
- ))}
300
- </>
301
- )}
302
- </Box>
303
- </HStack>
304
- </Box>
305
- </HStack>
306
- {/* <HStack>
307
- <Box flex={0.06} alignItems={'flex-start'}></Box>
308
- <Button
309
- size={'xs'}
310
- variant={'outline'}
311
- _text={{ fontSize: 12, color: '#000' }}
312
- onPress={() => onOpen(thread?.channel?.id, thread?.channel?.title, postParentId)}
313
- >
314
- Reply
315
- </Button>
316
- </HStack> */}
317
- </VStack>
318
- );
319
- };
320
-
321
- export const ThreadViewItem = React.memo(ThreadViewItemComponent);