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