@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
@@ -8,6 +8,7 @@ import {
8
8
  ImageSourcePropType,
9
9
  ImageStyle,
10
10
  Platform,
11
+ RefreshControl,
11
12
  StyleProp,
12
13
  Text,
13
14
  TextStyle,
@@ -30,6 +31,23 @@ import {
30
31
  import Header from "./Header";
31
32
  import styles from "./styles";
32
33
  import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
34
+ import { withSectionHeaders } from "./sectionLetter";
35
+ import { TEXT_START } from "../../helper/layoutDirection";
36
+ import { isOfflineOn, offlineSdk, sdkConnected } from "../../offline/gate";
37
+ import { OfflineHub } from "../../offline/OfflineHub";
38
+ import { appendUnique, fetchTwoPhase, mergeSnapshotPage } from "../../offline/twoPhase";
39
+ import {
40
+ applyFirstServerPage,
41
+ mergeCachedFirstPage,
42
+ mergeFirstServerPage,
43
+ isFilteredConversationRequest,
44
+ keepUnsentPreviews,
45
+ reconcileSyncPage,
46
+ } from "../../offline/conversations";
47
+ import { ConnectStateView, ConnectToLoadMore } from "../../offline/OfflineViews";
48
+ import { OFFLINE_STRING_KEYS } from "../../offline/notices";
49
+ import { CONTRACT_IDS } from "../../offline/stateContract";
50
+ import { probeFrame } from "../../offline/frameProbe";
33
51
 
34
52
  export interface CometChatListActionsInterface {
35
53
  updateList: (prop: any) => void;
@@ -117,9 +135,22 @@ export interface CometChatListProps {
117
135
  hideHeader?: boolean;
118
136
  title?: string;
119
137
  EmptyView?: React.FC;
138
+ /**
139
+ * Offline ON only: whether `EmptyView` is the integrator's own. A list wrapper that always
140
+ * passes a default empty view sets this so the kit's "Connect to search" state is not hidden by
141
+ * the wrapper's default but is by the integrator's. Defaults to `!!EmptyView`.
142
+ */
143
+ customEmptyView?: boolean;
120
144
  emptyStateText?: string;
121
145
  errorStateText?: string;
122
146
  ErrorView?: React.FC;
147
+ /**
148
+ * Offline ON only: whether `ErrorView` is the integrator's own, which then shows instead of the
149
+ * kit's "Connect to load ..." state (D84 rule 3). Defaults to `!!ErrorView`.
150
+ */
151
+ customErrorView?: boolean;
152
+ /** Offline ON only: localization key of the "Connect to load ..." text (default from `listItemKey`). */
153
+ connectToLoadKey?: string;
123
154
  LoadingView?: React.FC;
124
155
  requestBuilder?: any;
125
156
  searchRequestBuilder?: any;
@@ -129,6 +160,8 @@ export interface CometChatListProps {
129
160
  onError?: (error: CometChat.CometChatException) => void;
130
161
  onBack?: (() => void) | undefined;
131
162
  listItemKey: "uid" | "guid" | "conversationId";
163
+ /** Automation identifier for each row (`testID`), e.g. the state contract's conversation row. */
164
+ itemTestID?: (item: any) => string | undefined;
132
165
  listStyle?: DeepPartial<CometChatListStylesInterface>;
133
166
  hideSubmitButton?: boolean;
134
167
  statusIndicatorType?: (item: any) => CometChatStatusIndicatorInterface["type"] | null;
@@ -148,6 +181,13 @@ export interface CometChatListProps {
148
181
  onSearchBarClicked?: () => void;
149
182
  }
150
183
 
184
+ /** The "Connect to load ..." text of a list that could not load offline with nothing on screen. */
185
+ function connectToLoadKeyFor(listItemKey: "uid" | "guid" | "conversationId"): string {
186
+ if (listItemKey === "conversationId") return OFFLINE_STRING_KEYS.connectToLoadChats;
187
+ if (listItemKey === "guid") return OFFLINE_STRING_KEYS.connectToLoadGroups;
188
+ return OFFLINE_STRING_KEYS.connectToLoadUsers;
189
+ }
190
+
151
191
  let lastCall: any;
152
192
  let lastReject: Function;
153
193
 
@@ -183,9 +223,12 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
183
223
  hideSearch = false,
184
224
  title = "Title",
185
225
  EmptyView,
226
+ customEmptyView,
186
227
  emptyStateText = t("NO_USERS_FOUND"),
187
228
  errorStateText = t("SOMETHING_WRONG"),
188
229
  ErrorView,
230
+ customErrorView,
231
+ connectToLoadKey,
189
232
  LoadingView,
190
233
  requestBuilder,
191
234
  hideHeader,
@@ -196,6 +239,7 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
196
239
  onError,
197
240
  onBack,
198
241
  listItemKey = "uid",
242
+ itemTestID,
199
243
  listStyle,
200
244
  hideSubmitButton,
201
245
  statusIndicatorType,
@@ -252,7 +296,41 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
252
296
  const selectionEffectDidMountRef = useRef(false);
253
297
 
254
298
  const [list, setList] = useState<any[]>([]);
299
+ // Dev and sample builds only: the row list of every committed frame (TEST-PLAN §3.3).
300
+ useEffect(() => {
301
+ probeFrame(`list:${listItemKey}`, () =>
302
+ list.map((item: any) => ({ key: String(item?.[listItemKey] ?? ""), id: 0, state: "", item }))
303
+ );
304
+ }, [list, listItemKey]);
255
305
  const listRef = useRef<any[]>([]);
306
+ // Offline (ON path) state; untouched while offline is off.
307
+ const offlinePathUsedRef = useRef(false);
308
+ const offlineListRef = useRef<any[]>([]);
309
+ const offlineOpGenRef = useRef(0);
310
+ const offlineSearchTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
311
+ // A read past the cache failed offline and closed paging (conversations): the reconnect
312
+ // reopens it and loads that page once. Count of offline reads (and read-on loops) in flight.
313
+ const pagingClosedOfflineRef = useRef(false);
314
+ const offlineReadsInFlightRef = useRef(0);
315
+ /** A filtered chat list's re-read after a sync page is in flight: later sync pages start no second one. */
316
+ const syncRereadRef = useRef(false);
317
+ // D84 (offline ON): the error view, or the offline state, is up because a load failed with
318
+ // nothing on screen. "offline" = the device was not connected: a reconnect loads it again,
319
+ // once. "other" = any other error: never loaded again by itself. null = neither is up.
320
+ const errorViewRef = useRef<"offline" | "other" | null>(null);
321
+ // Which offline state shows over an empty list (D84 rule 3 and 7), if any: "load" = "Connect to
322
+ // load ..." (a plain list, error view slot), "search" = "Connect to search" (a keyword, empty
323
+ // view slot). Never set with offline off.
324
+ const [offlineState, setOfflineState] = useState<"none" | "load" | "search">("none");
325
+ // A reload the kit starts by itself (cache reset) goes through `reload()`: this makes it quiet
326
+ // while rows are shown, as the other kit-started re-reads are. Read once, synchronously.
327
+ const automaticReloadRef = useRef(false);
328
+ // A load-more asked for while an offline read was in flight: run once when the reads settle,
329
+ // so paging never waits for a second scroll (UIK-READ-03). Offline ON only; OFF keeps today's drop.
330
+ const deferredLoadMoreRef = useRef(false);
331
+ const [deferredLoadMoreTick, setDeferredLoadMoreTick] = useState(0);
332
+ const [offlineFooter, setOfflineFooter] = useState<"none" | "connect">("none");
333
+ const [refreshing, setRefreshing] = useState(false);
256
334
  const [dataLoadingStatus, setDataLoadingStatus] = useState<string>(LOADING);
257
335
 
258
336
  // Keep listRef in sync with list state for use in imperative methods
@@ -305,6 +383,15 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
305
383
  };
306
384
 
307
385
  const getSearch = (builtReq: any) => {
386
+ if (isOfflineOn()) {
387
+ // A keyword has no cache (BEH-SNAP-04): server only; offline with nothing saved is the error view (D83).
388
+ if (offlineSearchTimer.current) clearTimeout(offlineSearchTimer.current);
389
+ offlineSearchTimer.current = setTimeout(() => {
390
+ offlineSearchTimer.current = null;
391
+ void fetchListOffline(builtReq, true);
392
+ }, 500);
393
+ return;
394
+ }
308
395
  getList(builtReq)
309
396
  .then((newlist: any) => {
310
397
  setDataLoadingStatus(NO_DATA_FOUND);
@@ -329,24 +416,65 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
329
416
  return markedItems;
330
417
  };
331
418
 
419
+ // D5: the connection listener below is registered once, so it reads the integrator's
420
+ // CURRENT request builder (and onListFetched) through refs instead of the first render's.
421
+ const requestBuilderRef = useRef(requestBuilder);
422
+ requestBuilderRef.current = requestBuilder;
423
+ const onListFetchedRef = useRef(props.onListFetched);
424
+ onListFetchedRef.current = props.onListFetched;
425
+
332
426
  useEffect(() => {
333
427
  CometChat.addConnectionListener(
334
428
  connectionListenerId,
335
429
  new CometChat.ConnectionListener({
336
430
  onConnected: () => {
337
- if (requestBuilder) {
431
+ const offlineOn = isOfflineOn(); // gate read once for this reconnect
432
+ // Offline ON: conversations wait for the SDK's sync page (no fetch, UIK-SYNC-01).
433
+ if (offlineOn && listItemKey === "conversationId") {
434
+ // Paging a read past the cache closed offline opens again, and the load the user
435
+ // asked for runs now, once: its scroll trigger is spent (R5).
436
+ // D83 rule 4: so does an error view shown because the device was offline (not any other error).
437
+ if (pagingClosedOfflineRef.current || errorViewRef.current === "offline") {
438
+ const errorViewUp = errorViewRef.current === "offline" && listRef.current.length === 0;
439
+ pagingClosedOfflineRef.current = false;
440
+ errorViewRef.current = null;
441
+ setOfflineState("none");
442
+ setOfflineFooter("none");
443
+ setHasMoreData(true);
444
+ if (offlineReadsInFlightRef.current === 0) {
445
+ if (errorViewUp) setDataLoadingStatus(LOADING);
446
+ void readNextOfflineRef.current(listHandlerRef.current, listRef.current.length === 0);
447
+ }
448
+ }
449
+ return;
450
+ }
451
+ // D83 rule 4: an error view shown for any other error is not loaded again by itself.
452
+ if (offlineOn && errorViewRef.current === "other") return;
453
+ const currentBuilder = requestBuilderRef.current;
454
+ if (currentBuilder) {
338
455
  if (searchInputRef.current)
339
- listHandlerRef.current = requestBuilder
456
+ listHandlerRef.current = currentBuilder
340
457
  .setSearchKeyword(searchInputRef.current)
341
458
  .build();
342
- else listHandlerRef.current = requestBuilder.build();
459
+ else listHandlerRef.current = currentBuilder.build();
460
+ }
461
+ if (offlineOn) {
462
+ // Today's trigger, two-phase so the list never blanks. Over an error view it is the
463
+ // one reload of rule 4: it shows loading, and fails loudly again if it must.
464
+ if (errorViewRef.current === "offline" && listRef.current.length === 0) {
465
+ errorViewRef.current = null;
466
+ setOfflineState("none");
467
+ setDataLoadingStatus(LOADING);
468
+ }
469
+ void fetchListOffline(listHandlerRef.current, true, true);
470
+ return;
343
471
  }
344
472
  getList(listHandlerRef.current)
345
473
  .then((newlist: any[]) => {
346
474
  setDataLoadingStatus(NO_DATA_FOUND);
347
475
  setList(newlist);
348
476
  setHasMoreData(true); // Reset pagination since we rebuilt the request
349
- props.onListFetched?.(newlist);
477
+ onListFetchedRef.current?.(newlist);
350
478
  })
351
479
  .catch((error) => {
352
480
  if (error && error["message"] === "Promise cancelled") {
@@ -465,6 +593,11 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
465
593
  * @param {boolean} throughKeyword - Pass true if wants to set only new users.
466
594
  */
467
595
  const handleList = (throughKeyword?: boolean) => {
596
+ // Offline ON: a load-more asked for during an offline read waits for it, then runs (not dropped).
597
+ if (!throughKeyword && offlineReadsInFlightRef.current > 0 && isOfflineOn()) {
598
+ if (hasMoreData) deferredLoadMoreRef.current = true;
599
+ return;
600
+ }
468
601
  // Prevent multiple fetches
469
602
  if (isLoadingMore || (!throughKeyword && !hasMoreData)) return;
470
603
  setIsLoadingMore(true);
@@ -487,6 +620,13 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
487
620
  setHasMoreData(true);
488
621
  }
489
622
 
623
+ if (isOfflineOn()) {
624
+ const firstPage = !!throughKeyword || list.length === 0;
625
+ if (listItemKey === "conversationId" && !firstPage) void readNextOffline(listHandlerRef.current, false);
626
+ else void fetchListOffline(listHandlerRef.current, firstPage, automaticReloadRef.current);
627
+ return;
628
+ }
629
+
490
630
  getList(listHandlerRef.current)
491
631
  .then((newlist: any[] = []) => {
492
632
  let finalList: any[] = [];
@@ -531,6 +671,273 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
531
671
  });
532
672
  };
533
673
 
674
+ const offlineKeyOf = (item: any) => String(item?.[listItemKey] ?? "");
675
+
676
+ /**
677
+ * One page, two-phase (README §3.3, offline ON only): the cached page paints first, the
678
+ * server page replaces the same slice; an offline read past the cache keeps what is shown
679
+ * ("Connect to load more"). Only an empty online server page ends pagination.
680
+ *
681
+ * A failure (D84):
682
+ * - rows on screen, not connected: the rows stay, no error view, no `onError` (rule 2); a
683
+ * load-more page shows its "Connect to load more" footer;
684
+ * - rows on screen, a real error: the rows stay and `onError` fires once (rule 5), unless the
685
+ * kit started the read itself (`automatic`: reconnect, sync page, cache reset);
686
+ * - nothing on screen, not connected: "Connect to search" for a keyword (rule 7, no `onError`),
687
+ * otherwise the kit's "Connect to load ..." state in the error view's place (rule 3, `onError`
688
+ * once; the app's own error view shows instead if it passed one);
689
+ * - nothing on screen, a real error: the error view and `onError` (rule 4).
690
+ *
691
+ * `merge` (a conversations first page the kit re-reads itself after a sync page): the pages
692
+ * merge into the rows shown instead of replacing them, so rows paged in below page 1 stay.
693
+ */
694
+ const fetchListOffline = (
695
+ request: any,
696
+ firstPage: boolean,
697
+ automatic = false,
698
+ merge = false
699
+ ): Promise<any[] | undefined> => {
700
+ offlinePathUsedRef.current = true;
701
+ // A re-read the kit starts by itself (reconnect, sync page) that fails while rows are on
702
+ // screen stays quiet: rows stay, no footer, no error view, no onError. The next one retries.
703
+ const quietOnFailure = automatic && listRef.current.length > 0;
704
+ const opGen = ++offlineOpGenRef.current;
705
+ if (firstPage) deferredLoadMoreRef.current = false; // a fresh first page supersedes a waiting load-more
706
+ const hubGen = OfflineHub.getInstance().gen;
707
+ const stale = () => opGen !== offlineOpGenRef.current || hubGen !== OfflineHub.getInstance().gen;
708
+ const isConversations = listItemKey === "conversationId";
709
+ const keyword = searchInputRef.current;
710
+ let current = firstPage && !merge ? [] : listRef.current;
711
+ let cachedKeys = new Set<string>();
712
+ let shownCached = false;
713
+ let serverPage: any[] | undefined;
714
+ offlineReadsInFlightRef.current++;
715
+ setIsLoadingMore(true);
716
+ const publish = (next: any[]) => {
717
+ current = next;
718
+ offlineListRef.current = next;
719
+ listRef.current = next; // a read on right after this one starts from these rows
720
+ setList(next);
721
+ };
722
+ return fetchTwoPhase<any>(
723
+ request,
724
+ "next",
725
+ {
726
+ onCached: (page) => {
727
+ cachedKeys = new Set(page.map(offlineKeyOf));
728
+ if (page.length === 0) return;
729
+ shownCached = true;
730
+ publish(merge ? mergeCachedFirstPage(current, page) : firstPage ? page : appendUnique(current, page, offlineKeyOf));
731
+ setDataLoadingStatus("");
732
+ },
733
+ onServer: (page) => {
734
+ serverPage = page;
735
+ pagingClosedOfflineRef.current = false;
736
+ errorViewRef.current = null;
737
+ setOfflineState("none");
738
+ const base = firstPage && !shownCached && !merge ? [] : current;
739
+ const merged = mergeSnapshotPage(base, cachedKeys, page, offlineKeyOf);
740
+ const next = merge
741
+ ? mergeFirstServerPage(base, cachedKeys, page)
742
+ : firstPage && isConversations
743
+ ? applyFirstServerPage(base, page)
744
+ : isConversations
745
+ ? keepUnsentPreviews(base, merged)
746
+ : merged;
747
+ publish(next);
748
+ setOfflineFooter("none");
749
+ // A merge over rows shown resets paging; an empty answer proves nothing (D17).
750
+ if (!merge || page.length > 0 || base.length === 0) setHasMoreData(page.length > 0);
751
+ setDataLoadingStatus(next.length === 0 ? NO_DATA_FOUND : "");
752
+ onListFetchedRef.current?.(next);
753
+ },
754
+ onError: (error, failedOffline) => {
755
+ if (quietOnFailure) return;
756
+ // Not connected: the SDK said so, or it reports no connection.
757
+ const notConnected = failedOffline || sdkConnected() === false;
758
+ if (notConnected && keyword && firstPage) {
759
+ // A keyword has no cache: the rows of the last search are not its answer (AC-10.2).
760
+ publish([]);
761
+ setHasMoreData(false);
762
+ }
763
+ if (listRef.current.length > 0) {
764
+ // Rows on screen stay (BEH-READ-06), no error view over them.
765
+ if (notConnected) {
766
+ // D84 rule 2: not connected over rows is not an error: no onError. A load-more page
767
+ // offers "Connect to load more" at its edge.
768
+ if (!keyword) {
769
+ setOfflineFooter("connect");
770
+ if (isConversations) pagingClosedOfflineRef.current = true;
771
+ }
772
+ return;
773
+ }
774
+ // D84 rule 5: a real error over rows, in a load the user or app started: onError once.
775
+ errorHandler(error);
776
+ return;
777
+ }
778
+ errorViewRef.current = notConnected ? "offline" : "other"; // only a not-connected one reloads on reconnect
779
+ if (notConnected && keyword) {
780
+ // D84 rule 7: an offline keyword search with nothing saved is an offline state, not an
781
+ // error: "Connect to search", no onError. It runs again once on reconnect.
782
+ setOfflineState("search");
783
+ setDataLoadingStatus(NO_DATA_FOUND);
784
+ return;
785
+ }
786
+ // D84 rule 3 and 4: nothing on screen. Offline: the kit's "Connect to load ..." state (the
787
+ // app's error view shows instead if it passed one); a real error: the error view. onError once.
788
+ setOfflineState(notConnected ? "load" : "none");
789
+ setDataLoadingStatus(SOMETHING_WRONG);
790
+ errorHandler(error);
791
+ },
792
+ },
793
+ stale
794
+ )
795
+ .finally(() => {
796
+ offlineReadsInFlightRef.current--;
797
+ setIsLoadingMore(false);
798
+ releaseDeferredLoadMore();
799
+ })
800
+ .then(() => serverPage);
801
+ };
802
+
803
+ /** The offline reads have settled: run the load-more that waited for them, once, from a fresh render. */
804
+ const releaseDeferredLoadMore = () => {
805
+ if (offlineReadsInFlightRef.current === 0 && deferredLoadMoreRef.current) setDeferredLoadMoreTick((t) => t + 1);
806
+ };
807
+ useEffect(() => {
808
+ if (deferredLoadMoreTick === 0 || !deferredLoadMoreRef.current) return;
809
+ deferredLoadMoreRef.current = false;
810
+ if (isOfflineOn()) handleList();
811
+ }, [deferredLoadMoreTick]);
812
+
813
+ /** Most pages one offline conversations read goes on while its pages list no new chat. */
814
+ const MAX_OFFLINE_READ_ON = 10;
815
+
816
+ /**
817
+ * Offline path of a conversations load-more. A server page that lists no new chat (the SDK's
818
+ * reconnect sync page already listed them) is not the end: the read goes on, up to
819
+ * MAX_OFFLINE_READ_ON pages, until a page brings a new chat. A stale read (list re-fetched,
820
+ * search changed, unmounted) or an empty / failed page stops it.
821
+ */
822
+ const readNextOffline = async (request: any, firstPage: boolean): Promise<void> => {
823
+ const keyword = searchInputRef.current;
824
+ const listed = new Set(listRef.current.map(offlineKeyOf));
825
+ offlineReadsInFlightRef.current++; // held across the pages: no other read starts between them
826
+ try {
827
+ for (let reads = 0; reads < MAX_OFFLINE_READ_ON; reads++) {
828
+ const read = fetchListOffline(request, firstPage && reads === 0);
829
+ const gen = offlineOpGenRef.current;
830
+ const page = await read;
831
+ if (gen !== offlineOpGenRef.current || searchInputRef.current !== keyword) return;
832
+ if (!page?.length) return;
833
+ if (page.some((item: any) => !listed.has(offlineKeyOf(item)))) return;
834
+ }
835
+ } finally {
836
+ offlineReadsInFlightRef.current--;
837
+ releaseDeferredLoadMore();
838
+ }
839
+ };
840
+ const readNextOfflineRef = useRef(readNextOffline);
841
+ readNextOfflineRef.current = readNextOffline;
842
+
843
+ /** "Connect to load more" tapped: try the next page again. */
844
+ const retryOfflinePage = () => {
845
+ pagingClosedOfflineRef.current = false;
846
+ setOfflineFooter("none");
847
+ setHasMoreData(true);
848
+ void fetchListOffline(listHandlerRef.current, list.length === 0);
849
+ };
850
+
851
+ /** Pull-to-refresh, offline ON only (UIK-SYNC-05): ask the SDK for a catch-up sweep. */
852
+ const onPullToRefresh = () => {
853
+ setRefreshing(true);
854
+ const done = () => setRefreshing(false);
855
+ try {
856
+ const result: any = offlineSdk().forceSyncNow?.({
857
+ onSuccess: done,
858
+ onError: (error: any) => {
859
+ done();
860
+ // Sweep in progress or cooling down: end silently (AC-8.6). Offline off: today's refresh.
861
+ if (error?.code === "ERROR_OFFLINE_DISABLED") reload();
862
+ },
863
+ });
864
+ if (result && typeof result.then === "function") result.then(undefined, () => {});
865
+ else if (!result) done();
866
+ } catch {
867
+ done();
868
+ }
869
+ };
870
+
871
+ const offlineHandlers = {
872
+ onConversationSync: (conversations: any[], gen: number) => {
873
+ if (listItemKey !== "conversationId" || gen !== OfflineHub.getInstance().gen) return;
874
+ if (!offlinePathUsedRef.current && !isOfflineOn()) return;
875
+ const builder = requestBuilderRef.current;
876
+ if (searchInputRef.current || isFilteredConversationRequest(builder)) {
877
+ // A filtered list does not reconcile the plain sync page: it re-reads its own request
878
+ // once, merged into the rows shown, one at a time however many sync pages arrive.
879
+ if (syncRereadRef.current) return;
880
+ syncRereadRef.current = true;
881
+ if (builder) listHandlerRef.current = builder.build();
882
+ void fetchListOffline(listHandlerRef.current, true, true, true).finally(() => {
883
+ syncRereadRef.current = false;
884
+ });
885
+ return;
886
+ }
887
+ // The plain list reconciles the slice the page covers; the request cursor is untouched.
888
+ const next = reconcileSyncPage(listRef.current, conversations);
889
+ offlineListRef.current = next;
890
+ setList(next);
891
+ if (next.length > 0) setDataLoadingStatus("");
892
+ // The sync page is the server's answer: it replaces an error view (an empty page: the empty view).
893
+ else if (errorViewRef.current !== null) setDataLoadingStatus(NO_DATA_FOUND);
894
+ errorViewRef.current = null;
895
+ setOfflineState("none");
896
+ onListFetchedRef.current?.(next);
897
+ },
898
+ onSessionEnded: () => {
899
+ if (!offlinePathUsedRef.current) return;
900
+ offlineOpGenRef.current++;
901
+ deferredLoadMoreRef.current = false;
902
+ pagingClosedOfflineRef.current = false;
903
+ offlineListRef.current = [];
904
+ errorViewRef.current = null;
905
+ setOfflineState("none");
906
+ setList([]);
907
+ setOfflineFooter("none");
908
+ },
909
+ onCacheReset: () => {
910
+ if (!offlinePathUsedRef.current && !isOfflineOn()) return;
911
+ // The kit reloads by itself: quiet while rows are shown (D83 rule 3).
912
+ automaticReloadRef.current = true;
913
+ try {
914
+ reload();
915
+ } finally {
916
+ automaticReloadRef.current = false;
917
+ }
918
+ },
919
+ };
920
+ const offlineHandlersRef = useRef(offlineHandlers);
921
+ offlineHandlersRef.current = offlineHandlers;
922
+
923
+ const stopOfflineReads = () => {
924
+ offlineOpGenRef.current++;
925
+ };
926
+ useEffect(() => {
927
+ // Private hub channel; inert while offline is off.
928
+ const hub = OfflineHub.getInstance();
929
+ const subscriptions = [
930
+ hub.conversationSync$.subscribe((e) => offlineHandlersRef.current.onConversationSync(e.conversations, e.gen)),
931
+ hub.session$.subscribe(() => offlineHandlersRef.current.onSessionEnded()),
932
+ hub.cacheReset$.subscribe(() => offlineHandlersRef.current.onCacheReset()),
933
+ ];
934
+ return () => {
935
+ subscriptions.forEach((s) => s.unsubscribe());
936
+ stopOfflineReads(); // an offline read-on loop in flight stops at unmount
937
+ if (offlineSearchTimer.current) clearTimeout(offlineSearchTimer.current);
938
+ };
939
+ }, []);
940
+
534
941
  /**
535
942
  * Reloads the list by fetching fresh data (matches Calls tab behavior)
536
943
  */
@@ -539,6 +946,8 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
539
946
  if (isLoadingMore) return;
540
947
 
541
948
  setDataLoadingStatus(LOADING);
949
+ errorViewRef.current = null;
950
+ setOfflineState("none");
542
951
  setHasMoreData(true);
543
952
  if (requestBuilder) {
544
953
  if (searchInputRef.current)
@@ -636,7 +1045,7 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
636
1045
 
637
1046
  return (
638
1047
  <View key={`header_${headerLetter}_${index}`}>
639
- <Text style={[styles.headerLetterStyle, listStyle?.sectionHeaderTextStyle]}>
1048
+ <Text style={[TEXT_START, styles.headerLetterStyle, listStyle?.sectionHeaderTextStyle]}>
640
1049
  {headerLetter}
641
1050
  </Text>
642
1051
  </View>
@@ -644,6 +1053,7 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
644
1053
  }
645
1054
  return (
646
1055
  <CometChatListItem
1056
+ testID={itemTestID?.(item.value)}
647
1057
  statusIndicatorType={statusIndicatorType ? statusIndicatorType(item.value) : null}
648
1058
  id={item.value[listItemKey]}
649
1059
  avatarName={item.value.name}
@@ -687,6 +1097,7 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
687
1097
  },
688
1098
  [
689
1099
  listItemKey,
1100
+ itemTestID,
690
1101
  selectedItems,
691
1102
  shouldSelect,
692
1103
  listStyle,
@@ -735,7 +1146,30 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
735
1146
  */
736
1147
  const getMessageContainer = useCallback(() => {
737
1148
  let messageContainer: JSX.Element = <></>;
738
- if (list.length === 0 && dataLoadingStatus.toLowerCase() === NO_DATA_FOUND) {
1149
+ // D84: the kit's offline states sit in the error / empty view's place, in the host list's error-state style.
1150
+ const connectState = (title: string, testID: string, subtitle?: string) => (
1151
+ <ConnectStateView
1152
+ testID={testID}
1153
+ title={title}
1154
+ subtitle={subtitle}
1155
+ containerStyle={listStyle?.errorStateStyle?.containerStyle}
1156
+ titleStyle={listStyle?.errorStateStyle?.titleStyle}
1157
+ subtitleStyle={listStyle?.errorStateStyle?.subTitleStyle}
1158
+ />
1159
+ );
1160
+ if (
1161
+ list.length === 0 &&
1162
+ dataLoadingStatus.toLowerCase() === NO_DATA_FOUND &&
1163
+ offlineState === "search" &&
1164
+ !(customEmptyView ?? !!EmptyView)
1165
+ ) {
1166
+ // D84 rule 7 + addition A: an offline keyword search with nothing saved.
1167
+ messageContainer = connectState(
1168
+ t(OFFLINE_STRING_KEYS.connectToSearch),
1169
+ CONTRACT_IDS.emptyConnectToSearch,
1170
+ t(OFFLINE_STRING_KEYS.connectToSearchSubtitle)
1171
+ );
1172
+ } else if (list.length === 0 && dataLoadingStatus.toLowerCase() === NO_DATA_FOUND) {
739
1173
  messageContainer = EmptyView ? (
740
1174
  <EmptyView />
741
1175
  ) : (
@@ -745,6 +1179,17 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
745
1179
  </Text>
746
1180
  </View>
747
1181
  );
1182
+ } else if (
1183
+ !hideError &&
1184
+ dataLoadingStatus.toLowerCase() === SOMETHING_WRONG &&
1185
+ offlineState === "load" &&
1186
+ !(customErrorView ?? !!ErrorView)
1187
+ ) {
1188
+ // D84 rule 3: offline with nothing on screen: "Connect to load ...", no Retry.
1189
+ messageContainer = connectState(
1190
+ t(connectToLoadKey ?? connectToLoadKeyFor(listItemKey)),
1191
+ CONTRACT_IDS.emptyConnectToLoad
1192
+ );
748
1193
  } else if (!hideError && dataLoadingStatus.toLowerCase() === SOMETHING_WRONG) {
749
1194
  messageContainer = ErrorView ? (
750
1195
  <ErrorView />
@@ -759,20 +1204,11 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
759
1204
  </View>
760
1205
  );
761
1206
  } else {
762
- let currentLetter = "";
763
- const listWithHeaders: any[] = [];
764
1207
  if (list.length) {
765
- list.forEach((listItem: any) => {
766
- const chr = listItem?.name && listItem.name[0].toUpperCase();
767
- if (!hideStickyHeader && chr !== currentLetter && !ItemView) {
768
- currentLetter = chr;
769
- listWithHeaders.push({
770
- value: currentLetter,
771
- header: true,
772
- });
773
- }
774
- listWithHeaders.push({ value: listItem, header: false });
775
- });
1208
+ const listWithHeaders: any[] =
1209
+ hideStickyHeader || ItemView
1210
+ ? list.map((listItem: any) => ({ value: listItem, header: false }))
1211
+ : withSectionHeaders(list, (listItem: any) => listItem?.name);
776
1212
 
777
1213
  messageContainer = (
778
1214
  <View style={styles.listContainerStyle}>
@@ -807,9 +1243,30 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
807
1243
  }
808
1244
  }}
809
1245
  showsVerticalScrollIndicator={false}
810
- ListFooterComponent={renderFooter}
1246
+ ListFooterComponent={
1247
+ offlineFooter === "connect"
1248
+ ? () => (
1249
+ <ConnectToLoadMore
1250
+ t={t}
1251
+ onRetry={retryOfflinePage}
1252
+ textColor={theme.color.textSecondary as string}
1253
+ containerStyle={theme.messageListStyles?.offlineStyles?.footerStyle?.containerStyle}
1254
+ textStyle={theme.messageListStyles?.offlineStyles?.footerStyle?.textStyle}
1255
+ />
1256
+ )
1257
+ : renderFooter
1258
+ }
1259
+ refreshControl={
1260
+ // Offline ON only: pull-to-refresh asks the SDK for a sweep (conversations).
1261
+ listItemKey === "conversationId" && isOfflineOn() ? (
1262
+ <RefreshControl refreshing={refreshing} onRefresh={onPullToRefresh} />
1263
+ ) : undefined
1264
+ }
811
1265
  keyboardShouldPersistTaps='always'
812
1266
  keyboardDismissMode={Platform.OS === 'ios' ? 'on-drag' : 'none'}
1267
+ // ENG-40210: keep clipping off. FlatList defaults it ON for Android, where it detaches rows
1268
+ // outside Fabric's mount queue and crashes on cold start (addViewAt IndexOutOfBounds).
1269
+ removeClippedSubviews={false}
813
1270
  />
814
1271
  </View>
815
1272
  );
@@ -817,7 +1274,7 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
817
1274
  }
818
1275
 
819
1276
  return messageContainer;
820
- }, [list, selectedItems, theme, dataLoadingStatus, isLoadingMore, hasMoreData, shouldSelect]);
1277
+ }, [list, selectedItems, theme, dataLoadingStatus, isLoadingMore, hasMoreData, shouldSelect, offlineFooter, offlineState, refreshing]);
821
1278
 
822
1279
 
823
1280
  return (