@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
@@ -60,6 +60,14 @@ import { MessageEvents } from "../shared/events/messages";
60
60
  import { CometChatTextFormatter } from "../shared/formatters/CometChatTextFormatter";
61
61
  import { applyRawFormatters } from "../shared/formatters/applyRawFormatters";
62
62
  import { buildPinnedMessagesRequest } from "../shared/utils/PinnedMessagesHelper";
63
+ import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection } from "../shared/helper/layoutDirection";
64
+ import { readListPage } from "../shared/offline/twoPhase";
65
+ import { mediaActionSource, notifyMediaUnavailable } from "../shared/offline/media";
66
+ import { useOfflineSessionEnded } from "../shared/offline/useOfflineSessionEnded";
67
+ import { useOfflineReconnect } from "../shared/offline/useOfflineReconnect";
68
+ import { ConnectStateView } from "../shared/offline/OfflineViews";
69
+ import { OFFLINE_STRING_KEYS } from "../shared/offline/notices";
70
+ import { CONTRACT_IDS } from "../shared/offline/stateContract";
63
71
 
64
72
  /**
65
73
  * The options this panel is willing to show, as an ALLOW-LIST.
@@ -104,6 +112,8 @@ const textOf = (message: CometChat.BaseMessage): string => {
104
112
  };
105
113
 
106
114
  export interface CometChatPinnedMessagesInterface {
115
+ /** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
116
+ layoutDirection?: "ltr" | "rtl";
107
117
  /** 1-1 conversation. Mutually exclusive with `group`. */
108
118
  user?: CometChat.User;
109
119
  /** Group conversation. Mutually exclusive with `user`. */
@@ -176,6 +186,8 @@ export const CometChatPinnedMessages = (props: CometChatPinnedMessagesInterface)
176
186
  title,
177
187
  style,
178
188
  } = props;
189
+ // ENG-41333: own setting → enclosing component → global; drives the root and the context.
190
+ const direction = useComponentLayoutDirection(props.layoutDirection);
179
191
 
180
192
  const theme = useTheme() as CometChatTheme;
181
193
  const compTheme = useCompTheme();
@@ -209,6 +221,11 @@ export const CometChatPinnedMessages = (props: CometChatPinnedMessagesInterface)
209
221
  value => { if (mounted.current) setStateRaw(value); },
210
222
  []
211
223
  );
224
+ // Offline ON: nothing of the old session stays on screen (UIK-LIFE-01).
225
+ useOfflineSessionEnded(() => {
226
+ setMessages([]);
227
+ setState("empty");
228
+ });
212
229
 
213
230
  /** Long-press sheet state, mirroring what CometChatMessageList keeps. */
214
231
  const [sheetOptions, setSheetOptions] = useState<CometChatMessageOption[]>([]);
@@ -239,6 +256,14 @@ export const CometChatPinnedMessages = (props: CometChatPinnedMessagesInterface)
239
256
  * can only come back empty again.
240
257
  */
241
258
  const exhausted = useRef(false);
259
+ /**
260
+ * Offline ON (D84): "Connect to load messages" is up because the device was not connected and nothing is
261
+ * saved: the panel reads again once, by itself, when the connection is back. Any other error
262
+ * is not read again.
263
+ */
264
+ const reloadOnConnect = useRef(false);
265
+ /** Offline ON (D84 rule 3): the error state is "Connect to load messages" (not the error view) while this is set. */
266
+ const [offlineMiss, setOfflineMiss] = useState(false);
242
267
 
