@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
@@ -374,7 +374,7 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
374
374
  }
375
375
  return (
376
376
  <View>
377
- <Text>{"no match"}</Text>
377
+ <Text>{t("NOT_SUPPORTED")}</Text>
378
378
  </View>
379
379
  );
380
380
  }
@@ -13,6 +13,7 @@ import { DefaultLinkPreview } from "./resources";
13
13
  import { useTheme } from "../../theme";
14
14
  import { CometChatTheme } from "../../theme/type";
15
15
  import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
16
+ import { ownLanguageTextStyle } from "../../shared/helper/textDirection";
16
17
 
17
18
  /**
18
19
  * Props for the LinkPreviewBubble component.
@@ -109,9 +110,13 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
109
110
  if (onPress) {
110
111
  onPress();
111
112
  } else {
112
- const opened: unknown = await Linking.openURL(link);
113
- if (!opened) {
114
- Alert.alert(t("SOMETHING_WRONG"));
113
+ // openURL resolves true or rejects when the link cannot open; it never resolves false.
114
+ try {
115
+ await Linking.openURL(link);
116
+ } catch {
117
+ // Our own translated button (ENG-57297): with none, Android shows a hard-coded English
118
+ // 'OK' and iOS shows UIKit's OK in the phone's language, not the kit's.
119
+ Alert.alert(t("SOMETHING_WRONG"), undefined, [{ text: t("OK") }]);
115
120
  }
116
121
  }
117
122
  }
@@ -186,7 +191,7 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
186
191
  <View style={style?.bodyStyle?.containerStyle}>
187
192
  <View style={{ flexDirection: "row" }}>
188
193
  <View style={style?.bodyStyle?.titleContainerStyle}>
189
- <Text style={style?.bodyStyle?.titleStyle} ellipsizeMode='tail'>
194
+ <Text style={[ownLanguageTextStyle(title), style?.bodyStyle?.titleStyle]} ellipsizeMode='tail'>
190
195
  {title}
191
196
  </Text>
192
197
  </View>
@@ -204,10 +209,10 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
204
209
  )}
205
210
  </View>
206
211
  <View style={style?.bodyStyle?.subtitleContainerStyle}>
207
- <Text style={style?.bodyStyle?.subtitleTitle} numberOfLines={2} ellipsizeMode='tail'>
212
+ <Text style={[ownLanguageTextStyle(description), style?.bodyStyle?.subtitleTitle]} numberOfLines={2} ellipsizeMode='tail'>
208
213
  {description}
209
214
  </Text>
210
- <Text style={style?.bodyStyle?.subtitleTitle} numberOfLines={2} ellipsizeMode='tail'>
215
+ <Text style={[ownLanguageTextStyle(link), style?.bodyStyle?.subtitleTitle]} numberOfLines={2} ellipsizeMode='tail'>
211
216
  {link}
212
217
  </Text>
213
218
  </View>
@@ -15,8 +15,8 @@ const getLinkPreviewBubbleStyle = (
15
15
  bodyStyle: {
16
16
  containerStyle: {
17
17
  //borderRadius: spacing.radius.r2,
18
- borderBottomLeftRadius: spacing.radius.r2,
19
- borderBottomRightRadius: spacing.radius.r2,
18
+ borderBottomStartRadius: spacing.radius.r2,
19
+ borderBottomEndRadius: spacing.radius.r2,
20
20
  padding: spacing.padding.p2,
21
21
  backgroundColor: color.extendedPrimary900,
22
22
  flex: 1,
@@ -39,8 +39,8 @@ const getLinkPreviewBubbleStyle = (
39
39
  },
40
40
  headerImageStyle: {
41
41
  alignSelf: "center",
42
- borderTopLeftRadius: spacing.radius.r2,
43
- borderTopRightRadius: spacing.radius.r2,
42
+ borderTopStartRadius: spacing.radius.r2,
43
+ borderTopEndRadius: spacing.radius.r2,
44
44
  },
45
45
  headerImageContainerStyle: {
46
46
  flex: 1,
@@ -48,8 +48,8 @@ const getLinkPreviewBubbleStyle = (
48
48
  flexDirection: 'row',
49
49
  justifyContent: "center",
50
50
  backgroundColor: color.extendedPrimary900,
51
- borderTopLeftRadius: spacing.radius.r2,
52
- borderTopRightRadius: spacing.radius.r2,
51
+ borderTopStartRadius: spacing.radius.r2,
52
+ borderTopEndRadius: spacing.radius.r2,
53
53
  },
54
54
  };
55
55
  };
@@ -94,7 +94,7 @@ const styles = StyleSheet.create({
94
94
  alignItems: "center",
95
95
  },
96
96
  iconContainer: {
97
- paddingRight: 15,
97
+ paddingEnd: 15,
98
98
  },
99
99
  headingText: {
100
100
  fontSize: 20,
@@ -21,6 +21,12 @@ import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context"
21
21
  import { CometChatMessageEvents } from "../../shared/events/CometChatMessageEvents";
22
22
  import { messageStatus } from "../../shared/utils/CometChatMessageHelper";
23
23
  import { runAfterInteractions } from "../../shared/utils/runAfterInteractions";
24
+ import {
25
+ TEXT_START,
26
+ directionStyle,
27
+ useComponentLayoutDirection,
28
+ useInputTextAlign,
29
+ } from "../../shared/helper/layoutDirection";
24
30
 
25
31
  const { CommonUtil } = NativeModules;
26
32
 
@@ -124,14 +130,16 @@ export interface CometChatCreatePollInterface {
124
130
  * @returns {JSX.Element} The rendered poll creation UI.
125
131
  */
