@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.
- package/android/src/main/java/com/reactnativecometchatuikit/CometChatKeyboardModule.kt +101 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +78 -3
- package/android/src/main/java/com/reactnativecometchatuikit/KeyboardDirectionWatcher.kt +64 -0
- package/android/src/main/java/com/reactnativecometchatuikit/KeyboardLanguageDirection.kt +44 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +287 -49
- package/android/src/main/java/com/reactnativecometchatuikit/SafeFileName.java +78 -0
- package/ios/CCLocalFileGuard.h +19 -0
- package/ios/CCLocalFileGuard.m +34 -0
- package/ios/CometChatKeyboardModule.m +9 -0
- package/ios/CometChatKeyboardModule.swift +71 -0
- package/ios/FileManager.m +70 -6
- package/ios/KeyboardLanguageDirection.swift +24 -0
- package/ios/RichTextEditorView.swift +253 -51
- package/ios/RichTextEditorViewManager.m +1 -0
- package/ios/VideoManager.m +1 -1
- package/package.json +18 -3
- package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +41 -57
- package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +4 -1
- package/src/CometChatAIAssistantChatHistory/style.ts +5 -2
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +145 -63
- package/src/CometChatCompactMessageComposer/styles.ts +7 -7
- package/src/CometChatConversations/CometChatConversations.tsx +276 -147
- package/src/CometChatConversations/Skeleton.tsx +4 -1
- package/src/CometChatConversations/style.ts +1 -1
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +39 -18
- package/src/CometChatGroupMembers/Skeleton.tsx +4 -1
- package/src/CometChatGroupMembers/style.ts +6 -4
- package/src/CometChatGroups/CometChatGroups.tsx +74 -58
- package/src/CometChatGroups/GroupsStyle.ts +1 -1
- package/src/CometChatGroups/Skeleton.tsx +4 -1
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +190 -96
- package/src/CometChatMessageComposer/styles.tsx +1 -1
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +28 -15
- package/src/CometChatMessageHeader/listners.ts +76 -56
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -1
- package/src/CometChatMessageInformation/Skeleton.tsx +4 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +1465 -313
- package/src/CometChatMessageList/SwipeToReplyView.tsx +61 -0
- package/src/CometChatMessageList/style.ts +32 -32
- package/src/CometChatMessageList/swipeToReply.ts +25 -0
- package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +81 -10
- package/src/CometChatNotificationFeed/style.ts +1 -1
- package/src/CometChatNotificationFeed/utils.ts +17 -18
- package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +82 -3
- package/src/CometChatPinnedMessages/style.ts +5 -5
- package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +2 -0
- package/src/CometChatRichTextEditor/index.tsx +3 -0
- package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +83 -15
- package/src/CometChatSavedMessages/style.ts +3 -3
- package/src/CometChatSearch/CometChatSearch.tsx +391 -136
- package/src/CometChatSearch/Skeleton.tsx +4 -1
- package/src/CometChatSearch/searchLabels.ts +26 -0
- package/src/CometChatSearch/style.ts +7 -7
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +34 -8
- package/src/CometChatThreadHeader/Header.tsx +2 -2
- package/src/CometChatUsers/CometChatUsers.tsx +10 -1
- package/src/CometChatUsers/Skeleton.tsx +4 -1
- package/src/CometChatUsers/style.ts +1 -1
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +27 -1
- package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +16 -4
- package/src/calls/CometChatCallLogs/Skeleton.tsx +4 -1
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +11 -3
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +10 -2
- package/src/extensions/CollaborativeBubble/style.ts +4 -4
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +11 -6
- package/src/extensions/LinkPreview/style.ts +6 -6
- package/src/extensions/Polls/Header.tsx +1 -1
- package/src/extensions/Polls/Polls.tsx +25 -12
- package/src/extensions/Polls/PollsBubble.tsx +10 -6
- package/src/extensions/Polls/style.ts +4 -4
- package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +2 -2
- package/src/extensions/Stickers/CometChatStickerKeyboard/Skeleton.tsx +1 -1
- package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +1 -1
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +4 -2
- package/src/index.ts +11 -1
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +102 -2
- package/src/shared/CometChatUiKit/UIKitSettings.ts +28 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +10 -0
- package/src/shared/events/index.ts +4 -0
- package/src/shared/events/offline.ts +28 -0
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +18 -13
- package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +15 -7
- package/src/shared/formatters/CometChatTextFormatter.ts +11 -0
- package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +7 -4
- package/src/shared/framework/MessageDataSource.tsx +51 -108
- package/src/shared/helper/LocalizedDateHelper.ts +64 -4
- package/src/shared/helper/helperFunctions.ts +71 -4
- package/src/shared/helper/keyboardDirection.ts +54 -0
- package/src/shared/helper/layoutDirection.ts +205 -0
- package/src/shared/helper/pluralRules.ts +67 -0
- package/src/shared/helper/textDirection.ts +118 -0
- package/src/shared/icons/Icon.tsx +37 -2
- package/src/shared/icons/components/format-list-numbered-rtl.tsx +15 -0
- package/src/shared/index.ts +2 -0
- package/src/shared/offline/OfflineHub.ts +651 -0
- package/src/shared/offline/OfflineMediaBubble.tsx +49 -0
- package/src/shared/offline/OfflineViews.tsx +222 -0
- package/src/shared/offline/conversationPins.ts +137 -0
- package/src/shared/offline/conversations.ts +325 -0
- package/src/shared/offline/frameProbe.ts +24 -0
- package/src/shared/offline/gate.ts +94 -0
- package/src/shared/offline/groupActions.ts +81 -0
- package/src/shared/offline/identity.ts +162 -0
- package/src/shared/offline/index.ts +76 -0
- package/src/shared/offline/media.ts +247 -0
- package/src/shared/offline/notices.ts +84 -0
- package/src/shared/offline/reconcile.ts +296 -0
- package/src/shared/offline/searchOutcome.ts +62 -0
- package/src/shared/offline/send.ts +430 -0
- package/src/shared/offline/stateContract.ts +85 -0
- package/src/shared/offline/threadReplies.ts +125 -0
- package/src/shared/offline/twoPhase.ts +372 -0
- package/src/shared/offline/unsentActions.ts +168 -0
- package/src/shared/offline/useOfflineMediaUri.ts +87 -0
- package/src/shared/offline/useOfflineReconnect.ts +25 -0
- package/src/shared/offline/useOfflineSessionEnded.ts +22 -0
- package/src/shared/offline/useOfflineUploadTray.ts +76 -0
- package/src/shared/offline/usePresenceHidden.ts +33 -0
- package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +2 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/ar/translation.json +720 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +75 -4
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +75 -4
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +82 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +90 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +74 -3
- package/src/shared/services/UploadQueueService.ts +106 -1
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +13 -12
- package/src/shared/utils/CometChatMessagePreview/style.ts +1 -1
- package/src/shared/utils/MessageReceiptUtils.ts +8 -0
- package/src/shared/utils/MessageUtils.tsx +14 -14
- package/src/shared/utils/PermissionUtil.ts +16 -5
- package/src/shared/utils/SavedMessagesHelper.ts +18 -1
- package/src/shared/utils/attachmentLimits.ts +3 -2
- package/src/shared/utils/catchUpCursor.ts +36 -0
- package/src/shared/utils/conversationUtils.ts +3 -5
- package/src/shared/utils/failedMessageRetry.ts +73 -0
- package/src/shared/utils/fileIconFontSize.ts +10 -0
- package/src/shared/utils/fileSizeLabel.ts +16 -0
- package/src/shared/utils/groupActionText.ts +75 -0
- package/src/shared/utils/messageIdentity.ts +38 -0
- package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +12 -8
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +1 -1
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +5 -3
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +22 -17
- package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +45 -12
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +16 -10
- package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +20 -8
- package/src/shared/views/CometChatBadge/CometChatBadge.tsx +8 -4
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +6 -2
- package/src/shared/views/CometChatComposerErrorBanner.tsx +3 -1
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +8 -3
- package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +2 -2
- package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +5 -3
- package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +8 -8
- package/src/shared/views/CometChatEmojiKeyboard/style.ts +2 -2
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +13 -27
- package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +65 -15
- package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +7 -3
- package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +56 -25
- package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +41 -21
- package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +7 -3
- package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +7 -3
- package/src/shared/views/CometChatList/CometChatList.tsx +478 -21
- package/src/shared/views/CometChatList/Header.tsx +5 -2
- package/src/shared/views/CometChatList/sectionLetter.ts +44 -0
- package/src/shared/views/CometChatList/styles.ts +7 -7
- package/src/shared/views/CometChatListItem/CometChatListItem.tsx +6 -4
- package/src/shared/views/CometChatMediaRecorder/CometChatAudioPlayer.tsx +16 -10
- package/src/shared/views/CometChatMediaRecorder/Timer.tsx +5 -1
- package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +43 -16
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +24 -4
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +19 -2
- package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +3 -2
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +59 -12
- package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +2 -2
- package/src/shared/views/CometChatReactionList/Skeleton.tsx +4 -1
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +6 -2
- package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +7 -3
- package/src/shared/views/CometChatReportDialog/style.ts +1 -1
- package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +1 -1
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +4 -0
- package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +20 -13
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -2
- package/src/shared/views/CometChatSuggestionList/Skeleton.tsx +1 -1
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +29 -3
- package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +20 -30
- package/src/shared/views/CometChatTooltipMenu/tooltipPosition.ts +43 -0
- package/src/shared/views/CometChatVideoBubble/style.ts +2 -2
- package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +4 -1
- package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +58 -24
- package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +24 -12
- package/src/shared/views/SenderLabel.tsx +41 -0
- package/src/theme/default/default.ts +1 -1
- package/src/theme/type.ts +17 -0
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
|
@@ -68,13 +68,31 @@ import { useTheme } from "../theme";
|
|
|
68
68
|
import { Skeleton } from "./Skeleton";
|
|
69
69
|
import { ConversationStyle, Style } from "./style";
|
|
70
70
|
import MessageReceiptUtils from "../shared/utils/MessageReceiptUtils";
|
|
71
|
+
import { OfflineHub } from "../shared/offline/OfflineHub";
|
|
72
|
+
import {
|
|
73
|
+
failStrandedPreviews,
|
|
74
|
+
forgetStrandedPreview,
|
|
75
|
+
isFilteredConversationRequest,
|
|
76
|
+
refreshPreviewAfterDiscard,
|
|
77
|
+
routeIncomingMessage,
|
|
78
|
+
strandedPreviewsToRestore,
|
|
79
|
+
} from "../shared/offline/conversations";
|
|
80
|
+
import { dispatchSweptGroupAction } from "../shared/offline/groupActions";
|
|
81
|
+
import { resolveTwoPhase } from "../shared/offline/twoPhase";
|
|
82
|
+
import { isOfflineOn, offlineSdk } from "../shared/offline/gate";
|
|
83
|
+
import { conversationRowTestID } from "../shared/offline/stateContract";
|
|
84
|
+
import { onRemotePinEvent } from "../shared/offline/conversationPins";
|
|
85
|
+
import { OfflineNoticeView, useOfflineNotice } from "../shared/offline/OfflineViews";
|
|
71
86
|
import { deepMerge } from "../shared/helper/helperFunctions";
|
|
87
|
+
import { sentenceWithNames, stripBidiControls } from "../shared/helper/textDirection";
|
|
88
|
+
import { SenderLabel } from "../shared/views/SenderLabel";
|
|
72
89
|
import Delete from "../shared/icons/components/delete";
|
|
73
90
|
import { DeepPartial } from "../shared/helper/types";
|
|
74
91
|
import { CometChatTheme } from "../theme/type";
|
|
75
92
|
import { MenuItemInterface } from "../shared/views/CometChatTooltipMenu/CometChatTooltipMenu";
|
|
76
93
|
import { JSX } from "react";
|
|
77
94
|
import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
|
|
95
|
+
import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection, TEXT_START } from "../shared/helper/layoutDirection";
|
|
78
96
|
|
|
79
97
|
let __listenerIdCounter = 0;
|
|
80
98
|
|
|
@@ -92,6 +110,8 @@ const conversationRichTextFormatter = new CometChatRichTextFormatter();
|
|
|
92
110
|
* Interface defining props for the CometChatConversations component.
|
|
93
111
|
*/
|
|
94
112
|
export interface ConversationInterface {
|
|
113
|
+
/** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
|
|
114
|
+
layoutDirection?: "ltr" | "rtl";
|
|
95
115
|
/**
|
|
96
116
|
* Hide the submit (selection) button.
|
|
97
117
|
*/
|
|
@@ -185,6 +205,11 @@ export interface ConversationInterface {
|
|
|
185
205
|
* Hide error view.
|
|
186
206
|
*/
|
|
187
207
|
hideError?: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Offline support: hide the one-line notices (cache rebuilt, unsent messages lost). Has no
|
|
210
|
+
* effect with offline off. Default `false`.
|
|
211
|
+
*/
|
|
212
|
+
hideOfflineNotices?: boolean;
|
|
188
213
|
/**
|
|
189
214
|
* Callback for when a conversation item is pressed.
|
|
190
215
|
*/
|
|
@@ -299,6 +324,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
299
324
|
SubtitleView,
|
|
300
325
|
TrailingView,
|
|
301
326
|
hideError = false,
|
|
327
|
+
hideOfflineNotices = false,
|
|
302
328
|
onItemPress,
|
|
303
329
|
onItemLongPress,
|
|
304
330
|
onError,
|
|
@@ -319,6 +345,8 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
319
345
|
searchText = "",
|
|
320
346
|
SearchView,
|
|
321
347
|
} = props;
|
|
348
|
+
// ENG-41333: own setting → enclosing component → global; drives the root and the context.
|
|
349
|
+
const direction = useComponentLayoutDirection(props.layoutDirection);
|
|
322
350
|
|
|
323
351
|
// Reference for accessing CometChatList methods
|
|
324
352
|
const conversationListRef = React.useRef<CometChatListActionsInterface>(null);
|
|
@@ -661,7 +689,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
661
689
|
if (isTyping && !newConversation?.["lastMessage"]?.["typing"]) {
|
|
662
690
|
newConversation["lastMessage"]["typing"] =
|
|
663
691
|
args[0]?.receiverType === "group"
|
|
664
|
-
?
|
|
692
|
+
? sentenceWithNames(`\${name} ${t("IS_TYPING")}`, { name: args[0].sender.name })
|
|
665
693
|
: t("IS_TYPING");
|
|
666
694
|
} else {
|
|
667
695
|
delete newConversation["lastMessage"]["typing"];
|
|
@@ -766,7 +794,11 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
766
794
|
* Updates the conversation with a new message and moves it to the top of the list.
|
|
767
795
|
* @param newMessage - The new message to update.
|
|
768
796
|
*/
|
|
769
|
-
|
|
797
|
+
/**
|
|
798
|
+
* @param countUnread false for a message the SDK's catch-up sweep delivered (offline ON): the
|
|
799
|
+
* synced conversation counts already include it (UIK-SYNC-02).
|
|
800
|
+
*/
|
|
801
|
+
const updateLastMessage = (newMessage: CometChat.BaseMessage, countUnread: boolean = true) => {
|
|
770
802
|
CometChat.CometChatHelper.getConversationFromMessage(newMessage)
|
|
771
803
|
.then((conversation) => {
|
|
772
804
|
if (newMessage.getCategory() === MessageCategoryConstants.interactive) {
|
|
@@ -780,6 +812,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
780
812
|
CometChat.CometChatHelper.getConversationFromMessage(newMessage)
|
|
781
813
|
.then((newConversation) => {
|
|
782
814
|
if (
|
|
815
|
+
countUnread &&
|
|
783
816
|
newConversation?.getLastMessage().getSender().getUid() !==
|
|
784
817
|
loggedInUser.current?.getUid()
|
|
785
818
|
)
|
|
@@ -814,7 +847,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
814
847
|
}
|
|
815
848
|
// Update last message and unread count.
|
|
816
849
|
oldConversation.setLastMessage(newMessage);
|
|
817
|
-
if (newMessage.getSender().getUid() != loggedInUser.current?.getUid())
|
|
850
|
+
if (countUnread && newMessage.getSender().getUid() != loggedInUser.current?.getUid())
|
|
818
851
|
oldConversation.setUnreadMessageCount(oldConversation.getUnreadMessageCount() + 1);
|
|
819
852
|
placeConversation(CommonUtils.clone(oldConversation));
|
|
820
853
|
})
|
|
@@ -850,7 +883,9 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
850
883
|
if (message.hasOwnProperty("deletedAt")) return;
|
|
851
884
|
|
|
852
885
|
if (shouldMarkAsDelivered(message)) {
|
|
853
|
-
CometChat.markAsDelivered(message)
|
|
886
|
+
CometChat.markAsDelivered(message).catch((error: any) => {
|
|
887
|
+
console.log("Error marking message as delivered", error);
|
|
888
|
+
});
|
|
854
889
|
playNotificationSound();
|
|
855
890
|
}
|
|
856
891
|
};
|
|
@@ -1164,7 +1199,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1164
1199
|
messageText = (
|
|
1165
1200
|
<View style={conversationPreviewStyles.blockquoteRow}>
|
|
1166
1201
|
<View style={[conversationPreviewStyles.blockquoteBar, { backgroundColor: theme?.color?.primary as string }]} />
|
|
1167
|
-
<Text numberOfLines={1} ellipsizeMode='tail' style={[mergedStyles.itemStyle.subtitleStyle, conversationPreviewStyles.blockquoteText]}>
|
|
1202
|
+
<Text numberOfLines={1} ellipsizeMode='tail' style={[TEXT_START, mergedStyles.itemStyle.subtitleStyle, conversationPreviewStyles.blockquoteText]}>
|
|
1168
1203
|
{messageText}
|
|
1169
1204
|
</Text>
|
|
1170
1205
|
</View>
|
|
@@ -1172,7 +1207,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1172
1207
|
} else if (blockType === 'list') {
|
|
1173
1208
|
messageText = (
|
|
1174
1209
|
<Text
|
|
1175
|
-
style={[mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
|
|
1210
|
+
style={[TEXT_START, mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
|
|
1176
1211
|
numberOfLines={1}
|
|
1177
1212
|
ellipsizeMode='tail'
|
|
1178
1213
|
>
|
|
@@ -1182,7 +1217,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1182
1217
|
} else if (messageText && typeof messageText === 'string') {
|
|
1183
1218
|
messageText = (
|
|
1184
1219
|
<Text
|
|
1185
|
-
style={[mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
|
|
1220
|
+
style={[TEXT_START, mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
|
|
1186
1221
|
numberOfLines={1}
|
|
1187
1222
|
ellipsizeMode='tail'
|
|
1188
1223
|
>
|
|
@@ -1193,7 +1228,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1193
1228
|
// JSX element from rich text formatter — wrap with truncation
|
|
1194
1229
|
messageText = (
|
|
1195
1230
|
<Text
|
|
1196
|
-
style={[mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
|
|
1231
|
+
style={[TEXT_START, mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
|
|
1197
1232
|
numberOfLines={1}
|
|
1198
1233
|
ellipsizeMode='tail'
|
|
1199
1234
|
>
|
|
@@ -1202,28 +1237,23 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1202
1237
|
);
|
|
1203
1238
|
}
|
|
1204
1239
|
|
|
1205
|
-
let
|
|
1240
|
+
let groupSender = "";
|
|
1206
1241
|
if (!(lastMessage instanceof CometChat.Action)) {
|
|
1207
1242
|
if (lastMessage.getReceiverType() == ReceiverTypeConstants.group) {
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
}
|
|
1243
|
+
groupSender =
|
|
1244
|
+
lastMessage.getSender().getUid() == loggedInUserId
|
|
1245
|
+
? t("YOU")
|
|
1246
|
+
: lastMessage.getSender().getName();
|
|
1213
1247
|
}
|
|
1214
1248
|
}
|
|
1215
1249
|
|
|
1216
1250
|
return (
|
|
1217
1251
|
<>
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
>
|
|
1224
|
-
{groupText}
|
|
1225
|
-
</Text>
|
|
1226
|
-
)}
|
|
1252
|
+
<SenderLabel
|
|
1253
|
+
name={groupSender}
|
|
1254
|
+
textStyle={mergedStyles.itemStyle.subtitleStyle}
|
|
1255
|
+
containerStyle={conversationPreviewStyles.subtitleClamp}
|
|
1256
|
+
/>
|
|
1227
1257
|
{messageText}
|
|
1228
1258
|
</>
|
|
1229
1259
|
);
|
|
@@ -1297,7 +1327,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1297
1327
|
if (!lastMessage)
|
|
1298
1328
|
return (
|
|
1299
1329
|
<Text
|
|
1300
|
-
style={[mergedStyles.itemStyle.subtitleStyle]}
|
|
1330
|
+
style={[TEXT_START, mergedStyles.itemStyle.subtitleStyle]}
|
|
1301
1331
|
numberOfLines={1}
|
|
1302
1332
|
ellipsizeMode={"tail"}
|
|
1303
1333
|
>
|
|
@@ -1311,7 +1341,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1311
1341
|
<Text
|
|
1312
1342
|
numberOfLines={1}
|
|
1313
1343
|
ellipsizeMode={"tail"}
|
|
1314
|
-
style={[mergedStyles.typingIndicatorStyle]}
|
|
1344
|
+
style={[TEXT_START, mergedStyles.typingIndicatorStyle]}
|
|
1315
1345
|
>
|
|
1316
1346
|
{params.typingText}
|
|
1317
1347
|
</Text>
|
|
@@ -1390,7 +1420,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1390
1420
|
<View
|
|
1391
1421
|
accessible={true}
|
|
1392
1422
|
accessibilityLabel={t("PINNED") ?? "Pinned"}
|
|
1393
|
-
style={{
|
|
1423
|
+
style={{ marginEnd: theme.spacing.margin.m1 }}
|
|
1394
1424
|
>
|
|
1395
1425
|
<Icon name='keep-fill' color={theme.color.iconSecondary} height={14} width={14} />
|
|
1396
1426
|
</View>
|
|
@@ -1426,7 +1456,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1426
1456
|
<View
|
|
1427
1457
|
accessible={true}
|
|
1428
1458
|
accessibilityLabel={t("PINNED") ?? "Pinned"}
|
|
1429
|
-
style={{
|
|
1459
|
+
style={{ marginEnd: theme.spacing.margin.m1 }}
|
|
1430
1460
|
>
|
|
1431
1461
|
<Icon name='keep-fill' color={theme.color.iconSecondary} height={14} width={14} />
|
|
1432
1462
|
</View>
|
|
@@ -1498,6 +1528,108 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1498
1528
|
return oldConversation;
|
|
1499
1529
|
};
|
|
1500
1530
|
|
|
1531
|
+
// Offline (ON path): an own pending send moves its chat to the top with that preview
|
|
1532
|
+
// (BEH-CONV-01); a failed one keeps the preview with its failed mark. Private hub channel,
|
|
1533
|
+
// inert while offline is off.
|
|
1534
|
+
const offlineSendStateRef = React.useRef<(event: any) => void>(() => {});
|
|
1535
|
+
// Kill switch (UIK-LIFE-03): previews the SDK dropped when offline turned off.
|
|
1536
|
+
const strandedPreviewsRef = React.useRef(new Map<string, any>());
|
|
1537
|
+
const usedOfflineRef = React.useRef(false);
|
|
1538
|
+
const failStrandedPreviewsRef = React.useRef<() => void>(() => {});
|
|
1539
|
+
failStrandedPreviewsRef.current = () => {
|
|
1540
|
+
const hub = OfflineHub.getInstance();
|
|
1541
|
+
const rows = conversationListRef.current?.getAllListItems?.() ?? [];
|
|
1542
|
+
const count = failStrandedPreviews(rows, strandedPreviewsRef.current, hub);
|
|
1543
|
+
if (count > 0) hub.notify({ kind: "messages_not_sent", count, previewsOnly: true });
|
|
1544
|
+
};
|
|
1545
|
+
offlineSendStateRef.current = (event: any) => {
|
|
1546
|
+
if (event.gen !== OfflineHub.getInstance().gen) return;
|
|
1547
|
+
if (event.state === "sent" || event.state === "discarded") forgetStrandedPreview(strandedPreviewsRef.current, event.message);
|
|
1548
|
+
if (event.state === "discarded") {
|
|
1549
|
+
// The SDK moved this chat's preview back (or removed a local-only chat): show its answer.
|
|
1550
|
+
void refreshPreviewAfterDiscard(event.message, {
|
|
1551
|
+
rows: () => conversationListRef.current?.getAllListItems?.() ?? [],
|
|
1552
|
+
fetchConversation: (withId: string, type: string) =>
|
|
1553
|
+
resolveTwoPhase<CometChat.Conversation>(
|
|
1554
|
+
(listener) => offlineSdk().getConversation(withId, type, listener),
|
|
1555
|
+
"Conversation"
|
|
1556
|
+
).catch((e: any) => {
|
|
1557
|
+
if (e?.code === "ERR_CONVERSATION_NOT_ACCESSIBLE" || e?.code === "ERR_CONVERSATION_NOT_FOUND") return null;
|
|
1558
|
+
throw e;
|
|
1559
|
+
}),
|
|
1560
|
+
update: (row: any) => conversationListRef.current?.updateList(CommonUtils.clone(row)),
|
|
1561
|
+
remove: (id: string) => conversationListRef.current?.removeItemFromList(id),
|
|
1562
|
+
});
|
|
1563
|
+
return;
|
|
1564
|
+
}
|
|
1565
|
+
if (event.state !== "sending" && event.state !== "failed") return;
|
|
1566
|
+
const message = event.message;
|
|
1567
|
+
if (!message || message.getParentMessageId?.()) return;
|
|
1568
|
+
if (!shouldUpdateLastMessageAndUnreadCount(message)) return;
|
|
1569
|
+
updateLastMessage(message, false);
|
|
1570
|
+
};
|
|
1571
|
+
React.useEffect(() => {
|
|
1572
|
+
const hub = OfflineHub.getInstance();
|
|
1573
|
+
usedOfflineRef.current = isOfflineOn();
|
|
1574
|
+
const subscriptions = [
|
|
1575
|
+
hub.sendState$.subscribe((e) => {
|
|
1576
|
+
usedOfflineRef.current = true;
|
|
1577
|
+
offlineSendStateRef.current(e);
|
|
1578
|
+
}),
|
|
1579
|
+
hub.connected$.subscribe(() => {
|
|
1580
|
+
if (isOfflineOn()) {
|
|
1581
|
+
usedOfflineRef.current = true;
|
|
1582
|
+
return;
|
|
1583
|
+
}
|
|
1584
|
+
// Offline was on and is off now. A list that never used offline does nothing at all.
|
|
1585
|
+
if (!usedOfflineRef.current) return;
|
|
1586
|
+
// After this tick's other connection listeners: an open chat counts its own rows first.
|
|
1587
|
+
setTimeout(() => failStrandedPreviewsRef.current(), 0);
|
|
1588
|
+
}),
|
|
1589
|
+
hub.session$.subscribe(() => strandedPreviewsRef.current.clear()),
|
|
1590
|
+
];
|
|
1591
|
+
return () => subscriptions.forEach((s) => s.unsubscribe());
|
|
1592
|
+
}, []);
|
|
1593
|
+
// Offline (ON path): a pin or unpin made on another device or by an admin moves the row
|
|
1594
|
+
// (UIK-CONV-01). The gate is read per event; with offline off the event is ignored, as the
|
|
1595
|
+
// release before it did. Own pins keep updating from the pin call's onSuccess.
|
|
1596
|
+
const remotePinRef = React.useRef<(event: any) => void>(() => {});
|
|
1597
|
+
remotePinRef.current = (event: any) => {
|
|
1598
|
+
onRemotePinEvent(event, {
|
|
1599
|
+
rows: () => conversationListRef.current?.getAllListItems?.() ?? [],
|
|
1600
|
+
place: placeConversation,
|
|
1601
|
+
clone: (row: any) => CommonUtils.clone(row),
|
|
1602
|
+
loggedInUid: () => loggedInUser.current?.getUid?.(),
|
|
1603
|
+
filtered: () => !!searchText || isFilteredConversationRequest(conversationsRequestBuilder),
|
|
1604
|
+
fetchConversation: (withId: string, type: string) => CometChat.getConversation(withId, type),
|
|
1605
|
+
});
|
|
1606
|
+
};
|
|
1607
|
+
React.useEffect(() => {
|
|
1608
|
+
const subscription = OfflineHub.getInstance().conversationPin$.subscribe((e) => remotePinRef.current(e));
|
|
1609
|
+
return () => subscription.unsubscribe();
|
|
1610
|
+
}, []);
|
|
1611
|
+
const { notice: offlineNotice, dismiss: dismissOfflineNotice } = useOfflineNotice(
|
|
1612
|
+
!hideOfflineNotices,
|
|
1613
|
+
// Session-wide notices (cache rebuilt, sends lost) belong on the chat list.
|
|
1614
|
+
(n) => !n.conversationId && !n.message
|
|
1615
|
+
);
|
|
1616
|
+
|
|
1617
|
+
/**
|
|
1618
|
+
* Every incoming message, whatever its category: a swept (SYNC, offline ON) message updates
|
|
1619
|
+
* the preview only (no sound, no unread +1, no receipt; UIK-SYNC-02); a live one runs today's
|
|
1620
|
+
* handling.
|
|
1621
|
+
*/
|
|
1622
|
+
const onIncomingMessage = (message: any) => {
|
|
1623
|
+
routeIncomingMessage(message, {
|
|
1624
|
+
accepts: shouldUpdateLastMessageAndUnreadCount,
|
|
1625
|
+
previewOnly: (m: any) => updateLastMessage(m, false),
|
|
1626
|
+
live: (m: any) => {
|
|
1627
|
+
messageEventHandler(m);
|
|
1628
|
+
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
|
|
1629
|
+
},
|
|
1630
|
+
});
|
|
1631
|
+
};
|
|
1632
|
+
|
|
1501
1633
|
// Set up event listeners for user, call, group and message events.
|
|
1502
1634
|
React.useEffect(() => {
|
|
1503
1635
|
// Get logged in user.
|
|
@@ -1584,83 +1716,88 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1584
1716
|
);
|
|
1585
1717
|
|
|
1586
1718
|
// Listen for group events.
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1719
|
+
const groupListenerHandlers = {
|
|
1720
|
+
onGroupMemberScopeChanged: (
|
|
1721
|
+
message: CometChat.Action,
|
|
1722
|
+
changedUser: CometChat.GroupMember,
|
|
1723
|
+
newScope: CometChat.GroupMemberScope,
|
|
1724
|
+
oldScope: CometChat.GroupMemberScope,
|
|
1725
|
+
changedGroup: CometChat.Group
|
|
1726
|
+
) => {
|
|
1727
|
+
groupHandler(message, {
|
|
1728
|
+
action: "scopeChange",
|
|
1729
|
+
actionOn: changedUser,
|
|
1730
|
+
newScope: newScope,
|
|
1731
|
+
oldScope: oldScope,
|
|
1732
|
+
group: changedGroup,
|
|
1733
|
+
});
|
|
1734
|
+
},
|
|
1735
|
+
onGroupMemberKicked: (
|
|
1736
|
+
message: CometChat.Action,
|
|
1737
|
+
kickedUser: CometChat.User,
|
|
1738
|
+
kickedBy: CometChat.User,
|
|
1739
|
+
kickedFrom: CometChat.Group
|
|
1740
|
+
) => {
|
|
1741
|
+
groupHandler(message, {
|
|
1742
|
+
action: "kicked",
|
|
1743
|
+
actionOn: kickedUser,
|
|
1744
|
+
actionBy: kickedBy,
|
|
1745
|
+
group: kickedFrom,
|
|
1746
|
+
});
|
|
1747
|
+
},
|
|
1748
|
+
onGroupMemberLeft: (
|
|
1749
|
+
message: CometChat.Action,
|
|
1750
|
+
leavingUser: CometChat.User,
|
|
1751
|
+
group: CometChat.Group
|
|
1752
|
+
) => {
|
|
1753
|
+
groupHandler(message, { action: "left", actionOn: leavingUser, group });
|
|
1754
|
+
},
|
|
1755
|
+
onGroupMemberUnbanned: (message: CometChat.Action) => {
|
|
1756
|
+
groupHandler(message);
|
|
1757
|
+
},
|
|
1758
|
+
onGroupMemberBanned: (
|
|
1759
|
+
message: CometChat.Action,
|
|
1760
|
+
bannedUser: CometChat.User,
|
|
1761
|
+
bannedBy: CometChat.User,
|
|
1762
|
+
bannedFrom: CometChat.Group
|
|
1763
|
+
) => {
|
|
1764
|
+
groupHandler(message, {
|
|
1765
|
+
action: "banned",
|
|
1766
|
+
actionOn: bannedUser,
|
|
1767
|
+
actionBy: bannedBy,
|
|
1768
|
+
group: bannedFrom,
|
|
1769
|
+
});
|
|
1770
|
+
},
|
|
1771
|
+
onMemberAddedToGroup: (
|
|
1772
|
+
message: CometChat.Action,
|
|
1773
|
+
userAdded: CometChat.User,
|
|
1774
|
+
userAddedBy: CometChat.User,
|
|
1775
|
+
userAddedIn: CometChat.Group
|
|
1776
|
+
) => {
|
|
1777
|
+
if (onMemberAddedToGroupDebounceTimer.current) {
|
|
1778
|
+
clearTimeout(onMemberAddedToGroupDebounceTimer.current);
|
|
1779
|
+
}
|
|
1780
|
+
onMemberAddedToGroupDebounceTimer.current = setTimeout(() => {
|
|
1634
1781
|
groupHandler(message, {
|
|
1635
|
-
action: "
|
|
1636
|
-
actionOn:
|
|
1637
|
-
actionBy:
|
|
1638
|
-
group:
|
|
1782
|
+
action: "joined",
|
|
1783
|
+
actionOn: userAdded,
|
|
1784
|
+
actionBy: userAddedBy,
|
|
1785
|
+
group: userAddedIn,
|
|
1639
1786
|
});
|
|
1640
|
-
},
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
actionBy: userAddedBy,
|
|
1655
|
-
group: userAddedIn,
|
|
1656
|
-
});
|
|
1657
|
-
}, 50);
|
|
1658
|
-
},
|
|
1659
|
-
onGroupMemberJoined: (message: CometChat.Action) => {
|
|
1660
|
-
groupHandler(message);
|
|
1661
|
-
},
|
|
1662
|
-
})
|
|
1663
|
-
);
|
|
1787
|
+
}, 50);
|
|
1788
|
+
},
|
|
1789
|
+
onGroupMemberJoined: (message: CometChat.Action) => {
|
|
1790
|
+
groupHandler(message);
|
|
1791
|
+
},
|
|
1792
|
+
};
|
|
1793
|
+
CometChat.addGroupListener(groupListenerId, new CometChat.GroupListener(groupListenerHandlers));
|
|
1794
|
+
// Offline (ON path): a group action the catch-up sweep delivered while the device was offline
|
|
1795
|
+
// (me kicked, banned or removed) fires no GroupListener callback; run the same handlers for it,
|
|
1796
|
+
// so that conversation leaves the list as it would have live (UIT-SYNC-13). Inert with offline off.
|
|
1797
|
+
const sweptGroupActions = OfflineHub.getInstance().groupActionSwept$.subscribe((event) => {
|
|
1798
|
+
if (event.gen !== OfflineHub.getInstance().gen) return;
|
|
1799
|
+
dispatchSweptGroupAction(event.message, groupListenerHandlers);
|
|
1800
|
+
});
|
|
1664
1801
|
|
|
1665
1802
|
// Listen for conversation deletion events.
|
|
1666
1803
|
CometChatUIEventHandler.addConversationListener(conversationListenerId, {
|
|
@@ -1704,25 +1841,13 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1704
1841
|
checkAndUpdateLastMessage(message);
|
|
1705
1842
|
},
|
|
1706
1843
|
onTextMessageReceived: (textMessage: CometChat.TextMessage) => {
|
|
1707
|
-
|
|
1708
|
-
return;
|
|
1709
|
-
}
|
|
1710
|
-
messageEventHandler(textMessage);
|
|
1711
|
-
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
|
|
1844
|
+
onIncomingMessage(textMessage);
|
|
1712
1845
|
},
|
|
1713
1846
|
onMediaMessageReceived: (mediaMessage: CometChat.MediaMessage) => {
|
|
1714
|
-
|
|
1715
|
-
return;
|
|
1716
|
-
}
|
|
1717
|
-
messageEventHandler(mediaMessage);
|
|
1718
|
-
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
|
|
1847
|
+
onIncomingMessage(mediaMessage);
|
|
1719
1848
|
},
|
|
1720
1849
|
onCustomMessageReceived: (customMessage: CometChat.CustomMessage) => {
|
|
1721
|
-
|
|
1722
|
-
return;
|
|
1723
|
-
}
|
|
1724
|
-
messageEventHandler(customMessage);
|
|
1725
|
-
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
|
|
1850
|
+
onIncomingMessage(customMessage);
|
|
1726
1851
|
},
|
|
1727
1852
|
onMessageDeleted: (deletedMessage: CometChat.BaseMessage) => {
|
|
1728
1853
|
// Skip thread replies — they don't affect conversation unread count
|
|
@@ -1751,41 +1876,21 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1751
1876
|
typingEventHandler(typingIndicator, false);
|
|
1752
1877
|
},
|
|
1753
1878
|
onFormMessageReceived: (formMessage: any) => {
|
|
1754
|
-
|
|
1755
|
-
return;
|
|
1756
|
-
}
|
|
1757
|
-
messageEventHandler(formMessage);
|
|
1758
|
-
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
|
|
1879
|
+
onIncomingMessage(formMessage);
|
|
1759
1880
|
},
|
|
1760
1881
|
onCardMessageReceived: (cardMessage: any) => {
|
|
1761
|
-
|
|
1762
|
-
return;
|
|
1763
|
-
}
|
|
1764
|
-
messageEventHandler(cardMessage);
|
|
1765
|
-
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
|
|
1882
|
+
onIncomingMessage(cardMessage);
|
|
1766
1883
|
},
|
|
1767
1884
|
onSchedulerMessageReceived: (schedulerMessage: any) => {
|
|
1768
|
-
|
|
1769
|
-
return;
|
|
1770
|
-
}
|
|
1771
|
-
messageEventHandler(schedulerMessage);
|
|
1772
|
-
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
|
|
1885
|
+
onIncomingMessage(schedulerMessage);
|
|
1773
1886
|
},
|
|
1774
1887
|
onCustomInteractiveMessageReceived: (customInteractiveMessage: any) => {
|
|
1775
|
-
|
|
1776
|
-
return;
|
|
1777
|
-
}
|
|
1778
|
-
messageEventHandler(customInteractiveMessage);
|
|
1779
|
-
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
|
|
1888
|
+
onIncomingMessage(customInteractiveMessage);
|
|
1780
1889
|
},
|
|
1781
1890
|
// Agent (agentic/assistant) reply — update the conversation's last message + unread
|
|
1782
1891
|
// count in real time, otherwise the subtitle only refreshes after a re-fetch.
|
|
1783
1892
|
onAIAssistantMessageReceived: (aiAssistantMessage: any) => {
|
|
1784
|
-
|
|
1785
|
-
return;
|
|
1786
|
-
}
|
|
1787
|
-
messageEventHandler(aiAssistantMessage);
|
|
1788
|
-
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
|
|
1893
|
+
onIncomingMessage(aiAssistantMessage);
|
|
1789
1894
|
},
|
|
1790
1895
|
onMessageModerated: (moderatedMessage: CometChat.BaseMessage) => {
|
|
1791
1896
|
checkAndUpdateLastMessage(moderatedMessage);
|
|
@@ -1981,6 +2086,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1981
2086
|
CometChat.removeUserListener(userListenerId);
|
|
1982
2087
|
CometChat.removeCallListener(callListenerId);
|
|
1983
2088
|
CometChat.removeGroupListener(groupListenerId);
|
|
2089
|
+
sweptGroupActions.unsubscribe();
|
|
1984
2090
|
CometChatUIEventHandler.removeMessageListener(messageListenerId);
|
|
1985
2091
|
CometChatUIEventHandler.removeConversationListener(conversationListenerId);
|
|
1986
2092
|
CometChatUIEventHandler.removeGroupListener(groupListenerId);
|
|
@@ -2050,9 +2156,9 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
2050
2156
|
<Text
|
|
2051
2157
|
numberOfLines={1}
|
|
2052
2158
|
ellipsizeMode='tail'
|
|
2053
|
-
style={mergedStyles.itemStyle.titleStyle}
|
|
2159
|
+
style={[TEXT_START, mergedStyles.itemStyle.titleStyle]}
|
|
2054
2160
|
>
|
|
2055
|
-
{conversationWith.getName()}
|
|
2161
|
+
{stripBidiControls(conversationWith.getName())}
|
|
2056
2162
|
</Text>
|
|
2057
2163
|
</View>
|
|
2058
2164
|
);
|
|
@@ -2082,7 +2188,8 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
2082
2188
|
}, [getTrailingView, getPinOnlyTrailingView]);
|
|
2083
2189
|
|
|
2084
2190
|
return (
|
|
2085
|
-
<
|
|
2191
|
+
<LayoutDirectionContext.Provider value={direction}>
|
|
2192
|
+
<View style={[mergedStyles.containerStyle, directionStyle(direction)]}>
|
|
2086
2193
|
<CometChatList
|
|
2087
2194
|
AppBarOptions={AppBarOptions}
|
|
2088
2195
|
onError={onError}
|
|
@@ -2123,10 +2230,15 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
2123
2230
|
}
|
|
2124
2231
|
}}
|
|
2125
2232
|
listItemKey={"conversationId"}
|
|
2233
|
+
// The id carries the peer's uid/guid: built only with offline support on, so a release build
|
|
2234
|
+
// with it off has rows exactly as before the offline work.
|
|
2235
|
+
itemTestID={isOfflineOn() ? conversationRowTestID : undefined}
|
|
2126
2236
|
LoadingView={LoadingView ?? (() => <Skeleton style={mergedStyles.skeletonStyle} />)}
|
|
2127
2237
|
ItemView={ItemView}
|
|
2128
2238
|
EmptyView={EmptyView ? EmptyView : () => <EmptyStateView />}
|
|
2239
|
+
customEmptyView={!!EmptyView}
|
|
2129
2240
|
ErrorView={ErrorView ? ErrorView : () => <ErrorStateView />}
|
|
2241
|
+
customErrorView={!!ErrorView}
|
|
2130
2242
|
onBack={onBack}
|
|
2131
2243
|
hideBackButton={hideBackButton}
|
|
2132
2244
|
onSelection={onSelection}
|
|
@@ -2134,6 +2246,12 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
2134
2246
|
selectionMode={selectionMode}
|
|
2135
2247
|
hideError={hideError}
|
|
2136
2248
|
onListFetched={(conversations: CometChat.Conversation[]) => {
|
|
2249
|
+
// Kill switch: a refetch with offline off must not take a failed preview back.
|
|
2250
|
+
if (strandedPreviewsRef.current.size > 0) {
|
|
2251
|
+
strandedPreviewsToRestore(conversations, strandedPreviewsRef.current).forEach((m) =>
|
|
2252
|
+
updateLastMessage(m, false)
|
|
2253
|
+
);
|
|
2254
|
+
}
|
|
2137
2255
|
if (conversations.length === 0) {
|
|
2138
2256
|
onEmpty?.();
|
|
2139
2257
|
} else {
|
|
@@ -2198,7 +2316,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
2198
2316
|
...(deleteConversationOptionVisibility
|
|
2199
2317
|
? [
|
|
2200
2318
|
{
|
|
2201
|
-
text: "
|
|
2319
|
+
text: t("DELETE"),
|
|
2202
2320
|
onPress: () => {
|
|
2203
2321
|
setConfirmDelete(longPressId.current);
|
|
2204
2322
|
setTooltipVisible(false);
|
|
@@ -2253,7 +2371,18 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
2253
2371
|
{/* Without this the useToast hook runs but nothing ever appears — the
|
|
2254
2372
|
conversation pin/unpin toasts and every error message are invisible. */}
|
|
2255
2373
|
{ToastElement}
|
|
2374
|
+
{offlineNotice && !hideOfflineNotices ? (
|
|
2375
|
+
<OfflineNoticeView
|
|
2376
|
+
notice={offlineNotice}
|
|
2377
|
+
t={t}
|
|
2378
|
+
onDismiss={dismissOfflineNotice}
|
|
2379
|
+
containerStyle={theme.messageListStyles?.offlineStyles?.noticeStyle?.containerStyle}
|
|
2380
|
+
textStyle={theme.messageListStyles?.offlineStyles?.noticeStyle?.textStyle}
|
|
2381
|
+
actionTextStyle={theme.messageListStyles?.offlineStyles?.noticeStyle?.actionTextStyle}
|
|
2382
|
+
/>
|
|
2383
|
+
) : null}
|
|
2256
2384
|
</View>
|
|
2385
|
+
</LayoutDirectionContext.Provider>
|
|
2257
2386
|
);
|
|
2258
2387
|
};
|
|
2259
2388
|
|
|
@@ -2289,7 +2418,7 @@ const conversationPreviewStyles = StyleSheet.create({
|
|
|
2289
2418
|
width: 3,
|
|
2290
2419
|
borderRadius: 1.5,
|
|
2291
2420
|
marginVertical: 3,
|
|
2292
|
-
|
|
2421
|
+
marginStart: 4,
|
|
2293
2422
|
},
|
|
2294
2423
|
blockquoteText: {
|
|
2295
2424
|
flex: 1,
|