@messenger-box/platform-mobile 10.0.3-alpha.40 → 10.0.3-alpha.46

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 (54) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/compute.js +2 -3
  3. package/lib/index.js.map +1 -1
  4. package/lib/queries/inboxQueries.js +77 -0
  5. package/lib/queries/inboxQueries.js.map +1 -0
  6. package/lib/routes.json +2 -3
  7. package/lib/screens/inbox/DialogThreadMessages.js +3 -7
  8. package/lib/screens/inbox/DialogThreadMessages.js.map +1 -1
  9. package/lib/screens/inbox/DialogThreads.js +3 -7
  10. package/lib/screens/inbox/DialogThreads.js.map +1 -1
  11. package/lib/screens/inbox/components/DialogsListItem.js +47 -46
  12. package/lib/screens/inbox/components/DialogsListItem.js.map +1 -1
  13. package/lib/screens/inbox/components/GiftedChatInboxComponent.js +313 -0
  14. package/lib/screens/inbox/components/GiftedChatInboxComponent.js.map +1 -0
  15. package/lib/screens/inbox/components/ServiceDialogsListItem.js +72 -57
  16. package/lib/screens/inbox/components/ServiceDialogsListItem.js.map +1 -1
  17. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js +115 -14
  18. package/lib/screens/inbox/components/SlackMessageContainer/SlackBubble.js.map +1 -1
  19. package/lib/screens/inbox/components/SubscriptionHandler.js +24 -0
  20. package/lib/screens/inbox/components/SubscriptionHandler.js.map +1 -0
  21. package/lib/screens/inbox/containers/ConversationView.js +640 -493
  22. package/lib/screens/inbox/containers/ConversationView.js.map +1 -1
  23. package/lib/screens/inbox/containers/Dialogs.js +100 -181
  24. package/lib/screens/inbox/containers/Dialogs.js.map +1 -1
  25. package/lib/screens/inbox/containers/ThreadConversationView.js +659 -245
  26. package/lib/screens/inbox/containers/ThreadConversationView.js.map +1 -1
  27. package/lib/screens/inbox/containers/ThreadsView.js +3 -3
  28. package/lib/screens/inbox/containers/ThreadsView.js.map +1 -1
  29. package/lib/screens/inbox/hooks/useInboxMessages.js +31 -0
  30. package/lib/screens/inbox/hooks/useInboxMessages.js.map +1 -0
  31. package/package.json +4 -4
  32. package/src/index.ts +2 -0
  33. package/src/queries/inboxQueries.ts +298 -0
  34. package/src/queries/index.d.ts +2 -0
  35. package/src/queries/index.ts +1 -0
  36. package/src/screens/inbox/DialogThreadMessages.tsx +3 -11
  37. package/src/screens/inbox/DialogThreads.tsx +3 -7
  38. package/src/screens/inbox/components/Actionsheet.tsx +30 -0
  39. package/src/screens/inbox/components/DialogsListItem.tsx +89 -148
  40. package/src/screens/inbox/components/ExpandableInput.tsx +460 -0
  41. package/src/screens/inbox/components/ExpandableInputActionSheet.tsx +518 -0
  42. package/src/screens/inbox/components/GiftedChatInboxComponent.tsx +411 -0
  43. package/src/screens/inbox/components/ServiceDialogsListItem.tsx +202 -221
  44. package/src/screens/inbox/components/SlackInput.tsx +23 -0
  45. package/src/screens/inbox/components/SlackMessageContainer/SlackBubble.tsx +216 -30
  46. package/src/screens/inbox/components/SubscriptionHandler.tsx +41 -0
  47. package/src/screens/inbox/components/SupportServiceDialogsListItem.tsx +6 -7
  48. package/src/screens/inbox/containers/ConversationView.tsx +1109 -669
  49. package/src/screens/inbox/containers/Dialogs.tsx +198 -342
  50. package/src/screens/inbox/containers/SupportServiceDialogs.tsx +2 -2
  51. package/src/screens/inbox/containers/ThreadConversationView.tsx +1141 -402
  52. package/src/screens/inbox/containers/ThreadsView.tsx +5 -5
  53. package/src/screens/inbox/hooks/useInboxMessages.ts +34 -0
  54. package/src/screens/inbox/machines/threadsMachine.ts +2 -2
@@ -16,14 +16,15 @@ import { format, isToday, isYesterday } from 'date-fns';
16
16
  import { useFocusEffect } from '@react-navigation/native';
17
17
  import { IChannel, IUserAccount } from 'common';
