@cometchat/chat-uikit-react-native 5.5.4 → 5.7.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 (215) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/CometChatKeyboardModule.kt +101 -0
  2. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
  3. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +78 -3
  4. package/android/src/main/java/com/reactnativecometchatuikit/KeyboardDirectionWatcher.kt +64 -0
  5. package/android/src/main/java/com/reactnativecometchatuikit/KeyboardLanguageDirection.kt +44 -0
  6. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +287 -49
  7. package/android/src/main/java/com/reactnativecometchatuikit/SafeFileName.java +78 -0
  8. package/ios/CCLocalFileGuard.h +19 -0
  9. package/ios/CCLocalFileGuard.m +34 -0
  10. package/ios/CometChatKeyboardModule.m +9 -0
  11. package/ios/CometChatKeyboardModule.swift +71 -0
  12. package/ios/FileManager.m +70 -6
  13. package/ios/KeyboardLanguageDirection.swift +24 -0
  14. package/ios/RichTextEditorView.swift +253 -51
  15. package/ios/RichTextEditorViewManager.m +1 -0
  16. package/ios/VideoManager.m +1 -1
  17. package/package.json +18 -3
  18. package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +41 -57
  19. package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +4 -1
  20. package/src/CometChatAIAssistantChatHistory/style.ts +5 -2
  21. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +145 -63
  22. package/src/CometChatCompactMessageComposer/styles.ts +7 -7
  23. package/src/CometChatConversations/CometChatConversations.tsx +276 -147
  24. package/src/CometChatConversations/Skeleton.tsx +4 -1
  25. package/src/CometChatConversations/style.ts +1 -1
  26. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +39 -18
  27. package/src/CometChatGroupMembers/Skeleton.tsx +4 -1
  28. package/src/CometChatGroupMembers/style.ts +6 -4
  29. package/src/CometChatGroups/CometChatGroups.tsx +74 -58
  30. package/src/CometChatGroups/GroupsStyle.ts +1 -1
  31. package/src/CometChatGroups/Skeleton.tsx +4 -1
  32. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +190 -96
  33. package/src/CometChatMessageComposer/styles.tsx +1 -1
  34. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +28 -15
  35. package/src/CometChatMessageHeader/listners.ts +76 -56
  36. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -1
  37. package/src/CometChatMessageInformation/Skeleton.tsx +4 -1
  38. package/src/CometChatMessageList/CometChatMessageList.tsx +1465 -313
  39. package/src/CometChatMessageList/SwipeToReplyView.tsx +61 -0
  40. package/src/CometChatMessageList/style.ts +32 -32
  41. package/src/CometChatMessageList/swipeToReply.ts +25 -0
  42. package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +81 -10
  43. package/src/CometChatNotificationFeed/style.ts +1 -1
  44. package/src/CometChatNotificationFeed/utils.ts +17 -18
  45. package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +82 -3
  46. package/src/CometChatPinnedMessages/style.ts +5 -5
  47. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +2 -0
  48. package/src/CometChatRichTextEditor/index.tsx +3 -0
  49. package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +83 -15
  50. package/src/CometChatSavedMessages/style.ts +3 -3
  51. package/src/CometChatSearch/CometChatSearch.tsx +391 -136
  52. package/src/CometChatSearch/Skeleton.tsx +4 -1
  53. package/src/CometChatSearch/searchLabels.ts +26 -0
  54. package/src/CometChatSearch/style.ts +7 -7
  55. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +34 -8
  56. package/src/CometChatThreadHeader/Header.tsx +2 -2
  57. package/src/CometChatUsers/CometChatUsers.tsx +10 -1
  58. package/src/CometChatUsers/Skeleton.tsx +4 -1
  59. package/src/CometChatUsers/style.ts +1 -1
  60. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +27 -1
  61. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +16 -4
  62. package/src/calls/CometChatCallLogs/Skeleton.tsx +4 -1
  63. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +11 -3
  64. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +10 -2
  65. package/src/extensions/CollaborativeBubble/style.ts +4 -4
  66. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
  67. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
  68. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +11 -6
  69. package/src/extensions/LinkPreview/style.ts +6 -6
  70. package/src/extensions/Polls/Header.tsx +1 -1
  71. package/src/extensions/Polls/Polls.tsx +25 -12
  72. package/src/extensions/Polls/PollsBubble.tsx +10 -6
  73. package/src/extensions/Polls/style.ts +4 -4
  74. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +2 -2
  75. package/src/extensions/Stickers/CometChatStickerKeyboard/Skeleton.tsx +1 -1
  76. package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +1 -1
  77. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +4 -2
  78. package/src/index.ts +11 -1
  79. package/src/shared/CometChatUiKit/CometChatUIKit.ts +102 -2
  80. package/src/shared/CometChatUiKit/UIKitSettings.ts +28 -0
  81. package/src/shared/events/CometChatUIEventHandler/Listener.ts +10 -0
  82. package/src/shared/events/index.ts +4 -0
  83. package/src/shared/events/offline.ts +28 -0
  84. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +18 -13
  85. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +15 -7
  86. package/src/shared/formatters/CometChatTextFormatter.ts +11 -0
  87. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +7 -4
  88. package/src/shared/framework/MessageDataSource.tsx +51 -108
  89. package/src/shared/helper/LocalizedDateHelper.ts +64 -4
  90. package/src/shared/helper/helperFunctions.ts +71 -4
  91. package/src/shared/helper/keyboardDirection.ts +54 -0
  92. package/src/shared/helper/layoutDirection.ts +205 -0
  93. package/src/shared/helper/pluralRules.ts +67 -0
  94. package/src/shared/helper/textDirection.ts +118 -0
  95. package/src/shared/icons/Icon.tsx +37 -2
  96. package/src/shared/icons/components/format-list-numbered-rtl.tsx +15 -0
  97. package/src/shared/index.ts +2 -0
  98. package/src/shared/offline/OfflineHub.ts +651 -0
  99. package/src/shared/offline/OfflineMediaBubble.tsx +49 -0
  100. package/src/shared/offline/OfflineViews.tsx +222 -0
  101. package/src/shared/offline/conversationPins.ts +137 -0
  102. package/src/shared/offline/conversations.ts +325 -0
  103. package/src/shared/offline/frameProbe.ts +24 -0
  104. package/src/shared/offline/gate.ts +94 -0
  105. package/src/shared/offline/groupActions.ts +81 -0
  106. package/src/shared/offline/identity.ts +162 -0
  107. package/src/shared/offline/index.ts +76 -0
  108. package/src/shared/offline/media.ts +247 -0
  109. package/src/shared/offline/notices.ts +84 -0
  110. package/src/shared/offline/reconcile.ts +296 -0
  111. package/src/shared/offline/searchOutcome.ts +62 -0
  112. package/src/shared/offline/send.ts +430 -0
  113. package/src/shared/offline/stateContract.ts +85 -0
  114. package/src/shared/offline/threadReplies.ts +125 -0
  115. package/src/shared/offline/twoPhase.ts +372 -0
  116. package/src/shared/offline/unsentActions.ts +168 -0
  117. package/src/shared/offline/useOfflineMediaUri.ts +87 -0
  118. package/src/shared/offline/useOfflineReconnect.ts +25 -0
  119. package/src/shared/offline/useOfflineSessionEnded.ts +22 -0
  120. package/src/shared/offline/useOfflineUploadTray.ts +76 -0
  121. package/src/shared/offline/usePresenceHidden.ts +33 -0
  122. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +2 -0
  123. package/src/shared/resources/CometChatLocalizeNew/resources/ar/translation.json +720 -0
  124. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +74 -3
  125. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +75 -4
  126. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +74 -3
  127. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +75 -4
  128. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +74 -3
  129. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +74 -3
  130. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +74 -3
  131. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +74 -3
  132. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +74 -3
  133. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +82 -3
  134. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +74 -3
  135. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +74 -3
  136. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +74 -3
  137. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +90 -3
  138. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +74 -3
  139. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +74 -3
  140. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +74 -3
  141. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +74 -3
  142. package/src/shared/services/UploadQueueService.ts +106 -1
  143. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +13 -12
  144. package/src/shared/utils/CometChatMessagePreview/style.ts +1 -1
  145. package/src/shared/utils/MessageReceiptUtils.ts +8 -0
  146. package/src/shared/utils/MessageUtils.tsx +14 -14
  147. package/src/shared/utils/PermissionUtil.ts +16 -5
  148. package/src/shared/utils/SavedMessagesHelper.ts +18 -1
  149. package/src/shared/utils/attachmentLimits.ts +3 -2
  150. package/src/shared/utils/catchUpCursor.ts +36 -0
  151. package/src/shared/utils/conversationUtils.ts +3 -5
  152. package/src/shared/utils/failedMessageRetry.ts +73 -0
  153. package/src/shared/utils/fileIconFontSize.ts +10 -0
  154. package/src/shared/utils/fileSizeLabel.ts +16 -0
  155. package/src/shared/utils/groupActionText.ts +75 -0
  156. package/src/shared/utils/messageIdentity.ts +38 -0
  157. package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +12 -8
  158. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +1 -1
  159. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +5 -3
  160. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +22 -17
  161. package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +45 -12
  162. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +16 -10
  163. package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +20 -8
  164. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +8 -4
  165. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +6 -2
  166. package/src/shared/views/CometChatComposerErrorBanner.tsx +3 -1
  167. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +8 -3
  168. package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +2 -2
  169. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +5 -3
  170. package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +8 -8
  171. package/src/shared/views/CometChatEmojiKeyboard/style.ts +2 -2
  172. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +13 -27
  173. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +65 -15
  174. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +7 -3
  175. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +56 -25
  176. package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +41 -21
  177. package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +7 -3
  178. package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +7 -3
  179. package/src/shared/views/CometChatList/CometChatList.tsx +478 -21
  180. package/src/shared/views/CometChatList/Header.tsx +5 -2
  181. package/src/shared/views/CometChatList/sectionLetter.ts +44 -0
  182. package/src/shared/views/CometChatList/styles.ts +7 -7
  183. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +6 -4
  184. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPlayer.tsx +16 -10
  185. package/src/shared/views/CometChatMediaRecorder/Timer.tsx +5 -1
  186. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +43 -16
  187. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +24 -4
  188. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +19 -2
  189. package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +3 -2
  190. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +59 -12
  191. package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +2 -2
  192. package/src/shared/views/CometChatReactionList/Skeleton.tsx +4 -1
  193. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +6 -2
  194. package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +7 -3
  195. package/src/shared/views/CometChatReportDialog/style.ts +1 -1
  196. package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +1 -1
  197. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +4 -0
  198. package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +20 -13
  199. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -2
  200. package/src/shared/views/CometChatSuggestionList/Skeleton.tsx +1 -1
  201. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +29 -3
  202. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +20 -30
  203. package/src/shared/views/CometChatTooltipMenu/tooltipPosition.ts +43 -0
  204. package/src/shared/views/CometChatVideoBubble/style.ts +2 -2
  205. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +4 -1
  206. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +58 -24
  207. package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +24 -12
  208. package/src/shared/views/SenderLabel.tsx +41 -0
  209. package/src/theme/default/default.ts +1 -1
  210. package/src/theme/type.ts +17 -0
  211. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  212. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  213. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  214. package/android/.gradle/7.4/gc.properties +0 -0
  215. package/android/.gradle/vcs-1/gc.properties +0 -0