126
132
  export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
133
+ // Before the destructure: the placeholder defaults below are translated.
134
+ const { t } = useCometChatTranslation();
127
135
  const {
128
136
  title,
129
- questionPlaceholderText = "Ask question",
137
+ questionPlaceholderText = t("ASK_QUESTION"),
130
138
  onError,
131
139
  user,
132
140
  group,
133
141
  onClose,
134
- answerPlaceholderText = "Answers",
142
+ answerPlaceholderText = t("ANSWERS"),
135
143
  answerHelpText,
136
144
  addAnswerText,
137
145
  defaultAnswers = 2,
@@ -146,7 +154,9 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
146
154
  const [loader, setLoader] = useState(false);
147
155
  const loggedInUser = useRef<CometChat.User | null>(null);
148
156
  const theme = useTheme();
149
- const { t } = useCometChatTranslation();
157
+ const inputAlign = useInputTextAlign(); // ENG-41384
158
+ // ENG-57304: Modal content (the composer opens it) starts a new native root; re-apply the kit direction.
159
+ const direction = useComponentLayoutDirection();
150
160
  const answerRefs = useRef<(React.ComponentRef<typeof TextInput> | null)[]>([]);
151
161
  const [lastRemovedIndex, setLastRemovedIndex] = useState<number | null>(null);
152
162
  const [newlyAddedIndex, setNewlyAddedIndex] = useState<number | null>(null);
@@ -242,7 +252,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
242
252
  >
243
253
  <Icon name='info' color={theme.color.error} size={20} />
244
254
  <Text
245
- style={[theme.typography.caption1.regular, { color: theme.color.error, marginLeft: 10 }]}
255
+ style={[theme.typography.caption1.regular, { color: theme.color.error, marginStart: 10 }]}
246
256
  >
247
257
  {error}
248
258
  </Text>
@@ -338,15 +348,15 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
338
348
  onChangeText={(text) => handleAnswerTextChange(text, index)}
339
349
  placeholder={answerPlaceholderText}
340
350
  placeholderTextColor={theme.color.textTertiary}
341
- style={{
351
+ style={[inputAlign, {
342
352
  flex: 1,
343
353
  padding: Platform.select({ android: 5, ios: 10 }),
344
354
  borderWidth: 1,
345
355
  borderColor: theme.color.borderLight,
346
356
  borderRadius: 8,
347
- paddingLeft: 10,
357
+ paddingStart: 10,
348
358
  color: theme.color.textPrimary,
349
- }}
359
+ }]}
350
360
  />
351
361
  </View>
352
362
  );