243
268
  /**
244
269
  * The ordinary messages request, filtered to pinned rows. Paging is the ordinary
@@ -261,7 +286,32 @@ export const CometChatPinnedMessages = (props: CometChatPinnedMessagesInterface)
261
286
  try {
262
287
  // fetchPrevious(), not fetchNext() — "previous" is older, which is the direction
263
288
  // this list scrolls. Same call CometChatMessageList makes to load history.
264
- const rows = await request.current.fetchPrevious();
289
+ // Offline ON: the SDK's two-phase read; offline past the cache it answers with the
290
+ // device's page instead of an error (U6). Offline OFF: today's Promise fetch.
291
+ const { rows, offline } = await readListPage<CometChat.BaseMessage>(request.current, "previous");
292
+ if (offline) {
293
+ // A cached page never ends the list (BEH-READ-09b, BEH-PIN-02); a retry reads on.
294
+ if (rows.length > 0) {
295
+ setMessages(prev => {
296
+ const seen = new Set(prev.map(m => String(m.getId())));
297
+ return [...prev, ...rows.filter(r => !seen.has(String(r.getId())))];
298
+ });
299
+ setState("loaded");
300
+ reloadOnConnect.current = false;
301
+ setOfflineMiss(false);
302
+ } else {
303
+ // Nothing on the device and not connected: the offline state (D84), not an empty panel.
304
+ setState(prev => {
305
+ if (prev !== "loading") return prev;
306
+ reloadOnConnect.current = true;
307
+ return "error";
308
+ });
309
+ setOfflineMiss(true);
310
+ }
311
+ return;
312
+ }
313
+ reloadOnConnect.current = false;
314
+ setOfflineMiss(false);
265
315
  if (rows.length > 0) {
266
316
  // Dedupe on append (ENG-38891). A realtime pin/save PREPENDS its row the moment the
267
317
  // event lands; the same message then comes back inside a later fetched page, and a
@@ -279,6 +329,8 @@ export const CometChatPinnedMessages = (props: CometChatPinnedMessagesInterface)
279
329
  // Log it — a bare `catch {}` hides client-side rejections that never reach the
280
330
  // network, leaving a generic error screen and an empty network log to debug from.
281
331
  console.error("CometChatPinnedMessages: failed to fetch pinned messages", e);
332
+ reloadOnConnect.current = false;
333
+ setOfflineMiss(false);
282
334
  setState(prev => (prev === "loading" ? "error" : prev));
283
335
  } finally {
284
336
  fetching.current = false;
@@ -319,6 +371,13 @@ export const CometChatPinnedMessages = (props: CometChatPinnedMessagesInterface)
319
371
  loadNext();
320
372
  }, [buildRequest, loadNext]);
321
373
 
374
+ // D84 rule 8: the one read again of the offline state.
375
+ useOfflineReconnect(() => {
376
+ if (!reloadOnConnect.current) return;
377
+ reloadOnConnect.current = false;
378
+ reload();
379
+ });
380
+
322
381
  useEffect(() => {
323
382
  CometChat.getLoggedinUser()
324
383
  .then(u => {
@@ -618,7 +677,15 @@ export const CometChatPinnedMessages = (props: CometChatPinnedMessagesInterface)
618
677
  const onShare = (message: CometChat.BaseMessage) => {
619
678
  const attachment =
620
679
  message instanceof CometChat.MediaMessage ? message.getAttachment() : undefined;
621
- const fileUrl = attachment?.getUrl() ?? "";
680
+ let fileUrl = attachment?.getUrl() ?? "";
681
+ // Offline ON: share the saved file, never re-fetch the URL (BEH-MEDIA-18).
682
+ const source = attachment ? mediaActionSource(attachment) : null;
683
+ if (source?.kind === "unavailable") {
684
+ closeSheet();
685
+ notifyMediaUnavailable();
686
+ return;
687
+ }
688
+ if (source?.kind === "local") fileUrl = source.uri;
622
689
  const shareObj = {
623
690
  // Plain text: the share target is another app, which cannot read our wire format.
624
691
  message: stripRichText(applyRawFormatters(textOf(message), textFormatters)),
@@ -803,7 +870,8 @@ export const CometChatPinnedMessages = (props: CometChatPinnedMessagesInterface)
803
870
  };
804
871
 
805
872
  return (
806
- <View style={styles.containerStyle}>
873
+ <LayoutDirectionContext.Provider value={direction}>
874
+ <View style={[styles.containerStyle, directionStyle(direction)]}>
807
875
  {/* Back arrow LEADING the title, matching Group Info / User Info. This is a pushed
808
876
  full-screen route, not a modal, so a leading back is the right affordance — a
809
877
  trailing ✕ read as "dismiss a sheet". */}
@@ -858,6 +926,16 @@ export const CometChatPinnedMessages = (props: CometChatPinnedMessagesInterface)
858
926
  }
859
927
  />
