@cometchat/chat-uikit-react-native 5.4.1 → 5.5.1
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/CometChatClipboardModule.kt +34 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +562 -5
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +28 -1
- package/ios/CometChatClipboardModule.m +5 -0
- package/ios/CometChatClipboardModule.swift +22 -0
- package/ios/RichTextEditorView.swift +636 -31
- package/ios/RichTextEditorViewManager.m +3 -0
- package/ios/RichTextEditorViewManager.swift +24 -0
- package/package.json +5 -2
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +283 -64
- package/src/CometChatCompactMessageComposer/index.ts +2 -0
- package/src/CometChatConversations/CometChatConversations.tsx +299 -15
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +2 -2
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +15 -3
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +181 -12
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +10 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +572 -16
- package/src/CometChatMessageList/components/MessageModals.tsx +30 -0
- package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +21 -9
- package/src/CometChatMessageList/components/MessageQuickActions.tsx +162 -0
- package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +964 -0
- package/src/CometChatPinnedMessages/index.ts +5 -0
- package/src/CometChatPinnedMessages/style.ts +216 -0
- package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +5 -0
- package/src/CometChatRichTextEditor/index.tsx +31 -1
- package/src/CometChatRichTextEditor/types.ts +21 -1
- package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +871 -0
- package/src/CometChatSavedMessages/index.ts +5 -0
- package/src/CometChatSavedMessages/style.ts +159 -0
- package/src/CometChatSearch/CometChatSearch.tsx +71 -341
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +22 -2
- package/src/index.ts +60 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +18 -1
- package/src/shared/base/Types.ts +5 -0
- package/src/shared/constants/UIKitConstants.ts +16 -17
- package/src/shared/constants/textPatterns.ts +27 -0
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +25 -225
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +37 -0
- package/src/shared/events/ListenerInitializer.ts +20 -1
- package/src/shared/events/messages.ts +18 -0
- package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +123 -25
- package/src/shared/formatters/CometChatTextFormatter.ts +22 -0
- package/src/shared/formatters/applyRawFormatters.ts +31 -0
- package/src/shared/formatters/index.ts +14 -0
- package/src/shared/formatters/richTextWireFormat.ts +165 -0
- package/src/shared/framework/MessageDataSource.tsx +309 -10
- package/src/shared/icons/components/thread-follow.tsx +13 -0
- package/src/shared/icons/components/thread-unfollow.tsx +13 -0
- package/src/shared/icons/components/unsave.tsx +13 -0
- package/src/shared/icons/icon-mapping.tsx +6 -0
- package/src/shared/index.ts +37 -0
- package/src/shared/resources/CometChatLocalizeNew/CometChatI18nProvider.tsx +15 -30
- package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +138 -19
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +74 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +54 -1
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +11 -0
- package/src/shared/utils/MarkdownUtils.ts +57 -6
- package/src/shared/utils/MessageUtils.tsx +80 -5
- package/src/shared/utils/PinConversationHelper.ts +245 -0
- package/src/shared/utils/PinSaveFeatureGates.ts +178 -0
- package/src/shared/utils/PinSaveHelper.ts +549 -0
- package/src/shared/utils/PinnedMessagesHelper.ts +65 -0
- package/src/shared/utils/SavedMessagesHelper.ts +267 -0
- package/src/shared/utils/ThreadSubscriptionHelper.ts +427 -0
- package/src/shared/utils/__testUtils__/messagesRequestBuilderMock.ts +37 -0
- package/src/shared/utils/cloneRequestBuilder.ts +25 -0
- package/src/shared/utils/conversationUtils.ts +8 -1
- package/src/shared/utils/stripRichText.ts +7 -0
- package/src/shared/views/ClipboardPasteHandler/ClipboardPasteHandler.ts +32 -0
- package/src/shared/views/ClipboardPasteHandler/NativeCometChatClipboardModule.ts +6 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +4 -0
- package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +5 -0
- package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +17 -5
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +5 -1
- package/src/shared/views/CometChatCaptionText/CometChatCaptionText.tsx +8 -1
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +2 -0
- package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +91 -20
- package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +5 -0
- package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +5 -0
- package/src/shared/views/CometChatList/CometChatList.tsx +6 -1
- package/src/shared/views/CometChatList/Header.tsx +8 -2
- package/src/shared/views/CometChatListItem/CometChatListItem.tsx +4 -0
- package/src/shared/views/CometChatRetryButton/CometChatRetryButton.tsx +1 -0
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +4 -0
- package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +5 -0
- package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +5 -0
- package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +4 -1
- package/src/theme/default/default.ts +6 -0
- package/src/theme/type.ts +4 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
let __listenerIdCounter = 0;
|
|
2
2
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
3
|
-
import
|
|
3
|
+
import { ClipboardPasteHandler } from "../shared/views/ClipboardPasteHandler/ClipboardPasteHandler";
|
|
4
|
+
import { applyRawFormatters } from "../shared/formatters/applyRawFormatters";
|
|
4
5
|
import React, {
|
|
5
6
|
forwardRef,
|
|
6
7
|
JSX,
|
|
@@ -67,7 +68,7 @@ import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandle
|
|
|
67
68
|
import { MessageEvents } from "../shared/events/messages";
|
|
68
69
|
import { ChatConfigurator } from "../shared/framework/ChatConfigurator";
|
|
69
70
|
import { deepClone, deepMerge } from "../shared/helper/helperFunctions";
|
|
70
|
-
import { Icon } from "../shared/icons/Icon";
|
|
71
|
+
import { Icon, IconName } from "../shared/icons/Icon";
|
|
71
72
|
import { CometChatMessageTemplate } from "../shared/modals/CometChatMessageTemplate";
|
|
72
73
|
import { getUnixTimestamp, messageStatus } from "../shared/utils/CometChatMessageHelper";
|
|
73
74
|
import { CommonUtils } from "../shared/utils/CommonUtils";
|
|
@@ -103,12 +104,38 @@ import { CometChatAIAssistantTools } from "../shared/modals/CometChatAIAssistant
|
|
|
103
104
|
import { StreamMessage } from "../shared/modals";
|
|
104
105
|
import { internalMessageDataSource } from "../shared/framework/MessageDataSource";
|
|
105
106
|
import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
|
|
107
|
+
import { useToast } from "../shared/helper/useToast";
|
|
108
|
+
import {
|
|
109
|
+
applyEditedMessage,
|
|
110
|
+
applyIncomingReply,
|
|
111
|
+
applyOwnIncomingMessage,
|
|
112
|
+
applySentMessage,
|
|
113
|
+
getThreadIdFor,
|
|
114
|
+
stampThreadSubscribed,
|
|
115
|
+
toggleThreadSubscription,
|
|
116
|
+
} from "../shared/utils/ThreadSubscriptionHelper";
|
|
106
117
|
import { MessageModals } from "./components/MessageModals";
|
|
107
118
|
import { ReactionModals } from "./components/ReactionModals";
|
|
108
119
|
import { MessageOptionsSheet } from "./components/MessageOptionsSheet";
|
|
109
120
|
import { MessageListItem } from "./components/MessageListItem";
|
|
110
121
|
import CometChatConversationStarter from "../shared/views/CometChatConversationStarter/CometChatConversationStarter";
|
|
111
122
|
import CometChatSmartReplies from "../shared/views/CometChatSmartReplies/CometChatSmartReplies";
|
|
123
|
+
import {
|
|
124
|
+
applyPinSaveAnswer,
|
|
125
|
+
isPinned,
|
|
126
|
+
isSaved,
|
|
127
|
+
isPermissionError,
|
|
128
|
+
isModerationPending,
|
|
129
|
+
isCapError,
|
|
130
|
+
isFeatureOffError,
|
|
131
|
+
resolveCapLimit,
|
|
132
|
+
pinMessage as sdkPinMessage,
|
|
133
|
+
unpinMessage as sdkUnpinMessage,
|
|
134
|
+
saveMessage as sdkSaveMessage,
|
|
135
|
+
unsaveMessage as sdkUnsaveMessage,
|
|
136
|
+
pinSaveNeedsConfirm,
|
|
137
|
+
carryPinSaveAttrs,
|
|
138
|
+
} from "../shared/utils/PinSaveHelper";
|
|
112
139
|
|
|
113
140
|
let _defaultRequestBuilder: CometChat.MessagesRequestBuilder;
|
|
114
141
|
const AVERAGE_ITEM_LENGTH = 120;
|
|
@@ -194,8 +221,23 @@ function batchStateUpdates(callback: () => void): void {
|
|
|
194
221
|
export interface CometChatMessageListProps {
|
|
195
222
|
/**
|
|
196
223
|
* ID of the parent message when rendering threaded messages.
|
|
224
|
+
*
|
|
225
|
+
* @deprecated Pass {@link CometChatMessageListProps.parentMessage} instead. An id cannot
|
|
226
|
+
* answer "is this thread followed right now", so a reply arriving over the socket — which
|
|
227
|
+
* carries no `threadSubscribed` flag — cannot be corrected from it. This prop is still
|
|
228
|
+
* honoured when `parentMessage` is absent, and all existing scoping behaviour is
|
|
229
|
+
* unchanged; it is a deprecation to document, not to remove.
|
|
197
230
|
*/
|
|
198
231
|
parentMessageId?: string;
|
|
232
|
+
/**
|
|
233
|
+
* The parent message when rendering threaded messages. Supersedes
|
|
234
|
+
* {@link CometChatMessageListProps.parentMessageId} — it scopes the list identically and
|
|
235
|
+
* additionally acts as the thread's subscription authority, so each realtime reply can be
|
|
236
|
+
* stamped from it (mention → subscribed; otherwise inherit the parent's state).
|
|
237
|
+
*
|
|
238
|
+
* Re-pass it when the parent updates, so the list reads a current flag.
|
|
239
|
+
*/
|
|
240
|
+
parentMessage?: CometChat.BaseMessage;
|
|
199
241
|
/**
|
|
200
242
|
* The user object associated with the message list.
|
|
201
243
|
*/
|
|
@@ -428,6 +470,29 @@ export interface CometChatMessageListProps {
|
|
|
428
470
|
* Flag to hide the reply in thread option
|
|
429
471
|
*/
|
|
430
472
|
hideReplyInThreadOption?: boolean;
|
|
473
|
+
/**
|
|
474
|
+
* Flag to hide the follow/unfollow thread option. Independent of the thread
|
|
475
|
+
* header's own control — an integrator may legitimately want one surface and
|
|
476
|
+
* not the other. Both are additionally subject to the feature gate
|
|
477
|
+
* (`ThreadSubscriptionConfig.setEnabled`), which is off by default.
|
|
478
|
+
*/
|
|
479
|
+
hideThreadSubscriptionOption?: boolean;
|
|
480
|
+
/**
|
|
481
|
+
* Flags to hide the Pin / Unpin / Save / Unsave options (design doc §6.7).
|
|
482
|
+
*
|
|
483
|
+
* One flag per option rather than one per pair, because hiding half of a pair is a real
|
|
484
|
+
* configuration: a read-only pinned list is "pin, never unpin from here", and an
|
|
485
|
+
* integrator curating pins centrally wants Unpin gone while Pin stays.
|
|
486
|
+
*
|
|
487
|
+
* These are ANDed with the server's own answer — CometChatUIKit resolves
|
|
488
|
+
* `isPinMessageEnabled()` / `isSaveMessageEnabled()` on login, and an app whose plan has
|
|
489
|
+
* the feature off hides the options whatever these say. Turning a flag off here is an
|
|
490
|
+
* integrator's choice on top of that, never a way to switch the feature on.
|
|
491
|
+
*/
|
|
492
|
+
hidePinMessageOption?: boolean;
|
|
493
|
+
hideUnpinMessageOption?: boolean;
|
|
494
|
+
hideSaveMessageOption?: boolean;
|
|
495
|
+
hideUnsaveMessageOption?: boolean;
|
|
431
496
|
/**
|
|
432
497
|
* Flag to hide the share message option
|
|
433
498
|
*/
|
|
@@ -680,7 +745,8 @@ export const CometChatMessageList = memo(
|
|
|
680
745
|
forwardRef<CometChatMessageListActionsInterface, CometChatMessageListProps>(
|
|
681
746
|
(props: CometChatMessageListProps, ref) => {
|
|
682
747
|
const {
|
|
683
|
-
parentMessageId,
|
|
748
|
+
parentMessageId: parentMessageIdProp,
|
|
749
|
+
parentMessage,
|
|
684
750
|
user,
|
|
685
751
|
group,
|
|
686
752
|
EmptyView,
|
|
@@ -717,6 +783,11 @@ export const CometChatMessageList = memo(
|
|
|
717
783
|
enableMultipleAttachments = true,
|
|
718
784
|
hideReplyOption: propHideReplyOption = false,
|
|
719
785
|
hideReplyInThreadOption: propHideReplyInThreadOption = false,
|
|
786
|
+
hideThreadSubscriptionOption = false,
|
|
787
|
+
hidePinMessageOption = false,
|
|
788
|
+
hideUnpinMessageOption = false,
|
|
789
|
+
hideSaveMessageOption = false,
|
|
790
|
+
hideUnsaveMessageOption = false,
|
|
720
791
|
hideShareMessageOption: propHideShareMessageOption = false,
|
|
721
792
|
hideEditMessageOption: propHideEditMessageOption = false,
|
|
722
793
|
hideTranslateMessageOption: propHideTranslateMessageOption = false,
|
|
@@ -750,6 +821,17 @@ export const CometChatMessageList = memo(
|
|
|
750
821
|
loadLastAgentConversation = false,
|
|
751
822
|
} = props;
|
|
752
823
|
|
|
824
|
+
// §5.6 — `parentMessage` supersedes `parentMessageId`, and the id is derived from it so
|
|
825
|
+
// every existing scoping path below is untouched. The deprecated prop is still honoured
|
|
826
|
+
// when the object is absent, so old callers keep working exactly as before.
|
|
827
|
+
const parentMessageId = useMemo(
|
|
828
|
+
() =>
|
|
829
|
+
parentMessage?.getId?.() != null
|
|
830
|
+
? String(parentMessage.getId())
|
|
831
|
+
: parentMessageIdProp,
|
|
832
|
+
[parentMessage, parentMessageIdProp]
|
|
833
|
+
);
|
|
834
|
+
|
|
753
835
|
// Helper to check if user is agentic - memoized as boolean for performance
|
|
754
836
|
const isAgenticUser = useMemo(() => {
|
|
755
837
|
return user?.getRole?.() === "@agentic";
|
|
@@ -783,6 +865,7 @@ export const CometChatMessageList = memo(
|
|
|
783
865
|
const streamListenerId = "agent_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
784
866
|
const deleteItem = useRef<CometChat.BaseMessage>(undefined);
|
|
785
867
|
const shouldSuppressHighlightRef = useRef(false);
|
|
868
|
+
const { showToast, ToastElement } = useToast();
|
|
786
869
|
|
|
787
870
|
useLayoutEffect(() => {
|
|
788
871
|
// For agent chats (non-thread), don't set up message request builder
|
|
@@ -1064,6 +1147,15 @@ export const CometChatMessageList = memo(
|
|
|
1064
1147
|
const [selectedEmoji, setSelectedEmoji] = useState<string | undefined>(undefined);
|
|
1065
1148
|
const [hideScrollToBottomButton, setHideScrollToBottomButton] = useState<boolean>(true);
|
|
1066
1149
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
|
1150
|
+
/**
|
|
1151
|
+
* The pending unpin/unsave awaiting confirmation, or null. Carries the message
|
|
1152
|
+
* with it rather than leaning on `selectedMessage`, which the options sheet
|
|
1153
|
+
* clears on dismiss — the dialog outlives the sheet that launched it.
|
|
1154
|
+
*/
|
|
1155
|
+
const [pinSaveConfirm, setPinSaveConfirm] = useState<{
|
|
1156
|
+
message: CometChat.BaseMessage;
|
|
1157
|
+
action: "unpin" | "unsave";
|
|
1158
|
+
} | null>(null);
|
|
1067
1159
|
|
|
1068
1160
|
const infoObject = useRef<CometChat.BaseMessage | null>(undefined);
|
|
1069
1161
|
const [highlightedMessageId, setHighlightedMessageId] = useState<string | null>(null);
|
|
@@ -1330,6 +1422,10 @@ export const CometChatMessageList = memo(
|
|
|
1330
1422
|
});
|
|
1331
1423
|
}
|
|
1332
1424
|
if (previousMessagesFetched.length > 0) {
|
|
1425
|
+
// These came from a FETCH, so each already carries the server's
|
|
1426
|
+
// threadSubscribed answer on itself — parent and replies alike (§5.7).
|
|
1427
|
+
// Nothing to seed: the fetched object IS the state, and replacing the held
|
|
1428
|
+
// object is what makes a fetched flag beat a local mirror.
|
|
1333
1429
|
messagesContentListRef.current = [
|
|
1334
1430
|
...messagesContentListRef.current,
|
|
1335
1431
|
...previousMessagesFetched,
|
|
@@ -1743,6 +1839,14 @@ export const CometChatMessageList = memo(
|
|
|
1743
1839
|
enableMultipleAttachments,
|
|
1744
1840
|
hideReplyOption: isAgenticUserCheck || hideReplyOption,
|
|
1745
1841
|
hideReplyInThreadOption: isAgenticUserCheck || hideReplyInThreadOption,
|
|
1842
|
+
hideThreadSubscriptionOption: isAgenticUserCheck || hideThreadSubscriptionOption,
|
|
1843
|
+
// Without these three lines the four props above are inert: validateOption reads
|
|
1844
|
+
// them off `additionalParams`, which is THIS object, so a flag that never gets
|
|
1845
|
+
// forwarded is always undefined and the option always renders.
|
|
1846
|
+
hidePinMessageOption: isAgenticUserCheck || hidePinMessageOption,
|
|
1847
|
+
hideUnpinMessageOption: isAgenticUserCheck || hideUnpinMessageOption,
|
|
1848
|
+
hideSaveMessageOption: isAgenticUserCheck || hideSaveMessageOption,
|
|
1849
|
+
hideUnsaveMessageOption: isAgenticUserCheck || hideUnsaveMessageOption,
|
|
1746
1850
|
hideShareMessageOption: isAgenticUserCheck || hideShareMessageOption,
|
|
1747
1851
|
hideEditMessageOption: isAgenticUserCheck || hideEditMessageOption,
|
|
1748
1852
|
hideTranslateMessageOption: isAgenticUserCheck || hideTranslateMessageOption,
|
|
@@ -1752,6 +1856,12 @@ export const CometChatMessageList = memo(
|
|
|
1752
1856
|
hideCopyMessageOption: isAgenticUserCheck || hideCopyMessageOption,
|
|
1753
1857
|
hideMessageInfoOption: isAgenticUserCheck || hideMessageInfoOption || !receiptsVisibility,
|
|
1754
1858
|
hideFlagMessageOption: isAgenticUserCheck || hideFlagMessageOption,
|
|
1859
|
+
// The gate calls this one `hideReportMessageOption` while the public prop is
|
|
1860
|
+
// `hideFlagMessageOption` — same option, two names. Report was hidden anyway, but by
|
|
1861
|
+
// a post-filter further down rather than by the gate, leaving the gate's branch dead.
|
|
1862
|
+
// Forwarded under both names so the two agree and the option is never built in the
|
|
1863
|
+
// first place; the post-filter stays as the belt to this braces.
|
|
1864
|
+
hideReportMessageOption: isAgenticUserCheck || hideFlagMessageOption,
|
|
1755
1865
|
hideMarkAsUnreadOption: isAgenticUserCheck || hideMarkAsUnreadOption,
|
|
1756
1866
|
hideGroupActionMessages,
|
|
1757
1867
|
onReplyClick: (messageId: string) => {
|
|
@@ -1791,6 +1901,11 @@ export const CometChatMessageList = memo(
|
|
|
1791
1901
|
addTemplates,
|
|
1792
1902
|
isAgenticUser,
|
|
1793
1903
|
hideReplyInThreadOption,
|
|
1904
|
+
hideThreadSubscriptionOption,
|
|
1905
|
+
hidePinMessageOption,
|
|
1906
|
+
hideUnpinMessageOption,
|
|
1907
|
+
hideSaveMessageOption,
|
|
1908
|
+
hideUnsaveMessageOption,
|
|
1794
1909
|
hideShareMessageOption,
|
|
1795
1910
|
hideEditMessageOption,
|
|
1796
1911
|
hideTranslateMessageOption,
|
|
@@ -2057,6 +2172,32 @@ export const CometChatMessageList = memo(
|
|
|
2057
2172
|
|
|
2058
2173
|
const newMessage = (newMessage: any, isReceived = true) => {
|
|
2059
2174
|
let baseMessage = newMessage as CometChat.BaseMessage;
|
|
2175
|
+
|
|
2176
|
+
// Cases 2b/4b — a message I sent from ANOTHER of my devices. Sending subscribes me
|
|
2177
|
+
// wherever I sent it from, but this copy came over the socket and carries no flag, so
|
|
2178
|
+
// without this my own message reads "Subscribe" here until a refetch. Checked BEFORE
|
|
2179
|
+
// the reply rules and short-circuits them: "I sent this" already settles the question,
|
|
2180
|
+
// and a root message has no parentMessageId for the block below to notice at all.
|
|
2181
|
+
const ownIncoming =
|
|
2182
|
+
isReceived &&
|
|
2183
|
+
applyOwnIncomingMessage(baseMessage, loggedInUser.current?.getUid() ?? null);
|
|
2184
|
+
|
|
2185
|
+
// Case 3 plus the socket-`false` correction (§3.4). A reply off the socket carries no
|
|
2186
|
+
// threadSubscribed flag, so it must be stamped from the thread's authority: mentioned
|
|
2187
|
+
// → subscribed and publish; otherwise inherit whatever the parent currently says.
|
|
2188
|
+
// Prefer the `parentMessage` prop — in a thread view it IS the authority; fall back to
|
|
2189
|
+
// finding it in the list, which is the main-list case where it may be absent entirely.
|
|
2190
|
+
if (!ownIncoming && isReceived && baseMessage?.getParentMessageId?.()) {
|
|
2191
|
+
const parentId = Number(baseMessage.getParentMessageId());
|
|
2192
|
+
const parent =
|
|
2193
|
+
(Number(parentMessage?.getId?.()) === parentId ? parentMessage : null) ??
|
|
2194
|
+
messagesContentListRef.current.find(
|
|
2195
|
+
(msg: any) => Number(msg?.getId?.()) === parentId
|
|
2196
|
+
) ??
|
|
2197
|
+
null;
|
|
2198
|
+
applyIncomingReply(baseMessage, parent, loggedInUser.current?.getUid() ?? null);
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2060
2201
|
if (baseMessage.getCategory() === MessageCategoryConstants.interactive) {
|
|
2061
2202
|
//todo show unsupported bubble
|
|
2062
2203
|
}
|
|
@@ -2431,7 +2572,16 @@ export const CometChatMessageList = memo(
|
|
|
2431
2572
|
}
|
|
2432
2573
|
};
|
|
2433
2574
|
|
|
2434
|
-
|
|
2575
|
+
/**
|
|
2576
|
+
* @param pinSaveAuthoritative the incoming message IS the answer about pin/save state,
|
|
2577
|
+
* including the absence that means "no longer pinned". True for the pin/save
|
|
2578
|
+
* paths; false for an ordinary edit, whose response omits those fields entirely.
|
|
2579
|
+
*/
|
|
2580
|
+
const messageEdited = (
|
|
2581
|
+
editedMessage: CometChat.BaseMessage,
|
|
2582
|
+
withMuid: boolean = false,
|
|
2583
|
+
pinSaveAuthoritative: boolean = false
|
|
2584
|
+
) => {
|
|
2435
2585
|
let condition: (value: any, index: number, obj: any[]) => unknown;
|
|
2436
2586
|
if (withMuid) {
|
|
2437
2587
|
condition = (msg) => msg["muid"] == editedMessage["muid"];
|
|
@@ -2443,7 +2593,70 @@ export const CometChatMessageList = memo(
|
|
|
2443
2593
|
if (editedMessage.getCategory() === MessageCategoryConstants.interactive) {
|
|
2444
2594
|
//todo show unsupported bubble
|
|
2445
2595
|
}
|
|
2446
|
-
|
|
2596
|
+
// Two opposite readings of the same silence, so the two paths cannot share a rule.
|
|
2597
|
+
//
|
|
2598
|
+
// An EDIT response is a MINIMAL message carrying no pinnedAt / savedAt / pinnedBy:
|
|
2599
|
+
// its silence means "not mentioned", so those must be carried across or both
|
|
2600
|
+
// indicators vanish until the next fetch (ENG-38183).
|
|
2601
|
+
//
|
|
2602
|
+
// A PIN/UNPIN/SAVE/UNSAVE answer is the reverse: silence on pinnedAt means "no
|
|
2603
|
+
// longer pinned", so carrying the old value leaves the glyph on screen forever.
|
|
2604
|
+
// That path also must not swap the response INTO the list — it is partial and has
|
|
2605
|
+
// no muid, which changed the row key and remounted the whole bubble, reloading its
|
|
2606
|
+
// images on every pin. Instead keep the complete copy we hold and take only the
|
|
2607
|
+
// pin/save answer off the response; the quote rides along for free (ENG-38176).
|
|
2608
|
+
const replacement = pinSaveAuthoritative
|
|
2609
|
+
? applyPinSaveAnswer(messagesContentListRef.current[msgIndex], editedMessage)
|
|
2610
|
+
: carryPinSaveAttrs(
|
|
2611
|
+
CommonUtils.clone(editedMessage),
|
|
2612
|
+
messagesContentListRef.current[msgIndex]
|
|
2613
|
+
);
|
|
2614
|
+
|
|
2615
|
+
// The author default, applied at the one chokepoint every NON-FETCH replace goes
|
|
2616
|
+
// through — a send reconciling, an edit, a pin/save.
|
|
2617
|
+
//
|
|
2618
|
+
// None of those payloads ever carries threadSubscribed (the API populates it on
|
|
2619
|
+
// FETCHED messages only), so an absent flag HERE cannot mean "unsubscribed" — it
|
|
2620
|
+
// only means the response was silent. And if I sent the message, the server has me
|
|
2621
|
+
// subscribed to its thread. So filling the gap is reading the server's rule, not
|
|
2622
|
+
// guessing.
|
|
2623
|
+
//
|
|
2624
|
+
// Ordering is what makes it safe: the carry above runs FIRST, so an explicit false
|
|
2625
|
+
// — which is what a deliberate unsubscribe leaves on the held copy — is preserved
|
|
2626
|
+
// and never overwritten here. Only a genuinely absent value is filled.
|
|
2627
|
+
//
|
|
2628
|
+
// Doing it here rather than in the send handler is deliberate: stamping the send
|
|
2629
|
+
// RESPONSE only helps if that object survives into the list, and it does not — this
|
|
2630
|
+
// function replaces the list entry with a clone. The entry is what every surface
|
|
2631
|
+
// reads, so the entry is what has to carry the flag.
|
|
2632
|
+
// `!== true` rather than `=== undefined`: the SDK normalises the wire value, so an
|
|
2633
|
+
// unmentioned flag arrives as an explicit `false`, never as undefined. Checking for
|
|
2634
|
+
// undefined meant this never fired — verified from device logs, which showed the
|
|
2635
|
+
// replacement carrying `flag= false` on every composer send.
|
|
2636
|
+
//
|
|
2637
|
+
// That normalisation is also why the replacement alone cannot be trusted: on it,
|
|
2638
|
+
// "the response said nothing" and "the user deliberately unsubscribed" are the SAME
|
|
2639
|
+
// `false`. The comment above claimed the carry preserved an explicit false, but
|
|
2640
|
+
// preserveThreadSubscribed only ever raises false -> true; it never marks a false as
|
|
2641
|
+
// deliberate. So read the HELD copy, the one place the distinction survives —
|
|
2642
|
+
// ccThreadSubscriptionChanged stamps it there on an explicit unfollow. Without this,
|
|
2643
|
+
// unfollowing your own thread and then pinning, saving or editing that message put
|
|
2644
|
+
// you silently back to Following.
|
|
2645
|
+
const heldThreadSubscribed = (
|
|
2646
|
+
messagesContentListRef.current[msgIndex] as any
|
|
2647
|
+
)?.isThreadSubscribed?.();
|
|
2648
|
+
if (
|
|
2649
|
+
heldThreadSubscribed !== false &&
|
|
2650
|
+
(replacement as any)?.threadSubscribed !== true
|
|
2651
|
+
) {
|
|
2652
|
+
const senderUid = (replacement as any)?.getSender?.()?.getUid?.();
|
|
2653
|
+
const me = loggedInUser.current?.getUid();
|
|
2654
|
+
if (me && senderUid === me) {
|
|
2655
|
+
(replacement as any).threadSubscribed = true;
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
tmpList[msgIndex] = replacement;
|
|
2447
2660
|
messagesContentListRef.current = tmpList;
|
|
2448
2661
|
onLoad && onLoad([...messagesContentListRef.current].reverse());
|
|
2449
2662
|
setMessagesList(tmpList);
|
|
@@ -2478,6 +2691,133 @@ export const CometChatMessageList = memo(
|
|
|
2478
2691
|
});
|
|
2479
2692
|
};
|
|
2480
2693
|
|
|
2694
|
+
/**
|
|
2695
|
+
* Runs one pin/save write and folds the server's answer back into the list.
|
|
2696
|
+
*
|
|
2697
|
+
* ponytail: NOT optimistic. §7.4 asks for an optimistic flip with a revert
|
|
2698
|
+
* path, but every one of these calls resolves with the FULL updated message,
|
|
2699
|
+
* so applying that is both simpler and strictly more correct than guessing
|
|
2700
|
+
* the new state and reconciling later. It costs one round trip of latency
|
|
2701
|
+
* behind a modal the user just tapped through, and it deletes an entire
|
|
2702
|
+
* class of bug (stale optimistic state after a failed revert). Revisit if
|
|
2703
|
+
* the wait ever reads as lag on a slow network.
|
|
2704
|
+
*/
|
|
2705
|
+
const runPinSaveAction = (
|
|
2706
|
+
message: CometChat.BaseMessage,
|
|
2707
|
+
action: "pin" | "unpin" | "save" | "unsave"
|
|
2708
|
+
) => {
|
|
2709
|
+
const call =
|
|
2710
|
+
action === "pin"
|
|
2711
|
+
? sdkPinMessage
|
|
2712
|
+
: action === "unpin"
|
|
2713
|
+
? sdkUnpinMessage
|
|
2714
|
+
: action === "save"
|
|
2715
|
+
? sdkSaveMessage
|
|
2716
|
+
: sdkUnsaveMessage;
|
|
2717
|
+
|
|
2718
|
+
const successKey =
|
|
2719
|
+
action === "pin"
|
|
2720
|
+
? "MESSAGE_PINNED"
|
|
2721
|
+
: action === "unpin"
|
|
2722
|
+
? "MESSAGE_UNPINNED"
|
|
2723
|
+
: action === "save"
|
|
2724
|
+
? "MESSAGE_SAVED"
|
|
2725
|
+
: "MESSAGE_UNSAVED";
|
|
2726
|
+
|
|
2727
|
+
const ccEvent =
|
|
2728
|
+
action === "pin"
|
|
2729
|
+
? MessageEvents.ccMessagePinned
|
|
2730
|
+
: action === "unpin"
|
|
2731
|
+
? MessageEvents.ccMessageUnpinned
|
|
2732
|
+
: action === "save"
|
|
2733
|
+
? MessageEvents.ccMessageSaved
|
|
2734
|
+
: MessageEvents.ccMessageUnsaved;
|
|
2735
|
+
|
|
2736
|
+
call(message.getId())
|
|
2737
|
+
.then((updated: CometChat.BaseMessage) => {
|
|
2738
|
+
// The response body IS the answer about pin/save state on THIS device — including
|
|
2739
|
+
// the absence that means "no longer pinned". Marking it authoritative is what makes
|
|
2740
|
+
// unpin/unsave update the UI: otherwise carryPinSaveAttrs copies the old pinnedAt /
|
|
2741
|
+
// savedAt back onto the response and the glyph never clears. (Pin/save hid this —
|
|
2742
|
+
// they only ADD a field, so there is nothing for the carry to wrongly restore.)
|
|
2743
|
+
// The authoritative branch still carries `quotedMessage` across, which the pin
|
|
2744
|
+
// response drops and a pinned REPLY needs (ENG-38176).
|
|
2745
|
+
messageEdited(updated, false, true);
|
|
2746
|
+
CometChatUIEventHandler.emitMessageEvent(ccEvent, { message: updated });
|
|
2747
|
+
showToast(t(successKey) ?? successKey);
|
|
2748
|
+
})
|
|
2749
|
+
.catch(async (error: any) => {
|
|
2750
|
+
// Branch on the REAL backend codes (see PinSaveHelper.PinSaveErrors —
|
|
2751
|
+
// the design doc's names do not exist). Order matters: moderation
|
|
2752
|
+
// rejections must not be reported as permission problems.
|
|
2753
|
+
let messageText: string;
|
|
2754
|
+
if (isPermissionError(error) && isModerationPending(message)) {
|
|
2755
|
+
// Same 403 as a real permission refusal, different cause (ENG-38901). The
|
|
2756
|
+
// options are offered on a pending message deliberately — the check clears in
|
|
2757
|
+
// about two seconds and by then the action works — so the rare early tap must
|
|
2758
|
+
// say what actually happened rather than accuse the user of lacking rights.
|
|
2759
|
+
messageText =
|
|
2760
|
+
t("PIN_SAVE_MODERATION_PENDING") ??
|
|
2761
|
+
"This message is still being checked. Try again in a moment.";
|
|
2762
|
+
} else if (isPermissionError(error)) {
|
|
2763
|
+
messageText = t("PIN_NOT_ALLOWED") ?? "You don't have permission to pin messages here.";
|
|
2764
|
+
} else if (isFeatureOffError(error)) {
|
|
2765
|
+
messageText = t("PIN_SAVE_FEATURE_OFF") ?? "This feature isn't available for this app.";
|
|
2766
|
+
} else if (isCapError(error)) {
|
|
2767
|
+
// The cap is server-owned. Interpolate it ONLY when the payload
|
|
2768
|
+
// actually carries it — the backend documents the caps as tenant
|
|
2769
|
+
// settings and never promises them on the error, so the no-count
|
|
2770
|
+
// copy is the expected path, not an edge case. Printing a guessed
|
|
2771
|
+
// "100" would be worse than printing no number at all.
|
|
2772
|
+
const isPin = action === "pin";
|
|
2773
|
+
// errorParams first, then app settings (SDK getters, ENG-37790). Never the
|
|
2774
|
+
// error prose — that regex is gone.
|
|
2775
|
+
const limit = await resolveCapLimit(error, isPin ? "pin" : "save");
|
|
2776
|
+
if (limit !== null) {
|
|
2777
|
+
const template = isPin
|
|
2778
|
+
? t("PIN_LIMIT_REACHED") ??
|
|
2779
|
+
"You can only pin {limit} messages. Unpin one to pin another."
|
|
2780
|
+
: t("SAVE_LIMIT_REACHED") ?? "You can save up to {limit} messages.";
|
|
2781
|
+
messageText = template.replace("{limit}", String(limit));
|
|
2782
|
+
} else {
|
|
2783
|
+
messageText = isPin
|
|
2784
|
+
? t("PIN_LIMIT_REACHED_NO_COUNT") ??
|
|
2785
|
+
"You've reached your pinned messages limit. Unpin one to pin another."
|
|
2786
|
+
: t("SAVE_LIMIT_REACHED_NO_COUNT") ??
|
|
2787
|
+
"You've reached your limit for saved messages.";
|
|
2788
|
+
}
|
|
2789
|
+
} else {
|
|
2790
|
+
messageText = t("PIN_SAVE_GENERIC_ERROR") ?? "Something went wrong. Please try again.";
|
|
2791
|
+
}
|
|
2792
|
+
showToast(messageText);
|
|
2793
|
+
onError && onError(error);
|
|
2794
|
+
});
|
|
2795
|
+
};
|
|
2796
|
+
|
|
2797
|
+
/**
|
|
2798
|
+
* Confirm the REMOVING half of each pair, run the adding half straight away.
|
|
2799
|
+
*
|
|
2800
|
+
* Cross-platform decision (Jitvar, 2026-08-04): unpin and unsave ask; pin and
|
|
2801
|
+
* save do not. The asymmetry is the point — pinning or saving is additive and
|
|
2802
|
+
* its own undo is one tap away, whereas unpinning discards something the user
|
|
2803
|
+
* (or a colleague, in the case of a conversation-wide pin) deliberately put
|
|
2804
|
+
* there, and nothing on screen offers it back.
|
|
2805
|
+
*
|
|
2806
|
+
* All four kits follow this, so do not make it a local preference.
|
|
2807
|
+
*/
|
|
2808
|
+
const requestPinSaveAction = (
|
|
2809
|
+
message: CometChat.BaseMessage,
|
|
2810
|
+
action: "pin" | "unpin" | "save" | "unsave"
|
|
2811
|
+
) => {
|
|
2812
|
+
setShowMessageOptions([]);
|
|
2813
|
+
bottomSheetRef.current?.togglePanel();
|
|
2814
|
+
if (pinSaveNeedsConfirm(action)) {
|
|
2815
|
+
setPinSaveConfirm({ message, action: action as "unpin" | "unsave" });
|
|
2816
|
+
return;
|
|
2817
|
+
}
|
|
2818
|
+
runPinSaveAction(message, action);
|
|
2819
|
+
};
|
|
2820
|
+
|
|
2481
2821
|
const createActionMessage = () => { };
|
|
2482
2822
|
|
|
2483
2823
|
const updateMessageReceipt = (receipt: any) => {
|
|
@@ -2950,13 +3290,65 @@ export const CometChatMessageList = memo(
|
|
|
2950
3290
|
);
|
|
2951
3291
|
|
|
2952
3292
|
CometChatUIEventHandler.addMessageListener(messageEventListener, {
|
|
3293
|
+
// §3.2 — the bus is the only sync channel between surfaces, and subscribing to it
|
|
3294
|
+
// means writing the flag back onto the objects THIS list holds, not just
|
|
3295
|
+
// re-rendering. Without it a follow taken in the thread header leaves every bubble
|
|
3296
|
+
// in the list holding a stale object, and the next action sheet offers "Subscribe"
|
|
3297
|
+
// on a thread the user already follows.
|
|
3298
|
+
//
|
|
3299
|
+
// Keep this an INLINE arrow on this exact property: emitMessageEvent dispatches by
|
|
3300
|
+
// comparing the emitted name against the handler's inferred Function.name.
|
|
3301
|
+
ccThreadSubscriptionChanged: ({ parentMessageId: threadId, subscribed }: any) => {
|
|
3302
|
+
const target = Number(threadId);
|
|
3303
|
+
if (!target) return;
|
|
3304
|
+
messagesContentListRef.current.forEach((msg: any) => {
|
|
3305
|
+
if (getThreadIdFor(msg) === target) stampThreadSubscribed(msg, !!subscribed);
|
|
3306
|
+
});
|
|
3307
|
+
},
|
|
3308
|
+
// A pin or save made from the PINNED or SAVED panel reaches this list only through
|
|
3309
|
+
// the bus (ENG-38884). Those panels write to the server and update their own rows,
|
|
3310
|
+
// but the bubble behind them holds its own copy of the message — so unpinning from
|
|
3311
|
+
// the panel left the glyph sitting on a message that was no longer pinned, until
|
|
3312
|
+
// navigating away rebuilt the list from a fetch.
|
|
3313
|
+
//
|
|
3314
|
+
// messageEdited(..., pinSaveAuthoritative = true) is the same call this list makes
|
|
3315
|
+
// for its OWN pin/save writes: the response IS the answer, including the ABSENCE of
|
|
3316
|
+
// pinnedAt that means "no longer pinned". Re-applying an answer this list emitted
|
|
3317
|
+
// itself is harmless — it resolves to the identical object state.
|
|
3318
|
+
//
|
|
3319
|
+
// Inline arrows on these exact property names: emitMessageEvent dispatches by
|
|
3320
|
+
// comparing the emitted name against each handler's inferred Function.name.
|
|
3321
|
+
ccMessagePinned: ({ message }: any) => {
|
|
3322
|
+
if (message) messageEdited(message, false, true);
|
|
3323
|
+
},
|
|
3324
|
+
ccMessageUnpinned: ({ message }: any) => {
|
|
3325
|
+
if (message) messageEdited(message, false, true);
|
|
3326
|
+
},
|
|
3327
|
+
ccMessageSaved: ({ message }: any) => {
|
|
3328
|
+
if (message) messageEdited(message, false, true);
|
|
3329
|
+
},
|
|
3330
|
+
ccMessageUnsaved: ({ message }: any) => {
|
|
3331
|
+
if (message) messageEdited(message, false, true);
|
|
3332
|
+
},
|
|
2953
3333
|
ccMessageSent: ({ message, status }: any) => {
|
|
2954
3334
|
if (status == MessageStatusConstants.inprogress) {
|
|
2955
3335
|
newMessage(message, false);
|
|
2956
3336
|
}
|
|
2957
3337
|
|
|
2958
3338
|
if (status == MessageStatusConstants.success) {
|
|
3339
|
+
// Cases 2 and 4 — any message you send subscribes you to its thread server-side,
|
|
3340
|
+
// and your OWN sends never arrive on a listener. The send response omits the
|
|
3341
|
+
// flag, so this stamp is what makes the sender's own screen agree with the
|
|
3342
|
+
// server.
|
|
3343
|
+
//
|
|
3344
|
+
// ORDER MATTERS, and getting it wrong is silent. messageEdited() is what swaps
|
|
3345
|
+
// the optimistic bubble (keyed by muid, no server id yet) for the real message.
|
|
3346
|
+
// Until that has run, the list entry's id is not the thread id, so the
|
|
3347
|
+
// ccThreadSubscriptionChanged write-back has nothing to match on and the stamp
|
|
3348
|
+
// lands only on the response object — which the list then discards. Stamp AFTER
|
|
3349
|
+
// the swap, when the entry the surfaces actually read carries its server id.
|
|
2959
3350
|
messageEdited(message, true);
|
|
3351
|
+
applySentMessage(message);
|
|
2960
3352
|
if (
|
|
2961
3353
|
isAgenticUser &&
|
|
2962
3354
|
agenticParentMessageIdRef.current === undefined &&
|
|
@@ -2977,6 +3369,10 @@ export const CometChatMessageList = memo(
|
|
|
2977
3369
|
},
|
|
2978
3370
|
ccMessageEdited: ({ message, status }: any) => {
|
|
2979
3371
|
if (status == messageStatus.success) {
|
|
3372
|
+
// Case 5 — an edit that leaves me @mentioned subscribes me to that message's
|
|
3373
|
+
// thread. Hooked HERE and not inside messageEdited(): deletes and reaction
|
|
3374
|
+
// updates travel through that same helper and must not subscribe anybody.
|
|
3375
|
+
applyEditedMessage(message, loggedInUser.current?.getUid() ?? null);
|
|
2980
3376
|
messageEdited(message, false);
|
|
2981
3377
|
}
|
|
2982
3378
|
},
|
|
@@ -3042,7 +3438,7 @@ export const CometChatMessageList = memo(
|
|
|
3042
3438
|
onMessagesRead: (messageReceipt: any) => {
|
|
3043
3439
|
updateMessageReceipt(messageReceipt);
|
|
3044
3440
|
},
|
|
3045
|
-
|
|
3441
|
+
|
|
3046
3442
|
onMessageDeleted: (deletedMessage: any) => {
|
|
3047
3443
|
// If the deleted message was unread, decrement the unread count
|
|
3048
3444
|
if (!deletedMessage.getReadAt?.() && deletedMessage.getSender()?.getUid() !== loggedInUser.current?.getUid()) {
|
|
@@ -3051,8 +3447,48 @@ export const CometChatMessageList = memo(
|
|
|
3051
3447
|
messageEdited(deletedMessage);
|
|
3052
3448
|
},
|
|
3053
3449
|
onMessageEdited: (editedMessage: any) => {
|
|
3450
|
+
// Case 5b — somebody else edited their message and I am now mentioned in it.
|
|
3451
|
+
applyEditedMessage(editedMessage, loggedInUser.current?.getUid() ?? null);
|
|
3054
3452
|
messageEdited(editedMessage);
|
|
3055
3453
|
},
|
|
3454
|
+
// Pin & Save realtime (§6.6). Each event carries the full updated message,
|
|
3455
|
+
// so the same list-replace the edit path uses is all that is needed —
|
|
3456
|
+
// the meta-row indicator re-renders off the new object.
|
|
3457
|
+
//
|
|
3458
|
+
// LIVE for GROUPS as of 2026-08-10. A note from the backend team
|
|
3459
|
+
// (ENG-37690, 2026-07-29) said realtime was not wired up; that went stale
|
|
3460
|
+
// and these handlers sat marked "inert" while three separate bugs kept the
|
|
3461
|
+
// event from arriving — the SDK routed the frame to the wrong parser,
|
|
3462
|
+
// matched the wrong action names, and emitMessageEvent had no case for
|
|
3463
|
+
// these four names so the emit fell through to nothing.
|
|
3464
|
+
//
|
|
3465
|
+
// NOTE (1 Sep): 1-1 conversations DO emit these frames. This comment used to say they
|
|
3466
|
+
// did not, and that the DM's other participant only learned of a pin on their next
|
|
3467
|
+
// fetch. Confirmed at the handler, not inferred from the UI: with a real iOS pinner
|
|
3468
|
+
// and a real Android observer sitting in the DM, logcat caught
|
|
3469
|
+
// onMessagePinned … receiverType='user'
|
|
3470
|
+
// onMessageUnpinned … receiverType='user'
|
|
3471
|
+
// so these four handlers are live for 1-1s, not just groups. The DM half of
|
|
3472
|
+
// e2e/cross/pin.e2e.js (E2E_CONV=dm) asserts it and goes red if it ever reverts.
|
|
3473
|
+
// runPinSaveAction keeps
|
|
3474
|
+
// applying the response body directly, which is what makes the ACTING
|
|
3475
|
+
// device correct either way.
|
|
3476
|
+
//
|
|
3477
|
+
// These are read-only with respect to unread state (§7.7): no markAsRead,
|
|
3478
|
+
// no receipts, no unread-count change, which is why they deliberately do
|
|
3479
|
+
// NOT go through the onMessageDeleted-style branch that decrements counts.
|
|
3480
|
+
onMessagePinned: (message: any) => {
|
|
3481
|
+
messageEdited(message, false, true);
|
|
3482
|
+
},
|
|
3483
|
+
onMessageUnpinned: (message: any) => {
|
|
3484
|
+
messageEdited(message, false, true);
|
|
3485
|
+
},
|
|
3486
|
+
onMessageSaved: (message: any) => {
|
|
3487
|
+
messageEdited(message, false, true);
|
|
3488
|
+
},
|
|
3489
|
+
onMessageUnsaved: (message: any) => {
|
|
3490
|
+
messageEdited(message, false, true);
|
|
3491
|
+
},
|
|
3056
3492
|
onMessageModerated: (moderatedMessage: any) => {
|
|
3057
3493
|
if (isAgenticUser) return;
|
|
3058
3494
|
// A moderation verdict can arrive BEFORE the optimistic message has reconciled to its
|
|
@@ -3567,7 +4003,13 @@ export const CometChatMessageList = memo(
|
|
|
3567
4003
|
item?.getMetadata?.()?.error ||
|
|
3568
4004
|
(item as any)?.error ||
|
|
3569
4005
|
getModerationStatus(item) === "disapproved";
|
|
3570
|
-
|
|
4006
|
+
// EXCEPTION: a PINNED or SAVED member must also render its own meta row. The §7 fan-out
|
|
4007
|
+
// splits one send into a message PER MEDIA KIND (3 images + a video => an images message
|
|
4008
|
+
// and a videos message), so pin/save apply to one of those messages — and a non-last one
|
|
4009
|
+
// collapsed to a spacer, leaving its indicator nowhere to draw (ENG-38184). Only the
|
|
4010
|
+
// indicator shows here: the timestamp and receipt still belong to the last member alone.
|
|
4011
|
+
const _hasPinSaveIndicator = isPinned(item) || isSaved(item);
|
|
4012
|
+
if (!_hasError && !_hasPinSaveIndicator && _isCollapsibleBatchMember) {
|
|
3571
4013
|
// Non-last, non-failed batch member: the receipt/timestamp shows only on the LAST member,
|
|
3572
4014
|
// but that row is what gives the bubble its bottom footprint. Returning `undefined` leaves
|
|
3573
4015
|
// the content flush to the edge, so the rounded bottom corner doesn't render like the top.
|
|
@@ -3620,11 +4062,11 @@ export const CometChatMessageList = memo(
|
|
|
3620
4062
|
!!item.getEditedAt?.() &&
|
|
3621
4063
|
(editedType === MessageTypeConstants.text || isEditedMedia);
|
|
3622
4064
|
|
|
3623
|
-
// A first/middle
|
|
3624
|
-
//
|
|
4065
|
+
// A first/middle batch member that renders at all does so ONLY to show its own state
|
|
4066
|
+
// (an error icon, or a pin/save indicator) — the timestamp still belongs to the last
|
|
4067
|
+
// member of the group alone, so it is suppressed for every collapsed member.
|
|
3625
4068
|
const shouldShowTimestamp =
|
|
3626
|
-
(isAgenticUser ? isOutgoingMessage : !hideTimestamp) &&
|
|
3627
|
-
!(_isCollapsibleBatchMember && messageState === MessageReceipt.ERROR);
|
|
4069
|
+
(isAgenticUser ? isOutgoingMessage : !hideTimestamp) && !_isCollapsibleBatchMember;
|
|
3628
4070
|
return (
|
|
3629
4071
|
<View>
|
|
3630
4072
|
<View
|
|
@@ -3650,6 +4092,70 @@ export const CometChatMessageList = memo(
|
|
|
3650
4092
|
{t("EDITED")}
|
|
3651
4093
|
</Text>
|
|
3652
4094
|
)}
|
|
4095
|
+
{/* Pin & Save indicators (§6.2). Same meta-row slot as "Edited",
|
|
4096
|
+
before the timestamp. Icon-only — the design carries no
|
|
4097
|
+
"pinned by X" text today — so each gets an accessibilityLabel
|
|
4098
|
+
or a screen reader announces nothing at all (§6.8). Colour
|
|
4099
|
+
comes from the date/timestamp token so the pair reads as one
|
|
4100
|
+
piece of metadata rather than as an action. */}
|
|
4101
|
+
{(() => {
|
|
4102
|
+
// Saved first, then pinned — the order in the design. Built as a list so the
|
|
4103
|
+
// dots are DERIVED rather than hand-placed: one between every pair of glyphs
|
|
4104
|
+
// and one before the time, which is what makes "🔖 • 📌 • 07:53 pm" fall out
|
|
4105
|
+
// of the same code that produces "📌 • 4:56 pm".
|
|
4106
|
+
const indicators: { key: string; icon: IconName; label: string }[] = [];
|
|
4107
|
+
if (isSaved(item)) {
|
|
4108
|
+
indicators.push({
|
|
4109
|
+
key: "saved",
|
|
4110
|
+
icon: "bookmark-fill",
|
|
4111
|
+
label: t("SAVED") ?? "Saved",
|
|
4112
|
+
});
|
|
4113
|
+
}
|
|
4114
|
+
if (isPinned(item)) {
|
|
4115
|
+
indicators.push({
|
|
4116
|
+
key: "pinned",
|
|
4117
|
+
icon: "keep-fill",
|
|
4118
|
+
label: t("PINNED") ?? "Pinned",
|
|
4119
|
+
});
|
|
4120
|
+
}
|
|
4121
|
+
if (!indicators.length) return null;
|
|
4122
|
+
|
|
4123
|
+
// Decorative: the glyphs already announce "Saved" / "Pinned", so a screen
|
|
4124
|
+
// reader must not also read "bullet" between them.
|
|
4125
|
+
const dot = (key: string) => (
|
|
4126
|
+
<Text
|
|
4127
|
+
key={key}
|
|
4128
|
+
accessibilityElementsHidden={true}
|
|
4129
|
+
importantForAccessibility='no-hide-descendants'
|
|
4130
|
+
style={[_style.dateStyles?.textStyle]}
|
|
4131
|
+
>
|
|
4132
|
+
{"•"}
|
|
4133
|
+
</Text>
|
|
4134
|
+
);
|
|
4135
|
+
|
|
4136
|
+
const nodes: JSX.Element[] = [];
|
|
4137
|
+
indicators.forEach((indicator, index) => {
|
|
4138
|
+
if (index > 0) nodes.push(dot(`sep-${indicator.key}`));
|
|
4139
|
+
nodes.push(
|
|
4140
|
+
<View
|
|
4141
|
+
key={indicator.key}
|
|
4142
|
+
accessible={true}
|
|
4143
|
+
accessibilityLabel={indicator.label}
|
|
4144
|
+
>
|
|
4145
|
+
<Icon
|
|
4146
|
+
name={indicator.icon}
|
|
4147
|
+
color={_style.dateStyles?.textStyle?.color}
|
|
4148
|
+
height={14}
|
|
4149
|
+
width={14}
|
|
4150
|
+
/>
|
|
4151
|
+
</View>
|
|
4152
|
+
);
|
|
4153
|
+
});
|
|
4154
|
+
// Trailing dot only when a time actually follows it.
|
|
4155
|
+
if (shouldShowTimestamp) nodes.push(dot("sep-time"));
|
|
4156
|
+
|
|
4157
|
+
return <>{nodes}</>;
|
|
4158
|
+
})()}
|
|
3653
4159
|
{shouldShowTimestamp && (
|
|
3654
4160
|
<CometChatDate
|
|
3655
4161
|
timeStamp={
|
|
@@ -3666,7 +4172,11 @@ export const CometChatMessageList = memo(
|
|
|
3666
4172
|
{receiptsVisibility &&
|
|
3667
4173
|
alignment !== "leftAligned" &&
|
|
3668
4174
|
isOutgoingMessage &&
|
|
3669
|
-
!item.getDeletedAt?.()
|
|
4175
|
+
!item.getDeletedAt?.() &&
|
|
4176
|
+
// A collapsed member now renders when it is pinned/saved, but must not bring back
|
|
4177
|
+
// the receipt the collapse exists to hide. Scoped to the non-error case so the
|
|
4178
|
+
// failed-member branch below is untouched.
|
|
4179
|
+
!(_isCollapsibleBatchMember && !_hasError) ? (
|
|
3670
4180
|
(() => {
|
|
3671
4181
|
const receiptEl = (
|
|
3672
4182
|
<CometChatReceipt
|
|
@@ -3980,8 +4490,10 @@ export const CometChatMessageList = memo(
|
|
|
3980
4490
|
};
|
|
3981
4491
|
|
|
3982
4492
|
const copyMessage = (item: any) => {
|
|
3983
|
-
|
|
3984
|
-
|
|
4493
|
+
// getPlainString resolves mention tokens but leaves the rich-text wire format alone.
|
|
4494
|
+
// copyMessageText puts clean plain text on the clipboard for every other app and keeps
|
|
4495
|
+
// the colour in a private representation our own composer restores on paste.
|
|
4496
|
+
ClipboardPasteHandler.copyMessageText(getPlainString(item["text"], item), textFormatters);
|
|
3985
4497
|
// Defer modal dismiss to next frame to avoid Fabric race condition
|
|
3986
4498
|
// where unmounting the Modal while Clipboard is still accessing views
|
|
3987
4499
|
// causes EXC_BAD_ACCESS (SIGSEGV) at null pointer in mount phase.
|
|
@@ -4043,7 +4555,9 @@ export const CometChatMessageList = memo(
|
|
|
4043
4555
|
// Strip markdown/HTML from raw text BEFORE mention replacement,
|
|
4044
4556
|
// because getPlainString can break HTML tags (e.g., </u> becomes /u>)
|
|
4045
4557
|
let rawText = messageObject?.getData()["text"] || "";
|
|
4046
|
-
|
|
4558
|
+
// The app's own token becomes UI Kit markup BEFORE stripping, the same order the pinned
|
|
4559
|
+
// panel uses. Without it a consumer's `(#e11d48)text()` reaches the share sheet verbatim.
|
|
4560
|
+
let strippedText = stripMarkdown(applyRawFormatters(rawText, textFormatters));
|
|
4047
4561
|
let textMessage = getPlainString(strippedText, messageObject);
|
|
4048
4562
|
let fileUrl = messageObject.getData()["url"];
|
|
4049
4563
|
|
|
@@ -4108,6 +4622,30 @@ export const CometChatMessageList = memo(
|
|
|
4108
4622
|
case MessageOptionConstants.replyInThread:
|
|
4109
4623
|
option.onPress = openThreadView.bind(this, item);
|
|
4110
4624
|
break;
|
|
4625
|
+
case MessageOptionConstants.threadSubscription:
|
|
4626
|
+
option.onPress = () => {
|
|
4627
|
+
// The helper owns the debounce, the in-flight guard, the
|
|
4628
|
+
// optimistic emit and the revert; we only report the failure.
|
|
4629
|
+
// It resolves the thread id itself, so on a reply this acts on the
|
|
4630
|
+
// parent thread rather than writing an unopenable /threads row.
|
|
4631
|
+
toggleThreadSubscription(item).then(
|
|
4632
|
+
(subscribed: boolean) => {
|
|
4633
|
+
// Both transitions are confirmed. Unsubscribing is not sticky —
|
|
4634
|
+
// say so rather than letting the user discover it when a reply
|
|
4635
|
+
// drags them back in.
|
|
4636
|
+
showToast(
|
|
4637
|
+
t(
|
|
4638
|
+
subscribed
|
|
4639
|
+
? "THREAD_SUBSCRIPTION_SUBSCRIBED_TOAST"
|
|
4640
|
+
: "THREAD_SUBSCRIPTION_UNSUBSCRIBED_TOAST"
|
|
4641
|
+
)
|
|
4642
|
+
);
|
|
4643
|
+
},
|
|
4644
|
+
() => showToast(t("THREAD_SUBSCRIPTION_FAILED"))
|
|
4645
|
+
);
|
|
4646
|
+
setShowMessageOptions([]);
|
|
4647
|
+
};
|
|
4648
|
+
break;
|
|
4111
4649
|
case MessageOptionConstants.deleteMessage:
|
|
4112
4650
|
option.onPress = () => {
|
|
4113
4651
|
deleteItem.current = item;
|
|
@@ -4134,6 +4672,18 @@ export const CometChatMessageList = memo(
|
|
|
4134
4672
|
case MessageOptionConstants.markAsUnread:
|
|
4135
4673
|
option.onPress = markMessageAsUnread.bind(this, item);
|
|
4136
4674
|
break;
|
|
4675
|
+
case MessageOptionConstants.pinMessage:
|
|
4676
|
+
option.onPress = () => requestPinSaveAction(item, "pin");
|
|
4677
|
+
break;
|
|
4678
|
+
case MessageOptionConstants.unpinMessage:
|
|
4679
|
+
option.onPress = () => requestPinSaveAction(item, "unpin");
|
|
4680
|
+
break;
|
|
4681
|
+
case MessageOptionConstants.saveMessage:
|
|
4682
|
+
option.onPress = () => requestPinSaveAction(item, "save");
|
|
4683
|
+
break;
|
|
4684
|
+
case MessageOptionConstants.unsaveMessage:
|
|
4685
|
+
option.onPress = () => requestPinSaveAction(item, "unsave");
|
|
4686
|
+
break;
|
|
4137
4687
|
}
|
|
4138
4688
|
else {
|
|
4139
4689
|
// If overriding `onPress`, make sure to pass `item` explicitly
|
|
@@ -5345,6 +5895,7 @@ export const CometChatMessageList = memo(
|
|
|
5345
5895
|
<MessageModals
|
|
5346
5896
|
showDeleteModal={showDeleteModal}
|
|
5347
5897
|
showReportDialog={showReportDialog}
|
|
5898
|
+
pinSaveConfirm={pinSaveConfirm}
|
|
5348
5899
|
deleteItem={deleteItem}
|
|
5349
5900
|
reportedMessageRef={reportedMessageRef}
|
|
5350
5901
|
theme={theme}
|
|
@@ -5363,8 +5914,12 @@ export const CometChatMessageList = memo(
|
|
|
5363
5914
|
setShowReportDialog(false);
|
|
5364
5915
|
reportedMessageRef.current = null;
|
|
5365
5916
|
}}
|
|
5917
|
+
onPinSaveCancel={() => setPinSaveConfirm(null)}
|
|
5918
|
+
onPinSaveConfirm={() => {
|
|
5919
|
+
if (pinSaveConfirm) runPinSaveAction(pinSaveConfirm.message, pinSaveConfirm.action);
|
|
5920
|
+
setPinSaveConfirm(null);
|
|
5921
|
+
}}
|
|
5366
5922
|
/>
|
|
5367
|
-
|
|
5368
5923
|
<MessageOptionsSheet
|
|
5369
5924
|
bottomSheetRef={bottomSheetRef}
|
|
5370
5925
|
isOpen={showMessageOptions.length > 0 || Boolean(ExtensionsComponent) || messageInfo}
|
|
@@ -5413,6 +5968,7 @@ export const CometChatMessageList = memo(
|
|
|
5413
5968
|
setSelectedEmoji(undefined);
|
|
5414
5969
|
}}
|
|
5415
5970
|
/>
|
|
5971
|
+
{ToastElement}
|
|
5416
5972
|
</View>
|
|
5417
5973
|
</CometChatBatchMediaContext.Provider>
|
|
5418
5974
|
);
|