18
18
  import {
19
- useOnThreadCreatedUpdatedSubscription,
20
- useOnThreadChatMessageAddedSubscription,
19
+ THREAD_CREATED_UPDATED,
20
+ CHAT_MESSAGE_ADDED,
21
21
  useThreadMessagesQuery,
22
- OnThreadCreatedUpdatedDocument as THREAD_CHAT_ADDED,
23
- OnThreadChatMessageAddedDocument as CHAT_MESSAGE_ADDED,
24
- } from 'common/graphql';
22
+ useThreadCreatedUpdatedSubscription,
23
+ useThreadChatMessageAddedSubscription,
24
+ } from '../../../queries/inboxQueries';
25
25
  import { startCase } from 'lodash-es';
26
26
  import colors from 'tailwindcss/colors';
27
+ import { SubscriptionHandler } from './SubscriptionHandler';
27
28
 
28
29
  // Helper function to safely create a Date object
29
30
  const safeDate = (dateValue) => {
@@ -65,6 +66,7 @@ export interface IDialogListItemProps {
65
66
  onOpen: (id: any, title: any, postParentId?: any) => void;
66
67
  refreshing: boolean;
67
68
  role: any;
69
+ visible?: boolean;
68
70
  }
69
71
 
70
72
  // Helper function to compute the last message from a list of messages
@@ -121,7 +123,23 @@ const computeLastMessage = (threadMessages) => {
121
123
  };
122
124
 
123
125
  const ServiceChannelWithLastMessage = React.memo(
124
- ({ channel, lastMessage, subscribeToNewMessages, subscribeToChatMessages }: any) => {
126
+ ({
127
+ channel,
128
+ lastMessage,
129
+ subscribeToNewMessages,
130
+ subscribeToChatMessages,
131
+ subscribeToMore,
132
+ postParentId,
133
+ servicePostParentId,
134
+ }: {
135
+ channel: any;
136
+ lastMessage: any;
137
+ subscribeToNewMessages: () => void;
138
+ subscribeToChatMessages: () => void;
139
+ subscribeToMore: any;
140
+ postParentId: any;
141
+ servicePostParentId: any;
142
+ }) => {
125
143
  React.useEffect(() => {
126
144
  console.log(`Setting up subscriptions for channel ${channel?.id}`);
127
145
  // Subscribe and store the unsubscribe functions
@@ -197,20 +215,40 @@ const ServiceChannelWithLastMessage = React.memo(
197
215
  }
198
216
 
199
217
  return (
200
- <HStack space={'sm'} className="flex-1 justify-between">
201
- <Box className="flex-[0.8]">
202
- <Text color={colors.gray[600]} className="text-base text-wrap flex-wrap font-semibold">
203
- {title}
204
- </Text>
205
- <Text color={colors.gray[600]} numberOfLines={1}>
206
- {displayMessage}
207
- </Text>
208
- </Box>
209
-
210
- <Box className="flex-[0.2]">
211
- <Text color={colors.gray[500]}>{lastMessage ? createdAtText(lastMessage?.createdAt) : ''}</Text>
212
- </Box>
213
- </HStack>
218
+ <>
219
+ <SubscriptionHandler
220
+ subscribeToMore={subscribeToMore}
221
+ document={THREAD_CREATED_UPDATED}
222
+ variables={{
223
+ channelId: channel?.id?.toString(),
224
+ postParentId: postParentId || servicePostParentId || null,
225
+ }}
226
+ updateQuery={undefined} // Provide custom updateQuery if needed
227
+ />
228
+ <SubscriptionHandler
229
+ subscribeToMore={subscribeToMore}
230
+ document={CHAT_MESSAGE_ADDED}
231
+ variables={{
232
+ channelId: channel?.id?.toString(),
233
+ postParentId: postParentId || servicePostParentId || null,
234
+ }}
235
+ updateQuery={undefined} // Provide custom updateQuery if needed
236
+ />
237
+ <HStack space={'sm'} className="flex-1 justify-between">
238
+ <Box className="flex-[0.8]">
239
+ <Text color={colors.gray[600]} className="text-base text-wrap flex-wrap font-semibold">
240
+ {title}
241
+ </Text>
242
+ <Text color={colors.gray[600]} numberOfLines={1}>
243
+ {displayMessage}
244
+ </Text>
245
+ </Box>
246
+
247
+ <Box className="flex-[0.2]">
248
+ <Text color={colors.gray[500]}>{lastMessage ? createdAtText(lastMessage?.createdAt) : ''}</Text>
249
+ </Box>
250
+ </HStack>
251
+ </>
214
252
  );
215
253
  },
216
254
  );
@@ -228,12 +266,15 @@ export const ServiceDialogsListItemComponent: React.FC<IDialogListItemProps> = f
228
266
  onOpen,
229
267
  refreshing,
230
268
  role,
269
+ visible = true,
231
270
  }) {
232
- // Create a ref to track if component is mounted
233
271
  const isMountedRef = useRef(true);
234
272
  const [subscriptionsTimestamp, setSubscriptionsTimestamp] = useState(Date.now());
235
273
 
236
- // Query for thread messages
274
+ // Only run queries/subscriptions if visible
275
+ const shouldQuery = !!channel?.id && visible;
276
+
277
+ // Query for thread messages (minimal fields if possible)
237
278
  const {
238
279
  data: threadMessagesData,
239
280
  loading: threadMessageLoading,
@@ -246,31 +287,31 @@ export const ServiceDialogsListItemComponent: React.FC<IDialogListItemProps> = f
246
287
  role,
247
288
  limit: 2,
248
289
  },
290
+ skip: !shouldQuery, // Only run if visible
249
291
  fetchPolicy: 'cache-and-network',
250
292
  onCompleted: (data) => {
251
- console.log(
252
- `Completed thread messages query for channel ${channel?.id}:`,
253
- data?.threadMessages?.data?.length ? 'Has messages' : 'No messages',
254
- );
293
+ if (!shouldQuery) return;
255
294
  },
256
295
  onError: (error) => {
296
+ if (!shouldQuery) return;
257
297
  console.error(`Error fetching thread messages for channel ${channel?.id}:`, error);
258
298
  },
259
299
  });
260
300
 
261
301
  // Extract threadMessages data for easier access
262
- const threadMessages = threadMessagesData?.threadMessages?.data || [];
302
+ const threadMessages = useMemo(() => threadMessagesData?.threadMessages?.data || [], [threadMessagesData]);
263
303
 
264
304
  // Calculate lastMessage directly from threadMessages
265
305
  const lastMessage = useMemo(() => {
306
+ if (!shouldQuery) return null;
266
307
  return computeLastMessage(threadMessages);
267
- }, [threadMessages]);
308
+ }, [shouldQuery, threadMessages]);
268
309
 
