@cometchat/chat-uikit-react-native 5.0.0-beta.1 → 5.0.0

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/README.md +2 -3
  2. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +29 -44
  5. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +12 -0
  6. package/ios/FileManager.m +26 -9
  7. package/package.json +11 -36
  8. package/src/CometChatConversations/CometChatConversations.tsx +287 -147
  9. package/src/CometChatConversations/Skeleton.tsx +116 -73
  10. package/src/CometChatConversations/style.ts +17 -22
  11. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +439 -227
  12. package/src/CometChatGroupMembers/style.ts +2 -4
  13. package/src/CometChatGroups/CometChatGroups.tsx +239 -135
  14. package/src/CometChatGroups/GroupsStyle.ts +20 -17
  15. package/src/CometChatGroups/Skeleton.tsx +198 -288
  16. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +208 -73
  17. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +97 -43
  18. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +4 -2
  19. package/src/CometChatMessageList/CometChatMessageList.tsx +200 -76
  20. package/src/CometChatMessageList/style.ts +4 -4
  21. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +77 -11
  22. package/src/CometChatThreadHeader/style.ts +2 -2
  23. package/src/CometChatUsers/CometChatUsers.tsx +203 -51
  24. package/src/CometChatUsers/Skeleton.tsx +174 -159
  25. package/src/CometChatUsers/style.ts +21 -18
  26. package/src/calls/CallingConfiguration.ts +4 -3
  27. package/src/calls/CallingExtensionDecorator.tsx +5 -3
  28. package/src/calls/CometChatCallButtons/CometChatCallButtonConfiguration.ts +4 -2
  29. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +10 -8
  30. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +240 -97
  31. package/src/calls/CometChatCallLogs/Skeleton.tsx +175 -91
  32. package/src/calls/CometChatCallLogs/index.ts +1 -0
  33. package/src/calls/CometChatCallLogs/style.ts +85 -43
  34. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +42 -29
  35. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +36 -10
  36. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +39 -12
  37. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +5 -4
  38. package/src/extensions/Polls/PollsDecorator.tsx +30 -9
  39. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +34 -16
  40. package/src/index.ts +3 -1
  41. package/src/shared/base/Types.ts +31 -1
  42. package/src/shared/framework/DataSource.ts +64 -20
  43. package/src/shared/framework/DataSourceDecorator.tsx +46 -37
  44. package/src/shared/framework/MessageDataSource.tsx +518 -316
  45. package/src/shared/index.ts +3 -1
  46. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +3 -2
  47. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +3 -2
  48. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +3 -2
  49. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +3 -2
  50. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +3 -2
  51. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +3 -2
  52. package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +3 -2
  53. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +3 -2
  54. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +3 -2
  55. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +3 -2
  56. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +3 -2
  57. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +3 -2
  58. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +3 -2
  59. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +3 -2
  60. package/src/shared/utils/MessageUtils.tsx +41 -20
  61. package/src/shared/utils/conversationUtils.ts +2 -2
  62. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +22 -1
  63. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +20 -8
  64. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +177 -123
  65. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +76 -10
  66. package/src/shared/views/CometChatConfirmDialog/style.ts +2 -2
  67. package/src/shared/views/CometChatDate/CometChatDate.tsx +26 -18
  68. package/src/shared/views/CometChatDateSeperator/CometChatDateSeparator.tsx +22 -16
  69. package/src/shared/views/CometChatDeletedBubble/CometChatDeletedBubble.tsx +17 -5
  70. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +65 -35
  71. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +22 -11
  72. package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +47 -18
  73. package/src/shared/views/CometChatList/CometChatList.tsx +70 -46
  74. package/src/shared/views/CometChatList/Header.tsx +122 -37
  75. package/src/shared/views/CometChatList/styles.ts +1 -0
  76. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +116 -30
  77. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +52 -30
  78. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +36 -22
  79. package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +41 -13
  80. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +132 -17
  81. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +30 -2
  82. package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +10 -6
  83. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +20 -13
  84. package/src/shared/views/CometChatStatusIndicator/styles.ts +26 -13
  85. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +25 -2
  86. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +94 -14
  87. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +52 -16
  88. package/src/shared/views/CometChatTooltipMenu/index.ts +2 -1
  89. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +29 -9
  90. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +20 -2
  91. package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +29 -14
  92. package/src/shared/views/index.ts +2 -0
  93. package/src/theme/default/index.ts +5 -5
  94. package/src/theme/type.ts +2 -2
  95. package/src/shared/views/CometChatPanel/CometChatPanel.tsx +0 -57
  96. package/src/shared/views/CometChatPanel/PanelStyle.tsx +0 -43
  97. package/src/shared/views/CometChatPanel/resources/CloseIcon.png +0 -0
  98. package/src/shared/views/CometChatPanel/resources/index.ts +0 -3