860
928
  ) : state === "error" ? (
929
+ offlineMiss ? (
930
+ // D84 rule 3: offline with nothing saved: the offline state, no Retry; it loads by itself on reconnect.
931
+ <ConnectStateView
932
+ testID={CONTRACT_IDS.emptyConnectToLoad}
933
+ title={t(OFFLINE_STRING_KEYS.connectToLoadMessages)}
934
+ containerStyle={styles.errorStateStyle?.containerStyle}
935
+ titleStyle={styles.errorStateStyle?.titleStyle}
936
+ subtitleStyle={styles.errorStateStyle?.subTitleStyle}
937
+ />
938
+ ) :
861
939
  // The house error state, same as the conversation list: error-state illustration,
862
940
  // Oops! / went wrong / try again, and a Retry button. A bare sentence in the
863
941
  // default text style was the only thing here before, which read as a broken
@@ -960,5 +1038,6 @@ export const CometChatPinnedMessages = (props: CometChatPinnedMessagesInterface)
960
1038
 
961
1039
  {ToastElement}
962
1040
  </View>
1041
+ </LayoutDirectionContext.Provider>
963
1042
  );
964
1043
  };
@@ -67,13 +67,13 @@ export const getPinnedMessagesStyleLight = (
67
67
  flexDirection: "row",
68
68
  alignItems: "center",
69
69
  paddingTop: spacing.padding.p4,
70
- paddingLeft: spacing.padding.p2,
70
+ paddingStart: spacing.padding.p2,
71
71
  paddingBottom: spacing.padding.p2,
72
72
  },
73
73
  titleStyle: {
74
74
  ...typography.heading1.bold,
75
75
  color: color.textPrimary,
76
- paddingLeft: spacing.padding.p1,
76
+ paddingStart: spacing.padding.p1,
77
77
  },