269
310
  // Calculate servicePostParentId based on lastMessage
270
311
  const servicePostParentId = useMemo(() => {
271
- if (!lastMessage) return null;
312
+ if (!shouldQuery || !lastMessage) return null;
272
313
  return lastMessage?.parentId ? lastMessage?.parentId : lastMessage?.id;
273
- }, [lastMessage]);
314
+ }, [shouldQuery, lastMessage]);
274
315
 
275
316
  // Handle component unmount
276
317
  React.useEffect(() => {
@@ -280,7 +321,7 @@ export const ServiceDialogsListItemComponent: React.FC<IDialogListItemProps> = f
280
321
  }, []);
281
322
 
282
323
  const creatorAndMembersId = useMemo(() => {
283
- if (!channel?.members) return null;
324
+ if (!shouldQuery || !channel?.members) return null;
284
325
  const membersIds: any =
285
326
  channel?.members
286
327
  ?.filter((m: any) => m !== null && m?.user?.id !== currentUser?.id)
@@ -288,24 +329,20 @@ export const ServiceDialogsListItemComponent: React.FC<IDialogListItemProps> = f
288
329
  const creatorId: any = channel?.creator?.id;
289
330
  const mergedIds: any = [].concat(membersIds, creatorId) ?? [];
290
331
  return mergedIds?.filter((m: any, pos: any) => mergedIds?.indexOf(m) === pos) ?? [];
291
- }, [channel, currentUser]);
332
+ }, [shouldQuery, channel, currentUser]);
292
333
 
293
334
  const postParentId = useMemo(() => {
294
- if (!creatorAndMembersId?.length) return null;
295
-
335
+ if (!shouldQuery || !creatorAndMembersId?.length) return null;
296
336
  return creatorAndMembersId?.length && creatorAndMembersId?.includes(currentUser?.id)
297
337
  ? null
298
338
  : lastMessage?.parentId
299
339
  ? lastMessage?.parentId
300
340
  : lastMessage?.id ?? 0;
301
- }, [creatorAndMembersId, lastMessage, currentUser]);
341
+ }, [shouldQuery, creatorAndMembersId, lastMessage, currentUser]);
302
342
 