@@ -331,7 +331,7 @@ const getStatusInfoView = (
331
331
  />
332
332
  {receiptsVisibility && isOutgoingMessage ? (
333
333
  /* ToDoM Use Icon From Incoming/Outgoing bubble styles */
334
- <View style={{ marginLeft: 2, alignItems: "center", justifyContent: "center" }}>
334
+ <View style={{ marginStart: 2, alignItems: "center", justifyContent: "center" }}>
335
335
  <CometChatReceipt
336
336
  receipt={messageState as MessageReceipt}
337
337
  style={{
@@ -379,8 +379,8 @@ export const MessageUtils = {
379
379
  isOutgoing && moderationStatus === "disapproved"
380
380
  ? deepMerge(baseStyle, {
381
381
  containerStyle: {
382
- borderBottomLeftRadius: 0,
383
- borderBottomRightRadius: 0,
382
+ borderBottomStartRadius: 0,
383
+ borderBottomEndRadius: 0,
384
384
  overflow: "hidden",
385
385
  },
386
386
  })
@@ -440,7 +440,7 @@ export const getMessagePreviewInternal = (
440
440
  name={iconName}
441
441
  size={iconSize}
442
442
  color={iconColor || theme?.color?.textSecondary}
443
- containerStyle={{ marginRight: theme?.spacing?.spacing?.s0_5 }}
443
+ containerStyle={{ marginEnd: theme?.spacing?.spacing?.s0_5 }}
444
444
  />
445
445
  )}
446
446
  <Text
@@ -579,10 +579,10 @@ export const ModerationBottomView = ({
579
579
  {
580
580
  marginHorizontal: -bubblePadH,
581
581
  marginBottom: -bubblePadB,
582
- borderTopLeftRadius: 0,
583
- borderTopRightRadius: 0,
584
- borderBottomLeftRadius: bubbleRadius,
585
- borderBottomRightRadius: bubbleRadius,
582
+ borderTopStartRadius: 0,
583
+ borderTopEndRadius: 0,
584
+ borderBottomStartRadius: bubbleRadius,
585
+ borderBottomEndRadius: bubbleRadius,
586
586
  flexDirection: "row",
587
587
  alignItems: "center",
588
588
  },
@@ -592,7 +592,7 @@ export const ModerationBottomView = ({
592
592
  <Icon
593
593
  name="message-blocked"
594
594
  color={effective?.iconTintColor}
595
- containerStyle={{ paddingLeft: 12, paddingRight: 4, alignSelf: "stretch" }}
595
+ containerStyle={{ paddingStart: 12, paddingEnd: 4, alignSelf: "stretch" }}
596
596
  />
597
597
  <Text
598
598
  style={[
@@ -634,10 +634,10 @@ export const MimeErrorBottomView = ({
634
634
  {
635
635
  marginHorizontal: -bubblePadH,
636
636
  marginBottom: -bubblePadB,
637
- borderTopLeftRadius: 0,
638
- borderTopRightRadius: 0,
639
- borderBottomLeftRadius: bubbleRadius,
640
- borderBottomRightRadius: bubbleRadius,
637
+ borderTopStartRadius: 0,
638
+ borderTopEndRadius: 0,
639
+ borderBottomStartRadius: bubbleRadius,
640
+ borderBottomEndRadius: bubbleRadius,
641
641
  flexDirection: "row",
642
642
  alignItems: "center",
643
643
  },
@@ -647,7 +647,7 @@ export const MimeErrorBottomView = ({
647
647
  <Icon
648
648
  name="message-blocked"
649
649
  color={effective?.iconTintColor}
650
- containerStyle={{ paddingLeft: 12, paddingRight: 4, alignSelf: "stretch" }}
650
+ containerStyle={{ paddingStart: 12, paddingEnd: 4, alignSelf: "stretch" }}
651
651
  />
652
652
  <Text
653
653
  style={[
@@ -108,7 +108,7 @@ class PermissionUtilIOS {
108
108
 
109
109
  async startResourceBasedTask(resources: TPermissibleResources[]) {
110
110
  const resourcePermStatuses = await this.get(resources);
111
- let allResourcesAllowed = true;
111
+ const denied: TPermissibleResources[] = [];
112
112
  for (let i = 0; i < resourcePermStatuses.length; i++) {
113
113
  const resourcePermStatus = resourcePermStatuses[i];
114
114
  if (
@@ -118,12 +118,23 @@ class PermissionUtilIOS {
118
118
  await this.request([resources[i]]);
119
119
  [resourcePermStatuses[i]] = await this.get([resources[i]]);
120
120
  }
121
- if (resourcePermStatuses[i] === this.status.Denied) {
122
- allResourcesAllowed = false;
121
+ // iOS Restricted (Screen Time / MDM) can't be granted in-app either: block it like Denied.
122
+ if (
123
+ resourcePermStatuses[i] === this.status.Denied ||
124
+ resourcePermStatuses[i] === this.status.Restricted
125
+ ) {
126
+ denied.push(resources[i]);
123
127
  }
124
128
  }
125
- if (allResourcesAllowed === false) {
126
- Alert.alert("", t("CAMERA_PERMISSION"), [
129
+ const allResourcesAllowed = denied.length === 0;
130
+ if (!allResourcesAllowed) {
131
+ // ENG-57317: name what was actually denied (a voice call asks for the microphone only).
132
+ const message = !denied.includes("mic")
133
+ ? "CAMERA_PERMISSION"
134
+ : denied.includes("camera")
135
+ ? "CAMERA_MICROPHONE_PERMISSION"
136
+ : "MICROPHONE_ACCESS_PERMISSION";
137
+ Alert.alert("", t(message), [
127
138
  {
128
139
  style: "cancel",
129
140
  text: t("CANCEL"),
@@ -216,7 +216,24 @@ export const sourceLabelFor = (
216
216
  };
217
217
 
218
218
  /**
219
- * A fresh request for the logged-in user's saved messages, newest save first.
219
+ * The Saved list's order: newest message first, by when it was *sent*, as the React UI Kit
220
+ * does (`sentAtDesc` in its saved-messages reducer). Pages arrive in the request's own order
221
+ * (oldest first within a page) and a later page can hold a message newer than anything
222
+ * already shown, so the order is re-established on every merge. Ties break on id so equal
223
+ * timestamps don't shuffle between renders. Guarded: a row from an event is not guaranteed
224
+ * to be a fully hydrated SDK instance, and an ordering helper must never throw.
225
+ */
226
+ export const sentAtDesc = (a: CometChat.BaseMessage, b: CometChat.BaseMessage): number => {
227
+ const at = typeof a?.getSentAt === "function" ? Number(a.getSentAt()) || 0 : 0;
228
+ const bt = typeof b?.getSentAt === "function" ? Number(b.getSentAt()) || 0 : 0;
229
+ if (bt !== at) return bt - at;
230
+ const aid = typeof a?.getId === "function" ? Number(a.getId()) || 0 : 0;
231
+ const bid = typeof b?.getId === "function" ? Number(b.getId()) || 0 : 0;
232
+ return bid - aid;
233
+ };
234
+
235
+ /**
236
+ * A fresh request for the logged-in user's saved messages, newest message first by send time.
220
237
  *
221
238
  * The ordinary messages request, filtered to saved rows. Deliberately carries NO
222
239
  * uid/guid: `saved=1` is account-wide, and scoping it to a conversation would turn
@@ -1,4 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
+ import { localizeDigits } from '../helper/LocalizedDateHelper';
2
3
  import { CometChat } from '@cometchat/chat-sdk-react-native';
3
4
  import {
4
5
  DEFAULT_MAX_ATTACHMENT_COUNT,
@@ -103,7 +104,7 @@ export function acceptPickedAttachments<T>(
103
104
  const remaining = Math.max(0, maxCount - existingCount);
104
105
  if (files.length > remaining) {
105
106
  // Over the limit → drop the ENTIRE pick (already-staged files are untouched).
106
- showToast(t('ATTACHMENT_COUNT_EXCEEDED').replace('{max}', String(maxCount)));
107
+ showToast(t('ATTACHMENT_COUNT_EXCEEDED').replace('{max}', localizeDigits(String(maxCount))));
107
108
  return [];
108
109
  }
109
110
  return files;
@@ -127,7 +128,7 @@ export async function toastAttachmentRejection(
127
128
  const { fileSizeMax } = await getFileUploadLimits();
128
129
  showToast(
129
130
  t('ATTACHMENT_SIZE_EXCEEDED')
130
- .replace('{max}', `${Math.round(fileSizeMax / 1024 / 1024)} MB`)
131
+ .replace('{max}', localizeDigits(t('FILE_SIZE_MB').replace('{size}', String(Math.round(fileSizeMax / 1024 / 1024)))))
131
132
  );
132
133
  return;
133
134
  }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Reconnect catch-up paging for the message list (plan D3).
3
+ *
4
+ * `getNewMessages` fetched forward from `lastID` and recursed only when a page held exactly 30
5
+ * messages, without ever moving the cursor: a full page re-fetched the same page forever, and a
6
+ * request with a different limit never paged at all. The next page now starts after the newest
7
+ * server id of the page just fetched, and paging stops on a page shorter than the request's own
8
+ * limit (or one that did not move the cursor).
9
+ */
10
+
11
+ function numericId(message: any): number {
12
+ const raw = typeof message?.getId === "function" ? message.getId() : message?.id;
13
+ const id = typeof raw === "string" ? parseInt(raw, 10) : Number(raw);
14
+ return Number.isFinite(id) && id > 0 ? id : 0;
15
+ }
16
+
17
+ /** Newest server id in `messages` (0 when none has one). */
18
+ export function newestServerIdIn(messages: readonly any[] | null | undefined): number {
19
+ let newest = 0;
20
+ for (const message of messages ?? []) newest = Math.max(newest, numericId(message));
21
+ return newest;
22
+ }
23
+
24
+ /**
25
+ * The cursor for the next catch-up page, or `null` when catch-up is complete.
26
+ * @param page the page just fetched (any order)
27
+ * @param cursor the message id that page was fetched after
28
+ * @param limit the request's own page size
29
+ */
30
+ export function nextCatchUpCursor(page: readonly any[] | null | undefined, cursor: number, limit: number): number | null {
31
+ const size = page?.length ?? 0;
32
+ const pageLimit = Number(limit) > 0 ? Number(limit) : 30;
33
+ if (size < pageLimit) return null;
34
+ const newest = newestServerIdIn(page);
35
+ return newest > (Number(cursor) || 0) ? newest : null;
36
+ }
@@ -106,16 +106,14 @@ export class CometChatConversationUtils {
106
106
 
107
107
  if (lastMessage.getCategory() == "call") {
108
108
  let color: ColorValue | undefined = theme?.color?.textSecondary;
109
- let text = "Video call";
109
+ const isAudio = lastMessage.getType() == "audio";
110
+ let text = t(isAudio ? "VOICE_CALL" : "VIDEO_CALL");
110
111
  let iconName: IconName = "phone-incoming-fill";
111
- if (lastMessage.getType() == "audio") {
112
- text = "Voice call";
113
- }
114
112
  if (uid === lastMessage.getSender()?.getUid()) {
115
113
  iconName = "phone-outgoing-fill";
116
114
  } else if ((lastMessage as CometChat.Call).getAction() === "unanswered") {
117
115
  color = theme?.color?.error;
118
- text = "Missed " + text.toLowerCase();
116
+ text = t(isAudio ? "MISSED_VOICE_CALL" : "MISSED_VIDEO_CALL");
119
117
  }
120
118
 
121
119
  return getMessagePreviewInternal(iconName, text, {iconColor: color, theme});
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Retry of a failed own message on the offline-OFF path (plan D1).
3
+ *
4
+ * The bubble's "Retry" used to call a media-only resend that returned early for text and custom
5
+ * messages, so tapping Retry on a failed text did nothing. It also showed on moderation-
6
+ * disapproved rows (which have a server id and must not be re-sent) and re-sent them if media.
7
+ *
8
+ * Rules: Retry is offered only for a row the server never accepted (no server id) that was not
9
+ * rejected by moderation. It clears the kit's error marks and re-sends through the same public
10
+ * `CometChatUIKit.send*` path a first send uses, which re-emits ccMessageSent
11
+ * inprogress -> success/error; the list reconciles by muid in place.
12
+ */
13
+
14
+ export interface FailedMessageSenders {
15
+ sendText(message: any): Promise<unknown>;
16
+ sendMedia(message: any): Promise<unknown>;
17
+ sendCustom(message: any): Promise<unknown>;
18
+ }
19
+
20
+ function serverId(message: any): unknown {
21
+ return typeof message?.getId === "function" ? message.getId() : message?.id;
22
+ }
23
+
24
+ /** Whether the failed row may offer Retry (no server id, not rejected by moderation). */
25
+ export function isRetryableFailedRow(message: any, moderationStatus?: string): boolean {
26
+ if (!message) return false;
27
+ if (moderationStatus === "disapproved") return false;
28
+ const id = serverId(message);
29
+ return id === undefined || id === null || id === "" || id === 0 || id === "0";
30
+ }
31
+
32
+ /** Remove the error marks the send paths stamp (data.metaData.error, metadata.error, .error). */
33
+ export function clearSendErrorMarks(message: any): void {
34
+ const data: any = message?.getData?.() || {};
35
+ if (data?.metaData?.error) {
36
+ delete data.metaData.error;
37
+ message?.setData?.(data);
38
+ }
39
+ const metadata: any = message?.getMetadata?.();
40
+ if (metadata?.error) {
41
+ delete metadata.error;
42
+ message?.setMetadata?.(metadata);
43
+ }
44
+ if (message && "error" in message) message.error = undefined;
45
+ }
46
+
47
+ /** Which send a message goes through: "media", "custom" or "text"; `null` for anything else. */
48
+ export function resendKindOf(message: any): "text" | "media" | "custom" | null {
49
+ const category = message?.getCategory?.();
50
+ const type = message?.getType?.();
51
+ if (category === "custom") return "custom";
52
+ if (category === "message") {
53
+ if (type === "text") return "text";
54
+ if (type === "image" || type === "video" || type === "audio" || type === "file") return "media";
55
+ }
56
+ return null;
57
+ }
58
+
59
+ /** Re-send a failed row. Returns false when the row may not be retried. Never throws. */
60
+ export function resendFailedMessage(message: any, senders: FailedMessageSenders, moderationStatus?: string): boolean {
61
+ try {
62
+ if (!isRetryableFailedRow(message, moderationStatus)) return false;
63
+ const kind = resendKindOf(message);
64
+ if (!kind) return false;
65
+ clearSendErrorMarks(message);
66
+ const send = kind === "media" ? senders.sendMedia : kind === "custom" ? senders.sendCustom : senders.sendText;
67
+ // On failure the send path re-applies the error mark and emits ccMessageSent(error).
68
+ send(message).catch(() => {});
69
+ return true;
70
+ } catch {
71
+ return false;
72
+ }
73
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Font size for the translated label drawn inside the search file icon (CometChatSearch).
3
+ * The label sits on a front page ~54 units wide; 15 is the design size for "FILE". Longer words
4
+ * (ARCHIVO, BESTAND, FASCICOLO) or wide CJK glyphs shrink so they stay inside the page.
5
+ */
6
+ export function fileIconFontSize(label: string): number {
7
+ // ponytail: width estimate (CJK ≈ 1em, others ≈ 0.65em bold), not a text measurement.
8
+ const units = [...label].reduce((w, c) => w + (c.charCodeAt(0) >= 0x2e80 ? 1 : 0.65), 0);
9
+ return Math.min(15, 46 / Math.max(units, 1));
10
+ }
@@ -0,0 +1,16 @@
1
+ import { getCometChatTranslation } from "../resources/CometChatLocalizeNew/LocalizationManager";
2
+ import { localizeDigits } from "../helper/LocalizedDateHelper";
3
+
4
+ const t = getCometChatTranslation();
5
+
6
+ /**
7
+ * A file size with its unit in the kit language ("1.5 MB" in English, "١.٥ ميغابايت" in Arabic).
8
+ * `size` is already rounded by the caller; only the unit and the digits change here (the decimal
9
+ * point stays ".").
10
+ */
11
+ export function fileSizeLabel(
12
+ key: "FILE_SIZE_BYTES" | "FILE_SIZE_KB" | "FILE_SIZE_MB",
13
+ size: string | number
14
+ ): string {
15
+ return localizeDigits(t(key).replace("{size}", String(size)));
16
+ }
@@ -0,0 +1,75 @@
1
+ import { sentenceWithNames, withSentenceDirection } from "../helper/textDirection";
2
+
3
+ // ENG-41314: the sentence for a group member action ("X added Y"), built from the translated
4
+ // template (placeholders ${byName}/${onName}/${role}) or a simple fallback when the key has no
5
+ // translation. Names are isolated and the sentence takes the template's direction. Pure, so it
6
+ // can be tested without the data source.
7
+ //
8
+ // RTL parity (Android GroupActionText.kt): when the logged-in user did the action ("You added
9
+ // Sara") or had it done to them ("Ann added you"), the sentence uses its own template, because the
10
+ // verb changes with the person in most languages. `you` is the actor form, `youTarget` the target
11
+ // form (joined / left have none).
12
+ const ACTIONS: Record<string, { key: string; word: string; needsOn: boolean; you: string; youTarget?: string }> = {
13
+ added: {
14
+ key: "MESSAGE_LIST_ACTION_ADDED", word: "ADDED", needsOn: true,
15
+ you: "MESSAGE_LIST_ACTION_YOU_ADDED", youTarget: "MESSAGE_LIST_ACTION_ADDED_YOU",
16
+ },
17
+ joined: { key: "MESSAGE_LIST_ACTION_JOINED", word: "JOINED", needsOn: false, you: "MESSAGE_LIST_ACTION_YOU_JOINED" },
18
+ left: { key: "MESSAGE_LIST_ACTION_LEFT", word: "LEFT", needsOn: false, you: "MESSAGE_LIST_ACTION_YOU_LEFT" },
19
+ kicked: {
20
+ key: "MESSAGE_LIST_ACTION_KICKED", word: "KICKED", needsOn: true,
21
+ you: "MESSAGE_LIST_ACTION_YOU_KICKED", youTarget: "MESSAGE_LIST_ACTION_KICKED_YOU",
22
+ },
23
+ banned: {
24
+ key: "MESSAGE_LIST_ACTION_BANNED", word: "BANNED", needsOn: true,
25
+ you: "MESSAGE_LIST_ACTION_YOU_BANNED", youTarget: "MESSAGE_LIST_ACTION_BANNED_YOU",
26
+ },
27
+ unbanned: {
28
+ key: "MESSAGE_LIST_ACTION_UNBANNED", word: "UNBANNED", needsOn: true,
29
+ you: "MESSAGE_LIST_ACTION_YOU_UNBANNED", youTarget: "MESSAGE_LIST_ACTION_UNBANNED_YOU",
30
+ },
31
+ scopeChanged: {
32
+ key: "MESSAGE_LIST_ACTION_SCOPE_CHANGED", word: "MADE", needsOn: true,
33
+ you: "MESSAGE_LIST_ACTION_YOU_SCOPE_CHANGED", youTarget: "MESSAGE_LIST_ACTION_SCOPE_CHANGED_YOU",
34
+ },
35
+ };
36
+
37
+ /** Whether the logged-in user did the action (`actor`) or had it done to them (`target`). */
38
+ export type GroupActionSelf = { actor?: boolean; target?: boolean };
39
+
40
+ export function groupActionText(
41
+ action: string,
42
+ by: string | undefined,
43
+ on: string | undefined,
44
+ t: (key: string) => string,
45
+ newScope = "",
46
+ serverText = "",
47
+ self: GroupActionSelf = {}
48
+ ): string {
49
+ const translated = (key: string) => {
50
+ const s = t(key);
51
+ return s === key ? undefined : s;
52
+ };
53
+
54
+ const spec = ACTIONS[action];
55
+ // Server text, not a template: no placeholders to fill.
56
+ if (!spec) return withSentenceDirection(serverText);
57
+
58
+ // The actor form wins when the user is both. translate() already falls back to the kit's English
59
+ // you-form, so the plain template is used only when no bundle at all has the key.
60
+ const youKey = self.actor ? spec.you : self.target ? spec.youTarget : undefined;
61
+ const fallback = action === "scopeChanged"
62
+ ? `\${byName} ${t(spec.word)} \${onName} \${role}`
63
+ : spec.needsOn
64
+ ? `\${byName} ${t(spec.word)} \${onName}`
65
+ : `\${byName} ${t(spec.word)}`;
66
+ const role = newScope ? t(newScope.toUpperCase()) : "";
67
+ const template = ((youKey && translated(youKey)) || translated(spec.key) || fallback)
68
+ .replace("${role}", role)
69
+ .trim();
70
+
71
+ // A missing name reads "User" in the localized sentence. Not `serverText`: for an SDK-parsed
72
+ // action that is the SDK's English "%s kicked %s" with the empty name left blank.
73
+ const byName = by || "User";
74
+ return sentenceWithNames(template, spec.needsOn ? { byName, onName: on || "User" } : { byName });
75
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Null-safe identity checks for the message list's replace-in-place paths (plan D2).
3
+ *
4
+ * The list used to match `msg.getId() == edited.getId()` and `msg["muid"] == edited["muid"]`
5
+ * directly, so a message with no id (an unsent row) matched the first other row with no id
6
+ * (`undefined == undefined`), and a message with no muid matched any row without one. Two
7
+ * missing identities are never the same message.
8
+ */
9
+
10
+ function present(value: unknown): value is string | number {
11
+ return value !== undefined && value !== null && value !== "" && value !== 0 && value !== "0";
12
+ }
13
+
14
+ function idOf(message: any): unknown {
15
+ if (!message) return undefined;
16
+ return typeof message.getId === "function" ? message.getId() : message.id;
17
+ }
18
+
19
+ function muidOf(message: any): unknown {
20
+ if (!message) return undefined;
21
+ return message["muid"] ?? (typeof message.getMuid === "function" ? message.getMuid() : undefined);
22
+ }
23
+
24
+ /** Same server id, and both actually have one. Loose compare: ids arrive as numbers or strings. */
25
+ export function sameMessageById(a: any, b: any): boolean {
26
+ const left = idOf(a);
27
+ const right = idOf(b);
28
+ // eslint-disable-next-line eqeqeq
29
+ return present(left) && present(right) && left == right;
30
+ }
31
+
32
+ /** Same muid, and both actually have one. */
33
+ export function sameMessageByMuid(a: any, b: any): boolean {
34
+ const left = muidOf(a);
35
+ const right = muidOf(b);
36
+ // eslint-disable-next-line eqeqeq
37
+ return present(left) && present(right) && left == right;
38
+ }
@@ -4,6 +4,7 @@ import Markdown from 'react-native-markdown-display';
4
4
  import { CometChat } from '@cometchat/chat-sdk-react-native';
5
5
  import { CometChatCardView } from '@cometchat/cards-react-native';
6
6
  import { useTheme } from '../../../theme';
7
+ import { CODE_DIRECTION } from '../../helper/layoutDirection';
7
8
  import { CometChatTheme } from '../../../theme/type';
8
9
  import { CometChatUIEventHandler, CometChatUIEvents } from '../../events';
9
10
 
@@ -56,7 +57,8 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
56
57
  backgroundColor: bubbleStyle?.containerStyle?.backgroundColor || 'transparent',
57
58
  borderRadius: bubbleStyle?.containerStyle?.borderRadius || theme.spacing.radius.r3,
58
59
  minWidth: bubbleStyle?.containerStyle?.minWidth || 90,
59
- alignSelf: bubbleStyle?.containerStyle?.alignSelf || 'flex-start',
60
+ // Fill the bubble (it gets fillWidth): markdown has no natural width to shrink to.
61
+ alignSelf: bubbleStyle?.containerStyle?.alignSelf || 'stretch',
60
62
  maxWidth: '100%',
61
63
  overflow: 'hidden',
62
64
  ...bubbleStyle?.containerStyle,
@@ -100,6 +102,7 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
100
102
  padding: theme.spacing.padding.p0_5,
101
103
  },
102
104
  code_block: {
105
+ ...CODE_DIRECTION,
103
106
  backgroundColor: theme.color.background3,
104
107
  color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
105
108
  borderRadius: theme.spacing.radius.r2,
@@ -107,6 +110,7 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
107
110
  fontFamily: 'monospace',
108
111
  },
109
112
  fence: {
113
+ ...CODE_DIRECTION,
110
114
  backgroundColor: theme.color.background3,
111
115
  color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
112
116
  borderRadius: theme.spacing.radius.r2,
@@ -137,7 +141,7 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
137
141
  padding: 0,
138
142
  },
139
143
  th: {
140
- borderRightWidth: 1,
144
+ borderEndWidth: 1,
141
145
  borderBottomWidth: 1,
142
146
  borderColor: theme.color.borderDefault,
143
147
  backgroundColor: theme.color.background3,
@@ -148,10 +152,10 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
148
152
  fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
149
153
  margin: 0,
150
154
  borderTopWidth: 0,
151
- borderLeftWidth: 0,
155
+ borderStartWidth: 0,
152
156
  },
153
157
  td: {
154
- borderRightWidth: 1,
158
+ borderEndWidth: 1,
155
159
  borderBottomWidth: 1,
156
160
  borderColor: theme.color.borderDefault,
157
161
  backgroundColor: theme.color.background1,
@@ -161,7 +165,7 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
161
165
  fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
162
166
  margin: 0,
163
167
  borderTopWidth: 0,
164
- borderLeftWidth: 0,
168
+ borderStartWidth: 0,
165
169
  },
166
170
  tr: {
167
171
  borderBottomWidth: 0,
@@ -219,9 +223,9 @@ const CometChatAIAssistantMessageBubble: React.FC<CometChatAIAssistantMessageBub
219
223
  color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
220
224
  },
221
225
  blockquote: {
222
- borderLeftWidth: 3,
223
- borderLeftColor: theme.color.borderDefault,
224
- paddingLeft: theme.spacing.padding.p2,
226
+ borderStartWidth: 3,
227
+ borderStartColor: theme.color.borderDefault,
228
+ paddingStart: theme.spacing.padding.p2,
225
229
  color: theme.color.textSecondary,
226
230
  },
227
231
  link: {
@@ -21,7 +21,7 @@ export const getAttachmentPreviewStyle = (
21
21
  removeButton: {
22
22
  position: 'absolute' as const,
23
23
  top: 4,
24
- right: 4,
24
+ end: 4,
25
25
  width: 18,
26
26
  height: 18,
27
27
  borderRadius: 9,
@@ -11,6 +11,7 @@ import {
11
11
  import { useTheme } from '../../../theme';
12
12
  import { useCompTheme } from '../../../theme/hook';
13
13
  import { CometChatTheme } from '../../../theme/type';
14
+ import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
14
15
  import { SelectedAttachment } from '../../modals/SelectedAttachment';
15
16
  import { deepMerge } from '../../helper/helperFunctions';
16
17
 
@@ -36,6 +37,7 @@ export const CometChatAttachmentPreviewItem = ({
36
37
  style,
37
38
  }: CometChatAttachmentPreviewItemProps) => {
38
39
  const theme = useTheme();
40
+ const { t } = useCometChatTranslation();
39
41
  const compTheme = useCompTheme();
40
42
  const s = deepMerge(
41
43
  theme.attachmentPreviewItemStyles ?? {},
@@ -197,7 +199,7 @@ export const CometChatAttachmentPreviewItem = ({
197
199
  alignItems: 'center',
198
200
  }}
199
201
  accessibilityRole="button"
200
- accessibilityLabel="Retry upload"
202
+ accessibilityLabel={t("ATTACHMENT_RETRY")}
201
203
  >
202
204
  <Text style={{ fontSize: theme.typography.heading2.regular.fontSize, color: theme.color.error }}>
203
205
  {'⚠'}
@@ -238,7 +240,7 @@ export const CometChatAttachmentPreviewItem = ({
238
240
  style={[{
239
241
  position: 'absolute',
240
242
  top: theme.spacing.spacing.s1,
241
- right: theme.spacing.spacing.s1,
243
+ end: theme.spacing.spacing.s1,
242
244
  width: theme.spacing.spacing.s4,
243
245
  height: theme.spacing.spacing.s4,
244
246
  borderRadius: theme.spacing.radius.r2,
@@ -247,7 +249,7 @@ export const CometChatAttachmentPreviewItem = ({
247
249
  alignItems: 'center',
248
250
  }, s.removeButtonStyle]}
249
251
  accessibilityRole="button"
250
- accessibilityLabel="Remove attachment"
252
+ accessibilityLabel={t("ATTACHMENT_REMOVE")}
251
253
  >
252
254
  <Text
253
255
  style={{