@@ -126,7 +126,7 @@ export interface CometChatMessageListProps {
126
126
  /**
127
127
  * Flag to hide read receipts.
128
128
  */
129
- hideReceipt?: boolean;
129
+ receiptsVisibility?: boolean;
130
130
  /**
131
131
  * Flag to disable sound for incoming messages.
132
132
  */
@@ -142,7 +142,7 @@ export interface CometChatMessageListProps {
142
142
  /**
143
143
  * Flag to show or hide the user's avatar.
144
144
  */
145
- showAvatar?: boolean;
145
+ avatarVisibility?: boolean;
146
146
  /**
147
147
  * Function that returns a custom string representation for a message's date.
148
148
  *
@@ -161,6 +161,10 @@ export interface CometChatMessageListProps {
161
161
  * An array of message templates for rendering custom message types.
162
162
  */
163
163
  templates?: Array<CometChatMessageTemplate>;
164
+ /**
165
+ * An array of message templates for rendering custom message types.
166
+ */
167
+ addTemplates?: Array<CometChatMessageTemplate>;
164
168
  /**
165
169
  * Builder for constructing a request to fetch messages.
166
170
  */
@@ -275,6 +279,62 @@ export interface CometChatMessageListProps {
275
279
  * @type {[string, string?, string?, string?, string?]}
276
280
  */
277
281
  quickReactionList?: [string, string?, string?, string?, string?];
282
+ /**
283
+ * Callback to handle errors.
284
+ *
285
+ * @param messageList - Array of CometChat.BaseMessage
286
+ */
287
+ onLoad?: (messageList: CometChat.BaseMessage[]) => void;
288
+ /**
289
+ * Callback to handle errors.
290
+ *
291
+ * @param messageList - Array of CometChat.BaseMessage
292
+ */
293
+ onEmpty?: () => void;
294
+ /**
295
+ * Flag to hide the reply in thread option
296
+ */
297
+ hideReplyInThreadOption?: boolean;
298
+ /**
299
+ * Flag to hide the share message option
300
+ */
301
+ hideShareMessageOption?: boolean;
302
+ /**
303
+ * Flag to hide the edit message option
304
+ */
305
+ hideEditMessageOption?: boolean;
306
+ /**
307
+ * Flag to hide the translate message option
308
+ */
309
+ hideTranslateMessageOption?: boolean;
310
+ /**
311
+ * Flag to hide the delete message option
312
+ */
313
+ hideDeleteMessageOption?: boolean;
314
+ /**
315
+ * Flag to hide the react to message option
316
+ */
317
+ hideReactionOption?: boolean;
318
+ /**
319
+ * Flag to hide the message privately option
320
+ */
321
+ hideMessagePrivatelyOption?: boolean;
322
+ /**
323
+ * Flag to hide the copy message option
324
+ */
325
+ hideCopyMessageOption?: boolean;
326
+ /**
327
+ * Flag to hide the message info option
328
+ */
329
+ hideMessageInfoOption?: boolean;
330
+ /**
331
+ * Flag to hide group action messages
332
+ */
333
+ hideGroupActionMessages?: boolean;
334
+ /**
335
+ * Flag to hide the timestamp on message bubbles
336
+ */
337
+ hideTimestamp?: boolean;
278
338
  }
279
339
 
280
340
  /**
@@ -317,7 +377,7 @@ export interface CometChatMessageListActionsInterface {
317
377
 
318
378
  /**
319
379
  * Creates an action message.
320
- *
380
+ *
321
381
  * @remarks
322
382
  * TODO: Clarify the purpose and the appropriate usage of this method.
323
383
  */
@@ -342,16 +402,16 @@ export const CometChatMessageList = memo(
342
402
  ErrorView,
343
403
  hideError,
344
404
  LoadingView,
345
- hideReceipt = false,
405
+ receiptsVisibility = true,
346
406
  disableSoundForMessages,
347
407
  customSoundForMessages,
348
408
  alignment = "standard",
349
- showAvatar = true,
409
+ avatarVisibility = true,
350
410
  datePattern,
351
411
  dateSeparatorPattern,
352
412
  templates = [],
353
413
  messageRequestBuilder,
354
- scrollToBottomOnNewMessages,
414
+ scrollToBottomOnNewMessages = false,
355
415
  onThreadRepliesPress,
356
416
  HeaderView,
357
417
  FooterView,
@@ -365,6 +425,20 @@ export const CometChatMessageList = memo(
365
425
  style,
366
426
  onAddReactionPress,
367
427
  quickReactionList,
428
+ addTemplates = [],
429
+ onLoad,
430
+ onEmpty,
431
+ hideReplyInThreadOption = false,
432
+ hideShareMessageOption = false,
433
+ hideEditMessageOption = false,
434
+ hideTranslateMessageOption = false,
435
+ hideDeleteMessageOption = false,
436
+ hideReactionOption = false,
437
+ hideMessagePrivatelyOption = false,
438
+ hideCopyMessageOption = false,
439
+ hideMessageInfoOption = false,
440
+ hideGroupActionMessages = false,
441
+ hideTimestamp = false,
368
442
  } = props;
369
443
 
370
444
  const callListenerId = "call_" + new Date().getTime();
@@ -421,14 +495,21 @@ export const CometChatMessageList = memo(
421
495
  } else {
422
496
  types = ChatConfigurator.dataSource.getAllMessageTypes();
423
497
  categories = ChatConfigurator.dataSource.getAllMessageCategories();
498
+ if (addTemplates.length) {
499
+ types.push(...addTemplates.map((template) => template.type));
500
+ categories.push(...addTemplates.map((template) => template.category));
501
+ }
424
502
  }
425
503
 
504
+ if (hideGroupActionMessages) {
505
+ types = types.filter((type) => type !== MessageTypeConstants.groupMember);
506
+ }
426
507
  _updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setTypes(types);
427
508
  _updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setCategories(categories);
428
509
  }
429
510
 
430
511
  msgRequestBuilder.current = _updatedCustomRequestBuilder;
431
- }, []);
512
+ }, [hideGroupActionMessages]);
432
513
 