303
343
  // Function to force refresh the component state
304
344
  const refreshThreadState = useCallback(() => {
305
- if (channel?.id && isMountedRef.current) {
306
- console.log('Forcing thread state refresh for channel:', channel?.id);
307
-
308
- // Refetch messages from server
345
+ if (shouldQuery && channel?.id && isMountedRef.current) {
309
346
  refetchThreadMessages({
310
347
  channelId: channel?.id?.toString(),
311
348
  role,
@@ -314,23 +351,15 @@ export const ServiceDialogsListItemComponent: React.FC<IDialogListItemProps> = f
314
351
  console.error('Error refreshing thread state:', err);
315
352
  });
316
353
  }
317
- }, [channel?.id, refetchThreadMessages, isMountedRef, role]);
354
+ }, [shouldQuery, channel?.id, refetchThreadMessages, role]);
318
355
 
319
356
  // Reset subscriptions when the component gains focus
320
357
  useFocusEffect(
321
358
  React.useCallback(() => {
322
- // Force subscription refresh
359
+ if (!shouldQuery || !channel?.id) return;
323
360
  setSubscriptionsTimestamp(Date.now());
324
-
325
- // Existing focus effect logic...
326
- if (!channel?.id) return;
327
-
328
- console.log('ServiceDialogsListItem focused for channel:', channel?.id);
329
-
330
- // Use a direct refetch with network-only policy to force fresh data
331
361
  const fetchFreshData = async () => {
332
362
  try {
333
- // Force a network-only fetch
334
363
  await refetchThreadMessages({
335
364
  channelId: channel?.id?.toString(),
336
365
  role,
@@ -340,14 +369,9 @@ export const ServiceDialogsListItemComponent: React.FC<IDialogListItemProps> = f
340
369
  console.error('Error refetching thread messages on focus:', error);
341
370
  }
342
371
  };
343
-
344
- // Execute fetch
345
372
  fetchFreshData();
346
-
347
- return () => {
348
- // Cleanup function when unfocused
349
- };
350
- }, [refreshing, channel?.id, refetchThreadMessages, role]),
373
+ return () => {};
374
+ }, [shouldQuery, refreshing, channel?.id, refetchThreadMessages, role]),
351
375
  );
352
376
 