@@ -368,7 +378,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
368
378
  width: "100%",
369
379
  justifyContent: "center",
370
380
  alignItems: "flex-start",
371
- paddingLeft: 10,
381
+ paddingStart: 10,
372
382
  }}
373
383
  >
374
384
  <Text
@@ -468,7 +478,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
468
478
 
469
479
  return (
470
480
  <SafeAreaView
471
- style={{ flex: 1, backgroundColor: theme.color.background1 }}
481
+ style={[{ flex: 1, backgroundColor: theme.color.background1 }, directionStyle(direction)]}
472
482
  edges={["top", "left", "right"]}
473
483
  >
474
484
  <KeyboardAvoidingView
@@ -488,14 +498,14 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
488
498
  >
489
499
  <TouchableOpacity
490
500
  onPress={onClose}
491
- style={{ flexDirection: "row", paddingVertical: 20, paddingLeft: 10 }}
501
+ style={{ flexDirection: "row", paddingVertical: 20, paddingStart: 10 }}
492
502
  >
493
503
  <Icon name='arrow-back' />
494
504
  </TouchableOpacity>
495
505
  <Text
496
506
  style={[
497
507
  theme.typography.heading2.bold,
498
- { color: theme.color.iconPrimary, paddingLeft: 10 },
508
+ { color: theme.color.iconPrimary, paddingStart: 10 },
499
509
  ]}
500
510
  >
501
511
  {title ? title : t("CREATE_POLL")}
@@ -506,6 +516,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
506
516
  <View style={{ paddingHorizontal: 20 }}>
507
517
  <Text
508
518
  style={[
519
+ TEXT_START,
509
520
  theme.typography.heading4.medium,
510
521
  { marginTop: 15, color: theme.color.textPrimary },
511
522
  ]}
@@ -518,19 +529,21 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
518
529
  placeholder={questionPlaceholderText}
519
530
  placeholderTextColor={theme.color.textTertiary}
520
531
  style={[
532
+ inputAlign,
521
533
  {
522
534
  padding: Platform.select({ android: 5, ios: 10 }),
523
535
  borderWidth: 1,
524
536
  borderColor: theme.color.borderLight,
525
537
  borderRadius: 8,
526
538
  marginTop: 10,
527
- paddingLeft: 10,
539
+ paddingStart: 10,
528
540
  color: theme.color.textPrimary,
529
541
  },
530
542
  ]}
531
543
  />
532
544
  <Text
533
545
  style={[
546
+ TEXT_START,
534
547
  theme.typography.heading4.medium,
535
548
  { marginTop: 25, color: theme.color.textPrimary, marginBottom: 2 },
536
549
  ]}
@@ -17,6 +17,8 @@ import { CometChatTheme } from "../../theme/type";
17
17
  import { CometChatAvatar } from "../../shared/views/CometChatAvatar";
18
18
  import { useTheme } from "../../theme";
19
19
  import { Icon } from "../../shared/icons/Icon";
20
+ import { localizeDigits } from "../../shared/helper/LocalizedDateHelper";
21
+ import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew/useCometChatTranslationHook";
20
22
 
21
23
  /**
22
24
  *
@@ -152,6 +154,8 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
152
154
  activeProgressBarTint,
153
155
  } = props;
154
156
  const theme = useTheme();
157
+ // The context language: the provider sets the global one in an effect, a render later.
158
+ const { language } = useCometChatTranslation();
155
159
  const [optionsList, setOptionsList] = useState<Array<{ id: any; value: any }>>([]);
156
160
  const [optionsMetaData, setOptionsMetaData] = useState<any>({});
157
161
  const [isLoading, setIsLoading] = useState(false);
@@ -227,10 +231,10 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
227
231
  const secondavatarStyle = voteravatarStyle;
228
232
  const thirdavatarStyle = voteravatarStyle;
229
233
  if (secondavatarStyle && secondavatarStyle.containerStyle) {
230
- Object.assign(secondavatarStyle.containerStyle, { marginLeft: -10 });
234
+ Object.assign(secondavatarStyle.containerStyle, { marginStart: -10 });
231
235
  }
232
236
  if (thirdavatarStyle && thirdavatarStyle.containerStyle) {
233
- Object.assign(thirdavatarStyle.containerStyle, { marginLeft: -10 });
237
+ Object.assign(thirdavatarStyle.containerStyle, { marginStart: -10 });
234
238
  }
235
239
  // Ensure value is a string for rendering
236
240
  let optionText = typeof value === 'string' ? value : (value && value.value ? value.value : String(value));
@@ -292,7 +296,7 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
292
296
  </View>
293
297
 
294
298
  <Text style={voteCountTextStyle}>
295
- {optionsMetaData?.results?.options?.[id]?.count ?? 0}
299
+ {localizeDigits(String(optionsMetaData?.results?.options?.[id]?.count ?? 0), language)}
296
300
  </Text>
297
301
  </View>
298
302
  </View>
@@ -366,7 +370,7 @@ const style = StyleSheet.create({
366
370
  height: 20,
367
371
  width: 20,
368
372
  borderRadius: 20,
369
- marginLeft: 10,
373
+ marginStart: 10,
370
374
  alignItems: "center",
371
375
  justifyContent: "center",
372
376
  },
@@ -378,8 +382,8 @@ const style = StyleSheet.create({
378
382
  flexDirection: "row",
379
383
  position: "absolute",
380
384
  height: "100%",
381
- borderTopLeftRadius: 6,
382
- borderBottomLeftRadius: 6,
385
+ borderTopStartRadius: 6,
386
+ borderBottomStartRadius: 6,
383
387
  },
384
388
  centerPosition: {
385
389
  position: "absolute",
@@ -67,7 +67,7 @@ export const getPollBubbleStyleLight = (
67
67
  color: color.receiveBubbleText,
68
68
  flex: 1,
69
69
  maxWidth: "80%",
70
- marginRight: 10,
70
+ marginEnd: 10,
71
71
  //alignSelf: 'flex-end'
72
72
  },
73
73
  voteCountTextStyle: {
@@ -96,7 +96,7 @@ export const getPollBubbleStyleLight = (
96
96
  },
97
97
  activeProgressBarTint: color.iconHighlight,
98
98
  dateReceiptContainerStyle: {
99
- paddingRight: spacing.padding.p0,
99
+ paddingEnd: spacing.padding.p0,
100
100
  },
101
101
  voteravatarStyle: {
102
102
  containerStyle: {
@@ -139,7 +139,7 @@ export const getPollBubbleStyleLight = (
139
139
  color: color.sendBubbleText,
140
140
  flex: 1,
141
141
  maxWidth: "80%",
142
- marginRight: 10
142
+ marginEnd: 10
143
143
  },
144
144
  voteCountTextStyle: {
145
145
  ...typography.body.regular,
@@ -167,7 +167,7 @@ export const getPollBubbleStyleLight = (
167
167
  marginBottom: spacing.margin.m0,
168
168
  },
169
169
  dateReceiptContainerStyle: {
170
- paddingRight: spacing.padding.p0,
170
+ paddingEnd: spacing.padding.p0,
171
171
  },
172
172
  voteravatarStyle: {
173
173
  containerStyle: {
@@ -231,7 +231,7 @@ export const CometChatStickerKeyboard = (props: CometChatStickerKeyboardInterfac
231
231
  <Text
232
232
  style={[
233
233
  theme?.typography?.body.regular,
234
- { color: theme.color.textTertiary, paddingLeft: 10 },
234
+ { color: theme.color.textTertiary, paddingStart: 10 },
235
235
  ]}
236
236
  >
237
237
  {activeStickerSetName}
@@ -258,7 +258,7 @@ export const CometChatStickerKeyboard = (props: CometChatStickerKeyboardInterfac
258
258
  <TouchableOpacity
259
259
  style={Styles.sectionListItemStyle}
260
260
  onPress={() => onStickerSetClicked(item)}
261
- accessibilityLabel={`Sticker category ${item}`}
261
+ accessibilityLabel={t('STICKER_CATEGORY_NAMED').replace('{name}', item)}
262
262
  accessibilityRole='button'
263
263
  >
264
264
  {isActive && (
@@ -20,7 +20,7 @@ const SkeletonBox = ({ index, boxSize, gradientColors }: any) => {
20
20
  {
21
21
  width: boxSize,
22
22
  height: boxSize,
23
- marginRight: isLastInRow ? 0 : 8,
23
+ marginEnd: isLastInRow ? 0 : 8,
24
24
  },
25
25
  ]}
26
26
  >
@@ -34,7 +34,7 @@ export const Styles = StyleSheet.create({
34
34
  position: "absolute",
35
35
  top: "50%",
36
36
  left: "50%",
37
- marginLeft: -10,
37
+ marginStart: -10,
38
38
  marginTop: -10,
39
39
  zIndex: 2,
40
40
  borderRadius: 10,
@@ -23,6 +23,7 @@ import { CometChatStickerKeyboard } from "./CometChatStickerKeyboard";
23
23
  import { CometChatStickerBubble } from "./StickersBubble";
24
24
  import { StickerConfigurationInterface } from "./StickerConfiguration";
25
25
  import { AdditionalAuxiliaryOptionsParams } from "../../shared/base/Types";
26
+ import { isQuietRejection } from "../../shared/offline/send";
26
27
  import { getCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew/LocalizationManager"
27
28
 
28
29
  const t = getCometChatTranslation();
@@ -161,6 +162,7 @@ const StickerButton = ({ user, group, id, stickerIconStyle, stickerIcon, replyTo
161
162
  }
162
163
  })
163
164
  .catch((err) => {
165
+ if (isQuietRejection(err)) return; // the session ended or the cache was reset: nothing to report
164
166
  console.error("Failed to send sticker:", err);
165
167
  });
166
168
  };
@@ -238,8 +240,8 @@ const StickerButton = ({ user, group, id, stickerIconStyle, stickerIcon, replyTo
238
240
  key={"sticker"}
239
241
  onPress={togglePanel}
240
242
  style={{ justifyContent: "center", alignItems: "center", padding: 10 }}
241
- accessibilityLabel='Sticker Button'
242
- accessibilityHint='Opens the sticker panel'
243
+ accessibilityLabel={t('STICKER')}
244
+ accessibilityHint={t('OPEN_STICKER_PANEL')}
243
245
  >
244
246
  <Icon
245
247
  name='sticker-fill'
package/src/index.ts CHANGED
@@ -78,6 +78,7 @@ import {
78
78
  MessageBubbleAlignmentType,
79
79
  MessageDataSource,
80
80
  MessageEvents,
81
+ OfflineMessageEvents,
81
82
  MessageListAlignmentType,
82
83
  MessageTimeAlignmentType,
83
84
  RecorderState,
@@ -326,6 +327,7 @@ export {
326
327
  MentionTextStyle,
327
328
  MessageDataSource,
328
329
  MessageEvents,
330
+ OfflineMessageEvents,
329
331
  MessageTranslationBubble,
330
332
  MessageTranslationExtension,
331
333
  PollsExtension,
@@ -412,8 +414,12 @@ export type {
412
414
  } from "./shared";
413
415
 
414
416
  export {CometChatI18nProvider,useCometChatTranslation} from "./shared/resources/CometChatLocalizeNew"
415
- export {localizedDateHelperInstance,LocalizedDateHelper} from "./shared/helper/LocalizedDateHelper"
417
+ export {localizedDateHelperInstance,LocalizedDateHelper,localizeDigits} from "./shared/helper/LocalizedDateHelper"
418
+ // "{count} …" in the kit language's plural form (MEMBER_COUNT, REPLY_COUNT, …), for apps that use the kit bundles.
419
+ export { pluralCountLabel } from "./shared/helper/pluralRules";
416
420
  export { useLocalizedDate } from "./shared/helper/useLocalizedDateHook";
421
+ export { useCometChatLayoutDirection } from "./shared/helper/layoutDirection";
422
+ export type { CometChatLayoutDirection } from "./shared/helper/layoutDirection";
417
423
 
418
424
  export { CometChatMessageHeader } from "./CometChatMessageHeader";
419
425
  export {getLastSeenTime}
@@ -483,6 +489,10 @@ export type {
483
489
 
484
490
  // Rich Text Editor
485
491
  export { default as RichTextEditor } from './CometChatRichTextEditor';
492
+ // Offline support (additive): event payload and settings types.
493
+ export type { MessageSendState, MessageSendStateChangedEvent, OfflineCacheResetEvent } from "./shared/events";
494
+ export type { UIKitOfflineSettings } from "./shared/CometChatUiKit/UIKitSettings";
495
+
486
496
  export type {
487
497
  RichTextEditorRef,
488
498
  ContentChangeEvent,
@@ -20,7 +20,11 @@ import { CometChatSoundManager } from "../resources";
20
20
  import { getUnixTimestampInMilliseconds, messageStatus } from "../utils/CometChatMessageHelper";
21
21
  import { permissionUtil } from "../utils/PermissionUtil";
22
22
  import { CometChatUIKitHelper } from "./CometChatUIKitHelper";
23
+ import { applyOfflineSetting, prepareOfflineSupport, startOfflineSupport } from "../offline";
24
+ import { isOfflineOn } from "../offline/gate";
25
+ import { sendWithStatePromise } from "../offline/send";
23
26
  import { UIKitSettings } from "./UIKitSettings";
27
+ import { CometChatLayoutDirection, setGlobalLayoutDirection } from "../helper/layoutDirection";
24
28
 
25
29
  export class CometChatUIKit {
26
30
  static uiKitSettings: UIKitSettings;
@@ -39,6 +43,8 @@ export class CometChatUIKit {
39
43
  CometChatUIKit.uiKitSettings = {
40
44
  ...uiKitSettings,
41
45
  };
46
+ // Only when given: an init without one must not undo an earlier setLayoutDirection().
47
+ if (uiKitSettings.layoutDirection !== undefined) setGlobalLayoutDirection(uiKitSettings.layoutDirection);
42
48
  // Plain init(): clear any ai-agent settings so the Calls SDK uses plain init().
43
49
  CometChatUIKit.callsInitSettings = null;
44
50
  var appSetting = new CometChat.AppSettingsBuilder()
@@ -57,14 +63,21 @@ export class CometChatUIKit {
57
63
  appSetting.roles = uiKitSettings.roles;
58
64
  }
59
65
 
66
+ // Offline: pass-through only (absent ⇒ no call; SDK without offline ⇒ no call).
67
+ applyOfflineSetting(appSetting, uiKitSettings.offline);
68
+
60
69
  CometChatUIKit.attachListener();
70
+ prepareOfflineSupport();
61
71
 
62
72
  return CometChat.init(uiKitSettings.appId, appSetting.build()).then(
63
73
  async() => {
64
74
  CometChat.setSource("uikit-v5", Platform.OS, "react-native");
65
75
  ListenerInitializer.attachListeners();
76
+ // After the SDK's own init: register the offline hub once (inert while offline is off).
77
+ startOfflineSupport();
66
78
  try {
67
79
  const user = await CometChat.getLoggedinUser();
80
+ if (user) startOfflineSupport(user);
68
81
  CometChatUIKit.setLoggedInUser(user);
69
82
  if (user) {
70
83
  this.enableExtensions();
@@ -92,8 +105,25 @@ export class CometChatUIKit {
92
105
  * File-based init for AI agent skills.
93
106
  * Calls CometChat.initFromSettings(settings) which writes
94
107
  * integrationSource = "ai-agent" to persistent storage.
108
+ *
109
+ * Offline works the same as on init(): pass `offline` (the value `UIKitSettings.offline`
110
+ * takes — `true`, an options object, or an SDK `OfflineConfig`) and it reaches the SDK as
111
+ * `chatSDK.offline`, replacing any value in the settings file. Without it, the file's
112
+ * `chatSDK.offline` reaches the SDK unchanged.
113
+ *
114
+ * @param settings The parsed cometchat-settings.json object.
115
+ * @param offline Optional offline messaging settings for the Chat SDK.
95
116
  */
96
- static initFromSettings(settings: CometChat.CometChatSettings) {
117
+ static initFromSettings(settings: CometChat.CometChatSettings, offline?: UIKitSettings["offline"]) {
118
+ // Offline: a code-level setting wins over the file's; the caller's object is left as is.
119
+ // Read and written untyped: an SDK before offline support has no `chatSDK.offline` in its typings.
120
+ if (offline !== undefined && offline !== null) {
121
+ settings = {
122
+ ...settings,
123
+ chatSDK: { ...settings.chatSDK, offline } as CometChat.CometChatSettings["chatSDK"],
124
+ };
125
+ }
126
+
97
127
  // Extract authKey from credentials (UIKit uses this for login — SDK ignores it)
98
128
  const authKey = settings.credentials?.authKey;
99
129
 
@@ -102,6 +132,11 @@ export class CometChatUIKit {
102
132
  (settings.uiKit as { subscribePresenceForAllUsers?: boolean })
103
133
  ?.subscribePresenceForAllUsers ?? true;
104
134
 
135
+ // The file's uiKit.layoutDirection, as init()'s layoutDirection: applied only when given.
136
+ const layoutDirection = (settings.uiKit as { layoutDirection?: CometChatLayoutDirection } | undefined)
137
+ ?.layoutDirection;
138
+ if (layoutDirection !== undefined) setGlobalLayoutDirection(layoutDirection);
139
+
105
140
  // Store internally so login/createUser/updateUser keep working
106
141
  CometChatUIKit.uiKitSettings = {
107
142
  appId: settings.appId,
@@ -110,20 +145,27 @@ export class CometChatUIKit {
110
145
  subscriptionType: subscribePresence
111
146
  ? CometChat.AppSettings.SUBSCRIPTION_TYPE_ALL_USERS as UIKitSettings["subscriptionType"]
112
147
  : undefined,
148
+ // Same as init(): the kit's settings carry the offline setting the SDK was given.
149
+ offline: (settings.chatSDK as { offline?: UIKitSettings["offline"] } | undefined)?.offline,
150
+ layoutDirection,
113
151
  };
114
152
 
115
153
  // Capture raw settings so the Calls SDK routes through initFromSettings (ai-agent).
116
154
  CometChatUIKit.callsInitSettings = settings;
117
155
 
118
156
  CometChatUIKit.attachListener();
157
+ prepareOfflineSupport();
119
158
 
120
159
  // CRITICAL: Call initFromSettings — NOT init(). Only initFromSettings writes "ai-agent".
160
+ // `settings.chatSDK.offline` (from the file or `offline`) reaches the SDK: initFromSettings reads it itself.
121
161
  return CometChat.initFromSettings(settings).then(
122
162
  async () => {
123
163
  CometChat.setSource("uikit-v5", Platform.OS, "react-native");
124
164
  ListenerInitializer.attachListeners();
165
+ startOfflineSupport();
125
166
  await CometChat.getLoggedinUser()
126
- .then((user: any) => {
167
+ .then(async (user: any) => {
168
+ if (user) startOfflineSupport(user);
127
169
  CometChatUIKit.setLoggedInUser(user);
128
170
  if (user) {
129
171
  this.enableExtensions();
@@ -150,6 +192,14 @@ export class CometChatUIKit {
150
192
  );
151
193
  }
152
194
 
195
+ /**
196
+ * Change the kit's layout direction after init. Applies to components created afterwards
197
+ * (reopen the screen); mounted components keep the direction they were created with.
198
+ */
199
+ static setLayoutDirection(layoutDirection: CometChatLayoutDirection) {
200
+ setGlobalLayoutDirection(layoutDirection);
201
+ }
202
+
153
203
  static defaultExtensions: ExtensionsDataSource[] = [
154
204
  new StickersExtension(),
155
205
  new CollaborativeWhiteboardExtension(),
@@ -377,6 +427,8 @@ export class CometChatUIKit {
377
427
  static sendCustomMessage(
378
428
  message: CometChat.CustomMessage
379
429
  ): Promise<CometChat.CustomMessage | CometChat.BaseMessage> {
430
+ // Gate read once per send. OFF: today's code below, unchanged.
431
+ if (isOfflineOn()) return CometChatUIKit.sendOnOfflinePath(message, "custom");
380
432
  return new Promise((resolve, reject) => {
381
433
  if (!message.getMuid()) {
382
434
  message.setMuid(String(getUnixTimestampInMilliseconds()));
@@ -406,6 +458,7 @@ export class CometChatUIKit {
406
458
  static sendMediaMessage(
407
459
  message: CometChat.MediaMessage
408
460
  ): Promise<CometChat.MediaMessage | CometChat.BaseMessage> {
461
+ if (isOfflineOn()) return CometChatUIKit.sendOnOfflinePath(message, "media");
409
462
  return new Promise((resolve, reject) => {
410
463
  if (!message.getMuid()) {
411
464
  message.setMuid(String(getUnixTimestampInMilliseconds()));
@@ -461,6 +514,7 @@ export class CometChatUIKit {
461
514
  static sendTextMessage(
462
515
  message: CometChat.TextMessage
463
516
  ): Promise<CometChat.TextMessage | CometChat.BaseMessage> {
517
+ if (isOfflineOn()) return CometChatUIKit.sendOnOfflinePath(message, "text");
464
518
  return new Promise((resolve, reject) => {
465
519
  if (!message?.getMuid()) {
466
520
  message.setMuid(String(getUnixTimestampInMilliseconds()));
@@ -486,6 +540,52 @@ export class CometChatUIKit {
486
540
  });
487
541
  }
488
542
 
543
+ /**
544
+ * The statics on the offline (ON) path (README §3.4): the same compose-time preparation and
545
+ * `inprogress` announcement as today, then the kit's one send helper. Resolves on the server's
546
+ * ack (also after the message was queued), rejects on a final failure, a direct error or a
547
+ * discard, and never because the message was queued. When the session ends (logout, user
548
+ * switch) or a cache reset loses the queued send, it rejects once, quietly, with
549
+ * `ERROR_OFFLINE_MESSAGE_DISCARDED`, as Android does: no error event, no toast. The SDK's state
550
+ * comes from callbacks; the kit never stamps `metadata.error` here.
551
+ */
552
+ private static sendOnOfflinePath(message: any, kind: "text" | "media" | "custom"): Promise<any> {
553
+ try {
554
+ if (!message?.getMuid?.()) message.setMuid(String(getUnixTimestampInMilliseconds()));
555
+ if (!message?.getSender?.() && this.loggedInUser) message.setSender(this.loggedInUser);
556
+ if (kind === "media") {
557
+ let hasAttachment;
558
+ try {
559
+ hasAttachment = message.getAttachment();
560
+ } catch (error) {
561
+ hasAttachment = undefined;
562
+ }
563
+ if (hasAttachment == undefined) {
564
+ const file = message["files"]?.[0];
565
+ if (file == undefined) {
566
+ return Promise.reject(
567
+ new CometChat.CometChatException({
568
+ code: "Invalid Media message object",
569
+ message: "file object not found.",
570
+ })
571
+ );
572
+ }
573
+ const attachmentObject: CometChat.Attachment = new CometChat.Attachment(file);
574
+ attachmentObject.setName(file["name"]);
575
+ attachmentObject.setExtension((file["name"].lastIndexOf(".") + 1).toString());
576
+ attachmentObject.setMimeType(file["type"]);
577
+ attachmentObject.setSize(0);
578
+ attachmentObject.setUrl(file["uri"]);
579
+ message.setAttachment(attachmentObject);
580
+ }
581
+ }
582
+ } catch (error) {
583
+ return Promise.reject(error);
584
+ }
585
+ CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress);
586
+ return sendWithStatePromise(message, kind);
587
+ }
588
+
489
589
  static getDataSource() {
490
590
  return ChatConfigurator.getDataSource();
491
591
  }