433
514
  const theme = useTheme();
434
515
 
@@ -581,6 +662,7 @@ export const CometChatMessageList = memo(
581
662
  const bottomSheetRef = useRef<any>(null);
582
663
  const conversationId = useRef(null);
583
664
  let lastID = useRef(0);
665
+ let reachedFirstMessage = useRef<boolean>(false);
584
666
 
585
667
  const markUnreadMessageAsRead = () => {
586
668
  CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageRead, {
@@ -595,6 +677,7 @@ export const CometChatMessageList = memo(
595
677
  ...temporaryMessageListRef.current,
596
678
  ...messagesContentListRef.current,
597
679
  ];
680
+ onLoad && onLoad([...messagesContentListRef.current].reverse());
598
681
  setMessagesList((prev) => [...temporaryMessageListRef.current, ...prev]);
599
682
  temporaryMessageListRef.current = [];
600
683
  scrollToBottom();
@@ -602,6 +685,9 @@ export const CometChatMessageList = memo(
602
685
  };
603
686
 
604
687
  const getPreviousMessages = async () => {
688
+ if (reachedFirstMessage.current) {
689
+ return;
690
+ }
605
691
  if (messagesList.length == 0) setListState("loading");
606
692
  else setLoadingMessages(true);
607
693
  // TODO: this condition is applied because somewhere from whiteboard extention group scope is set to undefined.
@@ -615,7 +701,10 @@ export const CometChatMessageList = memo(
615
701
  messageRequest.current
616
702
  ?.fetchPrevious()
617
703
  .then((msgs: any[]) => {
618
- let previousMessagesFetched = msgs.reverse();
704
+ if (messageRequest.current!.getLimit() > msgs.length) {
705
+ reachedFirstMessage.current = true;
706
+ }
707
+ let previousMessagesFetched = [...msgs].reverse(); // Reverse for UI use
619
708
  if (messagesList.length === 0 && msgs?.length > 0) {
620
709
  CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccActiveChatChanged, {
621
710
  message: previousMessagesFetched[0],
@@ -666,11 +755,16 @@ export const CometChatMessageList = memo(
666
755
  ];
667
756
  setMessagesList((prev) => [...prev, ...previousMessagesFetched]);
668
757
  }
669
- if (messagesList.length == 0) setListState("");
670
- else setLoadingMessages(false);
758
+ if (messagesContentListRef.current.length == 0) {
759
+ onEmpty && onEmpty();
760
+ } else {
761
+ onLoad && onLoad([...messagesContentListRef.current].reverse());
762
+ setLoadingMessages(false);
763
+ }
764
+ setListState("");
671
765
  })
672
766
  .catch((e: any) => {
673
- if (messagesList.length == 0) setListState("error");
767
+ if (messagesContentListRef.current.length == 0) setListState("error");
674
768
  else setLoadingMessages(false);
675
769
  onError && onError(e);
676
770
  });
@@ -728,6 +822,7 @@ export const CometChatMessageList = memo(
728
822
  if (isAtBottom() || isNearBottom()) {
729
823
  messagesContentListRef.current = tmpList;
730
824
  setMessagesList(tmpList);
825
+ onLoad && onLoad([...messagesContentListRef.current].reverse());
731
826
  for (let i = 0; i < newMessages.length; i++) {
732
827
  if (newMessages[i].getSender().getUid() !== loggedInUser.current.getUid()) {
733
828
  bottomHandler(newMessages[i], true, true);
@@ -761,19 +856,49 @@ export const CometChatMessageList = memo(
761
856
 
762
857
  const templatesMap = useMemo(() => {
763
858
  let _formatters = textFormatters || [];
764
- let templates: CometChatMessageTemplate[] =
765
- ChatConfigurator.dataSource.getAllMessageTemplates(mergedTheme, {
766
- textFormatters: _formatters,
767
- });
859
+ let tempTemplates: CometChatMessageTemplate[] =
860
+ templates && templates.length
861
+ ? templates
862
+ : [
863
+ ...ChatConfigurator.dataSource.getAllMessageTemplates(mergedTheme, {
864
+ textFormatters: _formatters,
865
+ hideReplyInThreadOption,
866
+ hideShareMessageOption,
867
+ hideEditMessageOption,
868
+ hideTranslateMessageOption,
869
+ hideDeleteMessageOption,
870
+ hideReactionOption,
871
+ hideMessagePrivatelyOption,
872
+ hideCopyMessageOption,
873
+ hideMessageInfoOption,
874
+ hideGroupActionMessages,
875
+ }),
876
+ ...addTemplates,
877
+ ];
768
878
  let templatesMapTemp = new Map<string, CometChatMessageTemplate>();
769
879
 
770
- templates.forEach((template) => {
880
+ tempTemplates.forEach((template) => {
881
+ if (hideGroupActionMessages && template.type === MessageTypeConstants.groupMember) return;
771
882
  if (templatesMapTemp.get(`${template.category}_${template.type}`)) return;
772
883
  templatesMapTemp.set(`${template.category}_${template.type}`, template);
773
884
  });
774
885
 
775
886
  return templatesMapTemp;
776
- }, [mergedTheme]);
887
+ }, [
888
+ mergedTheme,
889
+ templates,
890
+ addTemplates,
891
+ hideReplyInThreadOption,
892
+ hideShareMessageOption,
893
+ hideEditMessageOption,
894
+ hideTranslateMessageOption,
895
+ hideDeleteMessageOption,
896
+ hideReactionOption,
897
+ hideMessagePrivatelyOption,
898
+ hideCopyMessageOption,
899
+ hideMessageInfoOption,
900
+ hideGroupActionMessages,
901
+ ]);
777
902
 
778
903
  const getPlainString = (underlyingText: string, messageObject: CometChat.BaseMessage) => {
779
904
  let _plainString = underlyingText;
@@ -956,6 +1081,7 @@ export const CometChatMessageList = memo(
956
1081
  let tmpList = [...messagesList];
957
1082
  tmpList[index] = oldMsg;
958
1083
  messagesContentListRef.current = tmpList;
1084
+ onLoad && onLoad([...messagesContentListRef.current].reverse());
959
1085
  setMessagesList(tmpList);
960
1086
  return;
961
1087
  }
@@ -1014,6 +1140,7 @@ export const CometChatMessageList = memo(
1014
1140
 
1015
1141
  const addToMessageList = (newMessage: CometChat.BaseMessage) => {
1016
1142
  messagesContentListRef.current = [newMessage, ...messagesContentListRef.current];
1143
+ onLoad && onLoad([...messagesContentListRef.current].reverse());
1017
1144
  setMessagesList((prev) => [newMessage, ...prev]);
1018
1145
  };
1019
1146
 
@@ -1028,6 +1155,7 @@ export const CometChatMessageList = memo(
1028
1155
  }
1029
1156
  tmpList[msgIndex]?.setUnreadReplyCount(0);
1030
1157
  messagesContentListRef.current = tmpList;
1158
+ onLoad && onLoad([...messagesContentListRef.current].reverse());
1031
1159
  setMessagesList(tmpList);
1032
1160
  }
1033
1161
  };
@@ -1045,6 +1173,7 @@ export const CometChatMessageList = memo(
1045
1173
  }
1046
1174
  tmpList[msgIndex] = CommonUtils.clone(editedMessage);
1047
1175
  messagesContentListRef.current = tmpList;
1176
+ onLoad && onLoad([...messagesContentListRef.current].reverse());
1048
1177
  setMessagesList(tmpList);
1049
1178
  }
1050
1179
  };
@@ -1056,6 +1185,7 @@ export const CometChatMessageList = memo(
1056
1185
  let tmpList = [...messagesList];
1057
1186
  tmpList.splice(msgIndex, 1);
1058
1187
  messagesContentListRef.current = tmpList;
1188
+ onLoad && onLoad([...messagesContentListRef.current].reverse());
1059
1189
  setMessagesList(tmpList);
1060
1190
  };
1061
1191
 
@@ -1067,10 +1197,10 @@ export const CometChatMessageList = memo(
1067
1197
  });
1068
1198
  setShowMessageOptions([]);
1069
1199
  setShowDeleteModal(false);
1070
- deleteItem.current = null;
1200
+ deleteItem.current = undefined;
1071
1201
  })
1072
1202
  .catch((rej: any) => {
1073
- deleteItem.current = null;
1203
+ deleteItem.current = undefined;
1074
1204
  setShowDeleteModal(false);
1075
1205
  console.log(rej);
1076
1206
  onError && onError(rej);
@@ -1117,6 +1247,7 @@ export const CometChatMessageList = memo(
1117
1247
  }
1118
1248
 
1119
1249
  messagesContentListRef.current = tmpList;
1250
+ onLoad && onLoad([...messagesContentListRef.current].reverse());
1120
1251
  setMessagesList(tmpList);
1121
1252
  };
1122
1253
 
@@ -1220,7 +1351,9 @@ export const CometChatMessageList = memo(
1220
1351
  }
1221
1352
  },
1222
1353
  ccMessageEdited: ({ message, status }: any) => {
1223
- if (status == messageStatus.success) messageEdited(message, false);
1354
+ if (status == messageStatus.success) {
1355
+ messageEdited(message, false);
1356
+ }
1224
1357
  },
1225
1358
  ccMessageDeleted: ({ message }: any) => {
1226
1359
  messageEdited(message, false);
@@ -1528,7 +1661,7 @@ export const CometChatMessageList = memo(
1528
1661
  let _style = getCurrentBubbleStyle(item);
1529
1662
 
1530
1663
  if (
1531
- showAvatar &&
1664
+ avatarVisibility &&
1532
1665
  (alignment === "leftAligned" ||
1533
1666
  (item.getSender()?.getUid() !== loggedInUser.current?.getUid() && !user)) &&
1534
1667
  ![MessageCategoryConstants.action, MessageCategoryConstants.call].includes(
@@ -1649,18 +1782,20 @@ export const CometChatMessageList = memo(
1649
1782
  {localize("EDITED")}
1650
1783
  </Text>
1651
1784
  )}
1652
- <CometChatDate
1653
- timeStamp={
1654
- (item.getDeletedAt() ||
1655
- item.getReadAt() ||
1656
- item.getDeliveredAt() ||
1657
- item.getSentAt()) * 1000 || getSentAtTimestamp(item)
1658
- }
1659
- pattern={"timeFormat"}
1660
- customDateString={datePattern && datePattern(item)}
1661
- style={_style.dateStyles}
1662
- />
1663
- {!hideReceipt && alignment !== "leftAligned" && isOutgoingMessage ? (
1785
+ {
1786
+ <CometChatDate
1787
+ timeStamp={
1788
+ !hideTimestamp
1789
+ ? (item.getDeletedAt() || item.getSentAt()) * 1000 ||
1790
+ getSentAtTimestamp(item)
1791
+ : undefined
1792
+ }
1793
+ pattern={"timeFormat"}
1794
+ customDateString={datePattern && datePattern(item)}
1795
+ style={_style.dateStyles}
1796
+ />
1797
+ }
1798
+ {receiptsVisibility && alignment !== "leftAligned" && isOutgoingMessage ? (
1664
1799
  <View style={{ marginLeft: 2, alignItems: "center", justifyContent: "center" }}>
1665
1800
  <CometChatReceipt
1666
1801
  receipt={messageState}
@@ -1688,6 +1823,11 @@ export const CometChatMessageList = memo(
1688
1823
 
1689
1824
  const onReactionPress = useCallback(
1690
1825
  (reaction: CometChat.ReactionCount, messageObject: CometChat.BaseMessage) => {
1826
+ if (reaction.getReaction() == "All") {
1827
+ setSelectedMessage(messageObject);
1828
+ setSelectedEmoji(reaction.getReaction());
1829
+ return;
1830
+ }
1691
1831
  if (onReactionPressFromProp) {
1692
1832
  onReactionPressFromProp(reaction, messageObject);
1693
1833
  return;
@@ -1699,7 +1839,7 @@ export const CometChatMessageList = memo(
1699
1839
 
1700
1840
  const onReactionLongPress = useCallback(
1701
1841
  (reaction: CometChat.ReactionCount, messageObject: CometChat.BaseMessage) => {
1702
- if (onReactionLongPressFromProp) {
1842
+ if (onReactionLongPressFromProp && reaction.getReaction() !== "All") {
1703
1843
  onReactionLongPressFromProp(reaction, messageObject);
1704
1844
  return;
1705
1845
  }
@@ -1709,24 +1849,6 @@ export const CometChatMessageList = memo(
1709
1849
  [onReactionLongPressFromProp]
1710
1850
  );
1711
1851
 
1712
- const onReactionListItemPress = useCallback(
1713
- (reaction: CometChat.Reaction, messageObject: CometChat.BaseMessage) => {
1714
- if (onReactionListItemPressProp) {
1715
- onReactionListItemPressProp(reaction, messageObject);
1716
- return;
1717
- }
1718
- reactToMessage(reaction?.getReaction(), messageObject);
1719
- if (
1720
- messageObject?.getReactions()?.length === 1 &&
1721
- messageObject?.getReactions()?.[0]?.getCount() == 1
1722
- ) {
1723
- setShowReactionList(false);
1724
- setSelectedEmoji(undefined);
1725
- }
1726
- },
1727
- [onReactionListItemPressProp]
1728
- );
1729
-
1730
1852
  const getFooterView = useCallback(
1731
1853
  (messageObject: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType) => {
1732
1854
  let hasReaction =
@@ -1971,15 +2093,15 @@ export const CometChatMessageList = memo(
1971
2093
  hasTemplate.HeaderView
1972
2094
  ? hasTemplate.HeaderView(message, bubbleAlignment)
1973
2095
  : !isThreaded
1974
- ? getHeaderView(message)
1975
- : undefined
2096
+ ? getHeaderView(message)
2097
+ : undefined
1976
2098
  }
1977
2099
  FooterView={
1978
2100
  hasTemplate.FooterView
1979
2101
  ? hasTemplate.FooterView(message, bubbleAlignment)
1980
2102
  : isThreaded
1981
- ? undefined
1982
- : getFooterView(message, bubbleAlignment)
2103
+ ? undefined
2104
+ : getFooterView(message, bubbleAlignment)
1983
2105
  }
1984
2106
  alignment={isThreaded ? "left" : bubbleAlignment}
1985
2107
  ContentView={hasTemplate.ContentView?.(message, bubbleAlignment)}
@@ -2167,8 +2289,8 @@ export const CometChatMessageList = memo(
2167
2289
  return (
2168
2290
  <ErrorEmptyView
2169
2291
  title={"Oops!"}
2170
- subTitle='Looks like something went wrong.'
2171
- tertiaryTitle='Please try again.'
2292
+ subTitle={localize("SOMETHING_WENT_WRONG")}
2293
+ tertiaryTitle={localize("WRONG_TEXT_TRY_AGAIN")}
2172
2294
  Icon={
2173
2295
  <Icon
2174
2296
  name='error-state'
@@ -2361,11 +2483,11 @@ export const CometChatMessageList = memo(
2361
2483
  isOpen={showDeleteModal}
2362
2484
  // onDismiss={()=>console.log(deleteItem.current, "CometChatConfirmDialog onDismiss")}
2363
2485
  onCancel={() => {
2364
- deleteItem.current = null;
2486
+ deleteItem.current = undefined;
2365
2487
  setShowDeleteModal(false);
2366
2488
  }}
2367
2489
  onConfirm={() => {
2368
- deleteMessage(deleteItem.current);
2490
+ deleteMessage(deleteItem.current!);
2369
2491
  }}
2370
2492
  />
2371
2493
 
@@ -2403,24 +2525,26 @@ export const CometChatMessageList = memo(
2403
2525
  infoObject.current = null;
2404
2526
  setMessageInfo(false);
2405
2527
  }}
2406
- style={mergedTheme.messageInformationStyles}
2528
+ style={mergedTheme?.messageListStyles?.messageInformationStyles}
2407
2529
  />
2408
2530
  ) : (
2409
2531
  <View style={{ flex: 1 }}>
2410
- <CometChatQuickReactions
2411
- quickReactions={quickReactionList}
2412
- onReactionPress={reactToMessage}
2413
- onAddReactionPress={
2414
- onAddReactionPress ??
2415
- (() => {
2416
- setShowMessageOptions([]);
2417
- setTimeout(() => {
2418
- setShowEmojiKeyboard(true);
2419
- }, 200);
2420
- })
2421
- }
2422
- style={mergedTheme.quickReactionStyle}
2423
- />
2532
+ {!hideReactionOption && (
2533
+ <CometChatQuickReactions
2534
+ quickReactions={quickReactionList}
2535
+ onReactionPress={reactToMessage}
2536
+ onAddReactionPress={
2537
+ onAddReactionPress ??
2538
+ (() => {
2539
+ setShowMessageOptions([]);
2540
+ setTimeout(() => {
2541
+ setShowEmojiKeyboard(true);
2542
+ }, 200);
2543
+ })
2544
+ }
2545
+ style={mergedTheme.quickReactionStyle}
2546
+ />
2547
+ )}
2424
2548
 
2425
2549
  <CometChatActionSheet
2426
2550
  actions={showMessageOptions}
@@ -2458,7 +2582,7 @@ export const CometChatMessageList = memo(
2458
2582
  <CometChatReactionList
2459
2583
  message={selectedMessage}
2460
2584
  selectedReaction={selectedEmoji}
2461
- onPress={onReactionListItemPress}
2585
+ onPress={onReactionListItemPressProp}
2462
2586
  reactionsRequestBuilder={reactionsRequestBuilder}
2463
2587
  />
2464
2588
  </CometChatBottomSheet>
@@ -225,7 +225,7 @@ export const getMessageListStylesLight = (
225
225
  fontFamily: typography.fontFamily,
226
226
  color: color.receiveBubbleText,
227
227
  ...typography.body.regular,
228
- lineHeight: 16.8,
228
+ //lineHeight: 16.8,
229
229
  },
230
230
  translatedTextStyle: {
231
231
  fontFamily: typography.fontFamily,
@@ -405,7 +405,7 @@ export const getMessageListStylesLight = (
405
405
  fontFamily: typography.fontFamily,
406
406
  color: color.sendBubbleText,
407
407
  ...typography.body.regular,
408
- lineHeight: 16.8,
408
+ //lineHeight: 16.8,
409
409
  },
410
410
  translatedTextStyle: {
411
411
  fontFamily: typography.fontFamily,
@@ -679,7 +679,7 @@ export const getMessageListStylesDark = (
679
679
  fontFamily: typography.fontFamily,
680
680
  color: color.receiveBubbleText,
681
681
  ...typography.body.regular,
682
- lineHeight: 16.8,
682
+ //lineHeight: 16.8,
683
683
  },
684
684
  translatedTextStyle: {
685
685
  fontFamily: typography.fontFamily,
@@ -859,7 +859,7 @@ export const getMessageListStylesDark = (
859
859
  fontFamily: typography.fontFamily,
860
860
  color: color.sendBubbleText,
861
861
  ...typography.body.regular,
862
- lineHeight: 16.8,
862
+ //lineHeight: 16.8,
863
863
  },
864
864
  translatedTextStyle: {
865
865
  fontFamily: typography.fontFamily,
@@ -2,9 +2,13 @@ import React, { useEffect, useState, useMemo } from "react";
2
2
  import { ScrollView, Text, View } from "react-native";
3
3
  import {
4
4
  ChatConfigurator,
5
+ CometChatMentionsFormatter,
5
6
  CometChatMessageTemplate,
7
+ CometChatTextFormatter,
6
8
  CometChatUIKit,
9
+ CometChatUrlsFormatter,
7
10
  localize,
11
+ MessageBubbleAlignmentType,
8
12
  } from "../shared";
9
13
  import { CometChat } from "@cometchat/chat-sdk-react-native";
10
14
  import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
@@ -47,6 +51,47 @@ export interface CometChatThreadHeaderInterface {
47
51
  * @type {DeepPartial<CometChatTheme["threadHeaderStyles"]>}
48
52
  */
49
53
  style?: DeepPartial<CometChatTheme["threadHeaderStyles"]>;
54
+ /**
55
+ * toggle visibility for the reply count.
56
+ *
57
+ * @type {boolean}
58
+ */
59
+ replyCountVisibility?: boolean;
60
+ /**
61
+ * toggle visibility for the reply count bar.
62
+ *
63
+ * @type {boolean}
64
+ */
65
+ replyCountBarVisibility?: boolean;
66
+ /**
67
+ * Custom styles for the thread header, partially overriding the default theme.
68
+ */
69
+ receiptsVisibility?: boolean;
70
+ /**
71
+ * toggle visibility for the receipts.
72
+ *
73
+ * @type {boolean}
74
+ */
75
+ avatarVisibility?: boolean;
76
+ /**
77
+ * Alignment type for the parent message bubble
78
+ */
79
+ alignment?: MessageBubbleAlignmentType;
80
+ /**
81
+ * Function that returns a custom string representation for a parent message's sent date.
82
+ *
83
+ * @param message - The base message object.
84
+ * @returns A string representing the custom date.
85
+ */
86
+ datePattern?: (message: CometChat.BaseMessage) => string;
87
+ /**
88
+ * Collection of text formatter classes to apply custom formatting.
89
+ *
90
+ * @type {Array<CometChatMentionsFormatter | CometChatUrlsFormatter | CometChatTextFormatter>}
91
+ */
92
+ textFormatters?: Array<
93
+ CometChatMentionsFormatter | CometChatUrlsFormatter | CometChatTextFormatter
94
+ >;
50
95
  }
51
96
 
52
97
  /**
@@ -57,7 +102,17 @@ export interface CometChatThreadHeaderInterface {
57
102
  * @returns {JSX.Element} The rendered thread header.
58
103
  */
59
104
  export const CometChatThreadHeader = (props: CometChatThreadHeaderInterface): JSX.Element => {
60
- const { parentMessage, template } = props;
105
+ const {
106
+ parentMessage,
107
+ template,
108
+ replyCountVisibility = true,
109
+ replyCountBarVisibility = true,
110
+ textFormatters,
111
+ datePattern,
112
+ alignment,
113
+ receiptsVisibility = true,
114
+ avatarVisibility = true,
115
+ } = props;
61
116
  const [message, setMessage] = useState<CometChat.BaseMessage>(parentMessage);
62
117
  const [replyCount, setReplyCount] = useState<number>(parentMessage.getReplyCount() || 0);
63
118
 
@@ -187,22 +242,33 @@ export const CometChatThreadHeader = (props: CometChatThreadHeaderInterface): JS
187
242
  templates:
188
243
  template && template.type === parentMessage.getType()
189
244
  ? [template]
190
- : ChatConfigurator.dataSource.getAllMessageTemplates(mergedTheme),
191
- alignment:
192
- message.getSender().getUid() === CometChatUIKit.loggedInUser!.getUid()
245
+ : ChatConfigurator.dataSource.getAllMessageTemplates(mergedTheme, {
246
+ textFormatters,
247
+ }),
248
+ alignment: alignment
249
+ ? alignment
250
+ : message.getSender().getUid() === CometChatUIKit.loggedInUser!.getUid()
193
251
  ? "right"
194
252
  : "left",
195
253
  theme: mergedTheme,
254
+ datePattern,
255
+ receiptsVisibility,
256
+ avatarVisibility
257
+
196
258
  })}
197
259
  </View>
198
260
  </ScrollView>
199
- <View style={style?.dividerStyle}>
200
- <Text style={style?.replyCountTextStyle}>
201
- {replyCount.toString() +
202
- " " +
203
- (replyCount == 1 ? localize("REPLY") : localize("REPLIES"))}
204
- </Text>
205
- </View>
261
+ {replyCountBarVisibility && (
262
+ <View style={style?.replyCountBarStyle}>
263
+ <Text style={style?.replyCountTextStyle}>
264
+ {replyCountVisibility
265
+ ? replyCount.toString() +
266
+ " " +
267
+ (replyCount == 1 ? localize("REPLY") : localize("REPLIES"))
268
+ : ""}
269
+ </Text>
270
+ </View>
271
+ )}
206
272
  </View>
207
273
  );
208
274
  };