353
377
  return (
@@ -380,174 +404,131 @@ export const ServiceDialogsListItemComponent: React.FC<IDialogListItemProps> = f
380
404
  channel={channel}
381
405
  lastMessage={lastMessage}
382
406
  subscribeToNewMessages={() =>
383
- subscribeToMore({
384
- document: THREAD_CHAT_ADDED,
385
- variables: {
386
- channelId: channel?.id?.toString(),
387
- postParentId: postParentId || servicePostParentId || null,
388
- },
389
- updateQuery: (prev, { subscriptionData }: any) => {
390
- if (!subscriptionData?.data) {
391
- console.log(`No subscription data for channel ${channel?.id}`);
392
- return prev;
393
- }
394
-
395
- try {
396
- const newPostThreadData: any =
397
- subscriptionData?.data?.threadCreatedUpdated?.data;
398
- const newMessage: any =
399
- subscriptionData?.data?.threadCreatedUpdated?.lastMessage;
400
-
401
- if (!newPostThreadData || !newMessage) {
402
- console.log(`Missing data in subscription for channel ${channel?.id}`);
403
- return prev;
404
- }
405
-
406
- console.log('New thread message subscription update:', {
407
- channelId: channel?.id,
408
- threadId: newPostThreadData?.id,
409
- hasMessage: !!newMessage,
410
- message: newMessage?.message?.substring(0, 20) + '...',
411
- });
412
-
413
- // Create a safe copy of the previous data
414
- const prevThreads = prev?.threadMessages?.data || [];
415
-
416
- // Check if this thread already exists
417
- const threadExists = prevThreads.some(
418
- (t: any) => t.id === newPostThreadData?.id,
419
- );
420
-
421
- let updatedThreads;
422
- if (threadExists) {
423
- // Update existing thread
424
- updatedThreads = prevThreads.map((t: any) =>
425
- t.id === newPostThreadData?.id
426
- ? {
427
- ...t,
428
- replies: [...(t?.replies || []), newMessage],
429
- replyCount: newPostThreadData?.replyCount,
430
- lastReplyAt: newPostThreadData?.lastReplyAt,
431
- updatedAt: newPostThreadData?.updatedAt,
432
- }
433
- : t,
434
- );
435
- } else {
436
- // Add new thread
437
- updatedThreads = [...prevThreads, newPostThreadData];
438
- }
439
-
440
- return {
441
- ...prev,
442
- threadMessages: {
443
- ...prev?.threadMessages,
444
- totalCount:
445
- newPostThreadData?.totalCount ??
446
- prev?.threadMessages?.totalCount ??
447
- 0,
448
- data: updatedThreads,
449
- },
450
- };
451
- } catch (error) {
452
- console.error(
453
- `Error processing subscription data for channel ${channel?.id}:`,
454
- error,
455
- );
456
- return prev;
457
- }
458
- },
459
- onError: (error) => {
460
- console.error(`Thread subscription error for channel ${channel?.id}:`, error);
461
- },
462
- })
407
+ shouldQuery
408
+ ? subscribeToMore({
409
+ document: THREAD_CREATED_UPDATED,
410
+ variables: {
411
+ channelId: channel?.id?.toString(),
412
+ postParentId: postParentId || servicePostParentId || null,
413
+ },
414
+ updateQuery: (prev, { subscriptionData }: any) => {
415
+ if (!subscriptionData?.data) {
416
+ return prev;
417
+ }
418
+ try {
419
+ const newPostThreadData: any =
420
+ subscriptionData?.data?.threadCreatedUpdated?.data;
421
+ const newMessage: any =
422
+ subscriptionData?.data?.threadCreatedUpdated?.lastMessage;
423
+ if (!newPostThreadData || !newMessage) {
424
+ return prev;
425
+ }
426
+ const prevThreads = prev?.threadMessages?.data || [];
427
+ const threadExists = prevThreads.some(
428
+ (t: any) => t.id === newPostThreadData?.id,
429
+ );
430
+ let updatedThreads;
431
+ if (threadExists) {
432
+ updatedThreads = prevThreads.map((t: any) =>
433
+ t.id === newPostThreadData?.id
434
+ ? {
435
+ ...t,
436
+ replies: [...(t?.replies || []), newMessage],
437
+ replyCount: newPostThreadData?.replyCount,
438
+ lastReplyAt: newPostThreadData?.lastReplyAt,
439
+ updatedAt: newPostThreadData?.updatedAt,
440
+ }
441
+ : t,
442
+ );
443
+ } else {
444
+ updatedThreads = [...prevThreads, newPostThreadData];
445
+ }
446
+ return {
447
+ ...prev,
448
+ threadMessages: {
449
+ ...prev?.threadMessages,
450
+ totalCount:
451
+ newPostThreadData?.totalCount ??
452
+ prev?.threadMessages?.totalCount ??
453
+ 0,
454
+ data: updatedThreads,
455
+ },
456
+ };
457
+ } catch (error) {
458
+ return prev;
459
+ }
460
+ },
461
+ onError: (error) => {
462
+ console.error(`Thread subscription error for channel ${channel?.id}:`, error);
463
+ },
464
+ })
465
+ : undefined
463
466
  }
464
467
  subscribeToChatMessages={() =>
465
- subscribeToMore({
466
- document: CHAT_MESSAGE_ADDED,
467
- variables: {
468
- channelId: channel?.id?.toString(),
469
- postParentId: postParentId || servicePostParentId || null,
470
- },
471
- updateQuery: (prev, { subscriptionData }: any) => {
472
- if (!subscriptionData?.data) {
473
- console.log(`No chat message subscription data for channel ${channel?.id}`);
474
- return prev;
475
- }
476
-
477
- try {
478
- const newMessage = subscriptionData?.data?.chatMessageAdded;
479
-
480
- if (!newMessage) {
481
- console.log(
482
- `Missing chat message data in subscription for channel ${channel?.id}`,
483
- );
484
- return prev;
485
- }
486
-
487
- console.log('New chat message subscription update:', {
488
- channelId: channel?.id,
489
- messageId: newMessage?.id,
490
- message: newMessage?.message?.substring(0, 20) + '...',
491
- });
492
-
493
- // Find the thread this message belongs to
494
- const prevThreads = prev?.threadMessages?.data || [];
495
- const threadIndex = prevThreads.findIndex((t: any) => {
496
- // Check if this message belongs to this thread
497
- if (newMessage.parentId && t.post?.id === newMessage.parentId) {
498
- return true;
499
- }
500
- // Check replies
501
- if (t.replies && t.replies.some((r: any) => r.id === newMessage.parentId)) {
502
- return true;
503
- }
504
- return false;
505
- });
506
-
507
- if (threadIndex === -1) {
508
- console.log(
509
- `Cannot find thread for chat message in channel ${channel?.id}`,
510
- );
511
- return prev;
512
- }
513
-
514
- // Update the thread with the new message
515
- const updatedThreads = [...prevThreads];
516
- const thread = { ...updatedThreads[threadIndex] };
517
-
518
- // Add message to replies
519
- thread.replies = [...(thread.replies || []), newMessage];
520
-
521
- // Fix for arithmetic operation type error
522
- const currentReplyCount =
523
- typeof thread.replyCount === 'number' ? thread.replyCount : 0;
524
- thread.replyCount = currentReplyCount + 1;
525
-
526
- thread.lastReplyAt = newMessage.createdAt;
527
- thread.updatedAt = newMessage.createdAt;
528
-
529
- updatedThreads[threadIndex] = thread;
530
-
531
- return {
532
- ...prev,
533
- threadMessages: {
534
- ...prev?.threadMessages,
535
- data: updatedThreads,
536
- },
537
- };
538
- } catch (error) {
539
- console.error(
540
- `Error processing chat message subscription for channel ${channel?.id}:`,
541
- error,
542
- );
543
- return prev;
544
- }
545
- },
546
- onError: (error) => {
547
- console.error(`Chat message subscription error for channel ${channel?.id}:`, error);
548
- },
549
- })
468
+ shouldQuery
469
+ ? subscribeToMore({
470
+ document: CHAT_MESSAGE_ADDED,
471
+ variables: {
472
+ channelId: channel?.id?.toString(),
473
+ postParentId: postParentId || servicePostParentId || null,
474
+ },
475
+ updateQuery: (prev, { subscriptionData }: any) => {
476
+ if (!subscriptionData?.data) {
477
+ return prev;
478
+ }
479
+ try {
480
+ const newMessage = subscriptionData?.data?.chatMessageAdded;
481
+ if (!newMessage) {
482
+ return prev;
483
+ }
484
+ const prevThreads = prev?.threadMessages?.data || [];
485
+ const threadIndex = prevThreads.findIndex((t: any) => {
486
+ if (newMessage.parentId && t.post?.id === newMessage.parentId) {
487
+ return true;
488
+ }
489
+ if (
490
+ t.replies &&
491
+ t.replies.some((r: any) => r.id === newMessage.parentId)
492
+ ) {
493
+ return true;
494
+ }
495
+ return false;
496
+ });
497
+ if (threadIndex === -1) {
498
+ return prev;
499
+ }
500
+ const updatedThreads = [...prevThreads];
501
+ const thread = { ...updatedThreads[threadIndex] };
502
+ thread.replies = [...(thread.replies || []), newMessage];
503
+ const currentReplyCount =
504
+ typeof thread.replyCount === 'number' ? thread.replyCount : 0;
505
+ thread.replyCount = currentReplyCount + 1;
506
+ thread.lastReplyAt = newMessage.createdAt;
507
+ thread.updatedAt = newMessage.createdAt;
508
+ updatedThreads[threadIndex] = thread;
509
+ return {
510
+ ...prev,
511
+ threadMessages: {
512
+ ...prev?.threadMessages,
513
+ data: updatedThreads,
514
+ },
515
+ };
516
+ } catch (error) {
517
+ return prev;
518
+ }
519
+ },
520
+ onError: (error) => {
521
+ console.error(
522
+ `Chat message subscription error for channel ${channel?.id}:`,
523
+ error,
524
+ );
525
+ },
526
+ })
527
+ : undefined
550
528
  }
529
+ subscribeToMore={subscribeToMore}
530
+ postParentId={postParentId}
531
+ servicePostParentId={servicePostParentId}
551
532
  />
552
533
  </Box>
553
534
  </HStack>
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { TextInput, TextInputProps } from 'react-native';
3
+
4
+ export const SlackInput = React.forwardRef<TextInput, TextInputProps>((props, ref) => {
5
+ return (
6
+ <TextInput
7
+ ref={ref}
8
+ {...props}
9
+ style={[
10
+ {
11
+ flex: 1,
12
+ fontSize: 16,
13
+ padding: 10,
14
+ borderRadius: 8,
15
+ backgroundColor: '#f8f8f8',
16
+ borderColor: '#e0e0e0',
17
+ borderWidth: 1,
18
+ },
19
+ props.style,
20
+ ]}
21
+ />
22
+ );
23
+ });