78
78
  closeButtonIconStyle: {
79
79
  tintColor: color.iconPrimary,
@@ -115,7 +115,7 @@ export const getPinnedMessagesStyleLight = (
115
115
  senderNameStyle: {
116
116
  ...typography.body.medium,
117
117
  color: color.textHighlight,
118
- marginLeft: spacing.margin.m2,
118
+ marginStart: spacing.margin.m2,
119
119
  },
120
120
  separatorStyle: {
121
121
  ...typography.caption1.regular,
@@ -134,11 +134,11 @@ export const getPinnedMessagesStyleLight = (
134
134
  width: 14,
135
135
  },
136
136
  savedIndicatorContainerStyle: {
137
- marginLeft: spacing.margin.m1,
137
+ marginStart: spacing.margin.m1,
138
138
  },
139
139
  bubbleContainerStyle: {
140
140
  // Lines the bubble up under the sender name rather than the avatar.
141
- marginLeft: spacing.spacing.s10,
141
+ marginStart: spacing.spacing.s10,
142
142
  },
143
143
  },
144
144
  emptyStateStyle: {
@@ -85,6 +85,8 @@ type PasteMediaEventData = Readonly<{
85
85
 
86
86
  export interface NativeProps extends ViewProps {
87
87
  placeholder?: string;
88
+ /** ENG-41384: kit direction, for iOS (Android gets it from the layout). */
89
+ isRTL?: boolean;
88
90
  editable?: boolean;
89
91
  maxHeight?: Double;
90
92
  numberOfLines?: Int32;
@@ -10,6 +10,7 @@ import type {
10
10
  InlineStyleKey,
11
11
  } from './types';
12
12
  import RichTextEditorViewNative from './RichTextEditorViewNativeComponent';
13
+ import { useKitRTL } from '../shared/helper/layoutDirection';
13
14
 
14
15
  // Command constants
15
16
  const COMMANDS = {
@@ -145,6 +146,7 @@ export interface RichTextEditorPropsExtended extends RichTextEditorProps {
145
146
 
146
147
  const RichTextEditor = forwardRef<RichTextEditorRef, RichTextEditorPropsExtended>((props, ref) => {
147
148
  const nativeRef = useRef<React.ElementRef<typeof RichTextEditorViewNative>>(null);
149
+ const isRTL = useKitRTL(); // ENG-41384: the iOS editor needs the kit direction told to it.
148
150
  const [height, setHeight] = useState<number | undefined>(undefined);
149
151
  // Latest mention ranges reported by native, in plain-text coordinates. Native owns them
150
152
  // because editing shifts them; it re-reports on every content change.
@@ -386,6 +388,7 @@ const RichTextEditor = forwardRef<RichTextEditorRef, RichTextEditorPropsExtended
386
388
  accessibilityLabel={props.accessibilityLabel}
387
389
  style={combinedStyle}
388
390
  placeholder={props.placeholder}
391
+ isRTL={isRTL}
389
392
  initialContentJson={props.initialContent ? JSON.stringify(props.initialContent) : undefined}
390
393
  editable={props.readOnly !== undefined ? !props.readOnly : true}
391
394
  maxHeight={props.maxHeight}
@@ -56,6 +56,7 @@ import {
56
56
  sourceLabelFor,
57
57
  subtitlePrefixNameFor,
58
58
  SavedMessageSource,
59
+ sentAtDesc,
59
60
  } from "../shared/utils/SavedMessagesHelper";
60
61
  import {
61
62
  carryPinSaveAttrs,
@@ -67,6 +68,14 @@ import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandle
67
68
  import { MessageEvents } from "../shared/events/messages";
68
69
  import { CometChatTextFormatter } from "../shared/formatters/CometChatTextFormatter";
69
70
  import { applyRawFormatters } from "../shared/formatters/applyRawFormatters";
71
+ import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection } from "../shared/helper/layoutDirection";
72
+ import { SenderLabel } from "../shared/views/SenderLabel";
73
+ import { readListPage } from "../shared/offline/twoPhase";
74
+ import { useOfflineSessionEnded } from "../shared/offline/useOfflineSessionEnded";
75
+ import { useOfflineReconnect } from "../shared/offline/useOfflineReconnect";
76
+ import { ConnectStateView } from "../shared/offline/OfflineViews";
77
+ import { OFFLINE_STRING_KEYS } from "../shared/offline/notices";
78
+ import { CONTRACT_IDS } from "../shared/offline/stateContract";
70
79
 
71
80
  /**
72
81
  * Module-level rich text formatter — reused across renders (no GC churn), mirroring
@@ -76,6 +85,8 @@ import { applyRawFormatters } from "../shared/formatters/applyRawFormatters";
76
85
  const savedRichTextFormatter = new CometChatRichTextFormatter();
77
86
 
78
87
  export interface CometChatSavedMessagesInterface {
88
+ /** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
89
+ layoutDirection?: "ltr" | "rtl";
79
90
  /** Page size. Defaults to 30; the server caps the whole set at 100. */
80
91
  limit?: number;
81
92
  /**
@@ -133,6 +144,8 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
133
144
  title,
134
145
  style,
135
146
  } = props;
147
+ // ENG-41333: own setting → enclosing component → global; drives the root and the context.
148
+ const direction = useComponentLayoutDirection(props.layoutDirection);
136
149
 
137
150
  const theme = useTheme() as CometChatTheme;
138
151
 
@@ -181,6 +194,11 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
181
194
  value => { if (mounted.current) setStateRaw(value); },
182
195
  []
183
196
  );
197
+ // Offline ON: nothing of the old session stays on screen (UIK-LIFE-01).
198
+ useOfflineSessionEnded(() => {
199
+ setMessages([]);
200
+ setState("empty");
201
+ });
184
202
 
185
203
  /**
186
204
  * Long-press menu state. Anchored at the touch point via CometChatTooltipMenu —
@@ -208,6 +226,14 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
208
226
  * can only come back empty again.
209
227
  */
210
228
  const exhausted = useRef(false);
229
+ /**
230
+ * Offline ON (D84): "Connect to load messages" is up because the device was not connected and nothing is
231
+ * saved: the panel reads again once, by itself, when the connection is back. Any other error
232
+ * is not read again.
233
+ */
234
+ const reloadOnConnect = useRef(false);
235
+ /** Offline ON (D84 rule 3): the error state is "Connect to load messages" (not the error view) while this is set. */
236
+ const [offlineMiss, setOfflineMiss] = useState(false);
211
237
 
212
238
  if (request.current === null) {
213
239
  request.current = buildSavedMessagesRequest(limit, messagesRequestBuilder);
@@ -219,14 +245,39 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
219
245
  try {
220
246
  // fetchPrevious(), not fetchNext() — "previous" is older, which is the direction
221
247
  // this list scrolls. Same call CometChatMessageList makes to load history.
222
- const rows = await request.current.fetchPrevious();
248
+ // Offline ON: the SDK's two-phase read; offline past the cache it answers with the
249
+ // device's page instead of an error (U6). Offline OFF: today's Promise fetch.
250
+ const { rows, offline } = await readListPage<CometChat.BaseMessage>(request.current, "previous");
251
+ if (offline) {
252
+ // A cached page never ends the list (BEH-READ-09b, BEH-PIN-02); a retry reads on.
253
+ if (rows.length > 0) {
254
+ setMessages(prev => {
255
+ const seen = new Set(prev.map(m => String(m.getId())));
256
+ return [...prev, ...rows.filter(r => !seen.has(String(r.getId())))].sort(sentAtDesc);
257
+ });
258
+ setState("loaded");
259
+ reloadOnConnect.current = false;
260
+ setOfflineMiss(false);
261
+ } else {
262
+ // Nothing on the device and not connected: the offline state (D84), not an empty panel.
263
+ setState(prev => {
264
+ if (prev !== "loading") return prev;
265
+ reloadOnConnect.current = true;
266
+ return "error";
267
+ });
268
+ setOfflineMiss(true);
269
+ }
270
+ return;
271
+ }
272
+ reloadOnConnect.current = false;
273
+ setOfflineMiss(false);
223
274
  if (rows.length > 0) {
224
275
  // Dedupe on append (ENG-38891). A realtime pin/save PREPENDS its row the moment the
225
276
  // event lands; the same message then comes back inside a later fetched page, and a
226
277
  // plain concat lists it twice — which is how a five-pin cap rendered six rows.
227
278
  setMessages(prev => {
228
279
  const seen = new Set(prev.map(m => String(m.getId())));
229
- return [...prev, ...rows.filter(r => !seen.has(String(r.getId())))];
280
+ return [...prev, ...rows.filter(r => !seen.has(String(r.getId())))].sort(sentAtDesc);
230
281
  });
231
282
  setState("loaded");
232
283
  } else {
@@ -239,6 +290,8 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
239
290
  // rejected client-side before any request) was unreachable from outside a debugger.
240
291
  console.error("CometChatSavedMessages: failed to fetch saved messages", e);
241
292
  // An empty first page is "empty", not "error" — only a real rejection is.
293
+ reloadOnConnect.current = false;
294
+ setOfflineMiss(false);
242
295
  setState(prev => (prev === "loading" ? "error" : prev));
243
296
  } finally {
244
297
  fetching.current = false;
@@ -281,6 +334,13 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
281
334
  // the request from the builder captured at mount.
282
335
  }, [limit, messagesRequestBuilder, loadNext]);
283
336
 
337
+ // D84 rule 8: the one read again of the offline state.
338
+ useOfflineReconnect(() => {
339
+ if (!reloadOnConnect.current) return;
340
+ reloadOnConnect.current = false;
341
+ reload();
342
+ });
343
+
284
344
  useEffect(() => {
285
345
  CometChat.getLoggedinUser()
286
346
  .then(user => {
@@ -320,7 +380,8 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
320
380
  if (!message) return;
321
381
  setMessages(prev => {
322
382
  if (prev.some(m => sameMessageId(m.getId(), message.getId()))) return prev;
323
- return [message, ...prev];
383
+ // By sentAt, not at the top: saving an old message must not make it look newest.
384
+ return [message, ...prev].sort(sentAtDesc);
324
385
  });
325
386
  setState("loaded");
326
387
  };
@@ -431,7 +492,7 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
431
492
  showToast(t("MESSAGE_NO_LONGER_AVAILABLE") ?? "This message is no longer available.");
432
493
  return;
433
494
  }
434
- setMessages(prev => [message, ...prev]);
495
+ setMessages(prev => [message, ...prev].sort(sentAtDesc));
435
496
  setState("loaded");
436
497
  showToast(t("PIN_SAVE_GENERIC_ERROR") ?? "Something went wrong. Please try again.");
437
498
  });
@@ -489,7 +550,6 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
489
550
  loggedInUser.current?.getUid() ?? null,
490
551
  t("YOU") ?? "You"
491
552
  );
492
- const prefix = prefixName ? `${prefixName}: ` : "";
493
553
 
494
554
  const rawLabel = preview.text ?? (preview.labelKey ? (t(preview.labelKey) ?? "") : "");
495
555
 
@@ -604,14 +664,8 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
604
664
 
605
665
  return (
606
666
  <View style={localStyles.subtitleRow}>
607
- {prefix ? (
608
- <Text
609
- numberOfLines={1}
610
- style={itemStyle?.subtitleStyle}
611
- >
612
- {prefix}
613
- </Text>
614
- ) : null}
667
+ {/* A long name ellipsizes at 40%, as in the conversation list; short ones keep full width. */}
668
+ <SenderLabel name={prefixName} textStyle={itemStyle?.subtitleStyle} containerStyle={LABEL_LIMIT} />
615
669
  {preview.icon ? (
616
670
  <Icon
617
671
  name={preview.icon as IconName}
@@ -679,7 +733,8 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
679
733
  };
680
734
 
681
735
  return (
682
- <View style={styles.containerStyle}>
736
+ <LayoutDirectionContext.Provider value={direction}>
737
+ <View style={[styles.containerStyle, directionStyle(direction)]}>
683
738
  {/* Back arrow LEADING the title, matching Group Info / User Info. This is a pushed
684
739
  full-screen route, not a modal, so a leading back is the right affordance — a
685
740
  trailing ✕ read as "dismiss a sheet". */}
@@ -735,6 +790,16 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
735
790
  }
736
791
  />
737
792
  ) : state === "error" ? (
793
+ offlineMiss ? (
794
+ // D84 rule 3: offline with nothing saved: the offline state, no Retry; it loads by itself on reconnect.
795
+ <ConnectStateView
796
+ testID={CONTRACT_IDS.emptyConnectToLoad}
797
+ title={t(OFFLINE_STRING_KEYS.connectToLoadMessages)}
798
+ containerStyle={styles.errorStateStyle?.containerStyle}
799
+ titleStyle={styles.errorStateStyle?.titleStyle}
800
+ subtitleStyle={styles.errorStateStyle?.subTitleStyle}
801
+ />
802
+ ) :
738
803
  // The house error state, same as the conversation list: error-state illustration,
739
804
  // Oops! / went wrong / try again, and a Retry button. A bare sentence in the
740
805
  // default text style was the only thing here before, which read as a broken
@@ -804,6 +869,7 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
804
869
 
805
870
  {ToastElement}
806
871
  </View>
872
+ </LayoutDirectionContext.Provider>
807
873
  );
808
874
  };
809
875
 
@@ -811,6 +877,8 @@ export const CometChatSavedMessages = (props: CometChatSavedMessagesInterface) =
811
877
  * Static layout only — nothing here depends on the theme. Anything theme-derived
812
878
  * lives in ./style.ts (or conversationStyles, for the row chrome) and is merged in.
813
879
  */
880
+ const LABEL_LIMIT = { maxWidth: "40%" } as const;
881
+
814
882
  const localStyles = StyleSheet.create({
815
883
  // Block-preview styling, matching CometChatConversations so a saved row and a
816
884
  // conversation row render the same message identically.
@@ -843,7 +911,7 @@ const localStyles = StyleSheet.create({
843
911
  width: 3,
844
912
  borderRadius: 1.5,
845
913
  marginVertical: 3,
846
- marginLeft: 4,
914
+ marginStart: 4,
847
915
  },
848
916
  blockquoteText: {
849
917
  flex: 1,
@@ -63,13 +63,13 @@ export const getSavedMessagesStyleLight = (
63
63
  flexDirection: "row",
64
64
  alignItems: "center",
65
65
  paddingTop: spacing.padding.p4,
66
- paddingLeft: spacing.padding.p2,
66
+ paddingStart: spacing.padding.p2,
67
67
  paddingBottom: spacing.padding.p2,
68
68
  },
69
69
  titleStyle: {
70
70
  ...typography.heading1.bold,
71
71
  color: color.textPrimary,
72
- paddingLeft: spacing.padding.p1,
72
+ paddingStart: spacing.padding.p1,
73
73
  },
74
74
  closeButtonIconStyle: {
75
75
  tintColor: color.iconPrimary,
@@ -82,7 +82,7 @@ export const getSavedMessagesStyleLight = (
82
82
  width: spacing.spacing.s4,
83
83
  },
84
84
  previewIconContainerStyle: {
85
- marginRight: spacing.margin.m1,
85
+ marginEnd: spacing.margin.m1,
86
86
  },
87
87
  menuIconStyle: {
88
88
  tintColor: color.iconSecondary,