@cometchat/chat-uikit-react-native 5.5.3 → 5.6.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/build.gradle +5 -0
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +78 -3
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +47 -4
- package/android/src/main/java/com/reactnativecometchatuikit/SafeFileName.java +78 -0
- package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +209 -119
- package/ios/CCLocalFileGuard.h +19 -0
- package/ios/CCLocalFileGuard.m +34 -0
- package/ios/FileManager.m +70 -6
- package/ios/RichTextEditorView.swift +96 -1
- package/ios/SoundPlayer.m +152 -6
- package/ios/VideoManager.m +1 -1
- package/package.json +18 -3
- package/react-native-cometchat-ui-kit.podspec +1 -1
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +167 -79
- package/src/CometChatConversations/CometChatConversations.tsx +240 -117
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +4 -0
- package/src/CometChatGroups/CometChatGroups.tsx +61 -52
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +173 -85
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +7 -3
- package/src/CometChatMessageHeader/listners.ts +76 -56
- package/src/CometChatMessageList/CometChatMessageList.tsx +1423 -205
- package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +71 -7
- package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +74 -2
- package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +69 -4
- package/src/CometChatSearch/CometChatSearch.tsx +353 -101
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +23 -1
- package/src/CometChatUsers/CometChatUsers.tsx +2 -0
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +19 -0
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +48 -47
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -0
- package/src/index.ts +6 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +85 -2
- package/src/shared/CometChatUiKit/UIKitSettings.ts +20 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +10 -0
- package/src/shared/events/index.ts +4 -0
- package/src/shared/events/offline.ts +28 -0
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +5 -3
- package/src/shared/framework/MessageDataSource.tsx +34 -14
- package/src/shared/index.ts +2 -0
- package/src/shared/offline/OfflineHub.ts +651 -0
- package/src/shared/offline/OfflineMediaBubble.tsx +49 -0
- package/src/shared/offline/OfflineViews.tsx +218 -0
- package/src/shared/offline/conversationPins.ts +137 -0
- package/src/shared/offline/conversations.ts +325 -0
- package/src/shared/offline/frameProbe.ts +24 -0
- package/src/shared/offline/gate.ts +94 -0
- package/src/shared/offline/groupActions.ts +81 -0
- package/src/shared/offline/identity.ts +162 -0
- package/src/shared/offline/index.ts +76 -0
- package/src/shared/offline/media.ts +247 -0
- package/src/shared/offline/notices.ts +90 -0
- package/src/shared/offline/reconcile.ts +296 -0
- package/src/shared/offline/searchOutcome.ts +62 -0
- package/src/shared/offline/send.ts +430 -0
- package/src/shared/offline/stateContract.ts +85 -0
- package/src/shared/offline/threadReplies.ts +125 -0
- package/src/shared/offline/twoPhase.ts +372 -0
- package/src/shared/offline/unsentActions.ts +168 -0
- package/src/shared/offline/useOfflineMediaUri.ts +87 -0
- package/src/shared/offline/useOfflineReconnect.ts +25 -0
- package/src/shared/offline/useOfflineSessionEnded.ts +22 -0
- package/src/shared/offline/useOfflineUploadTray.ts +76 -0
- package/src/shared/offline/usePresenceHidden.ts +33 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +24 -1
- package/src/shared/services/UploadQueueService.ts +106 -1
- package/src/shared/utils/MessageReceiptUtils.ts +8 -0
- package/src/shared/utils/SavedMessagesHelper.ts +18 -1
- package/src/shared/utils/catchUpCursor.ts +36 -0
- package/src/shared/utils/failedMessageRetry.ts +73 -0
- package/src/shared/utils/messageIdentity.ts +38 -0
- package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +34 -5
- package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +10 -2
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +13 -27
- package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +60 -11
- package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +27 -2
- package/src/shared/views/CometChatList/CometChatList.tsx +468 -7
- package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +27 -5
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +1 -0
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +56 -10
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +4 -0
- package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +36 -2
- package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +24 -12
- package/src/theme/type.ts +17 -0
|
@@ -114,6 +114,10 @@ import {
|
|
|
114
114
|
import { runAfterInteractions } from '../shared/utils/runAfterInteractions';
|
|
115
115
|
import { MessageTypeConstants, ReceiverTypeConstants, ConversationOptionConstants, MentionsVisibility, MentionsTargetElement, ViewAlignment, EnterKeyBehavior, DISABLED_BUTTON_OPACITY } from '../shared/constants/UIKitConstants';
|
|
116
116
|
import { MessageEvents } from '../shared/events';
|
|
117
|
+
import { isQuietRejection, quietAwareOnError, routeSend } from "../shared/offline/send";
|
|
118
|
+
import { isOfflineOn } from "../shared/offline/gate";
|
|
119
|
+
import { useOfflineUploadTray } from "../shared/offline/useOfflineUploadTray";
|
|
120
|
+
import { offlineMutationErrorText } from "../shared/offline/notices";
|
|
117
121
|
import { CometChatUIEventHandler } from '../shared/events/CometChatUIEventHandler/CometChatUIEventHandler';
|
|
118
122
|
import { CometChatMessageEvents } from '../shared/events/CometChatMessageEvents';
|
|
119
123
|
import { ICONS } from './resources';
|
|
@@ -452,6 +456,7 @@ const EmojiButton = ({ user, group, composerIdMap, replyToMessage, closeReplyPre
|
|
|
452
456
|
}
|
|
453
457
|
})
|
|
454
458
|
.catch((err: any) => {
|
|
459
|
+
if (isQuietRejection(err)) return; // the session ended or the cache was reset: nothing to report
|
|
455
460
|
console.error("Failed to send sticker:", err);
|
|
456
461
|
});
|
|
457
462
|
}, [user, group, composerIdMap]);
|
|
@@ -640,13 +645,15 @@ export interface CometChatCompactMessageComposerInterface {
|
|
|
640
645
|
onChangeText?: (text: string) => void;
|
|
641
646
|
|
|
642
647
|
/**
|
|
643
|
-
* Flag to turn off sound for outgoing messages.
|
|
648
|
+
* Flag to turn off sound for outgoing messages. The composer owns the send sound;
|
|
649
|
+
* CometChatMessageList only plays incoming-message sounds.
|
|
644
650
|
* @type {boolean}
|
|
651
|
+
* @defaultValue false
|
|
645
652
|
*/
|
|
646
653
|
disableSoundForOutgoingMessages?: boolean;
|
|
647
654
|
|
|
648
655
|
/**
|
|
649
|
-
*
|
|
656
|
+
* Alias for disableSoundForOutgoingMessages, which takes precedence when both are set.
|
|
650
657
|
* @type {boolean}
|
|
651
658
|
*/
|
|
652
659
|
disableSoundForMessages?: boolean;
|
|
@@ -658,7 +665,7 @@ export interface CometChatCompactMessageComposerInterface {
|
|
|
658
665
|
customSoundForOutgoingMessage?: any;
|
|
659
666
|
|
|
660
667
|
/**
|
|
661
|
-
*
|
|
668
|
+
* Alias for customSoundForOutgoingMessage, which takes precedence when both are set.
|
|
662
669
|
* @type {*}
|
|
663
670
|
*/
|
|
664
671
|
customSoundForMessage?: any;
|
|
@@ -1188,7 +1195,9 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
1188
1195
|
parentMessageId,
|
|
1189
1196
|
disableTypingEvents: propDisableTypingEvents,
|
|
1190
1197
|
disableMentions: propDisableMentions,
|
|
1191
|
-
|
|
1198
|
+
disableSoundForOutgoingMessages,
|
|
1199
|
+
disableSoundForMessages,
|
|
1200
|
+
customSoundForOutgoingMessage,
|
|
1192
1201
|
customSoundForMessage,
|
|
1193
1202
|
textFormatters,
|
|
1194
1203
|
onError,
|
|
@@ -1244,6 +1253,12 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
1244
1253
|
enableMultipleAttachments = true,
|
|
1245
1254
|
} = props;
|
|
1246
1255
|
|
|
1256
|
+
// The documented names (…ForOutgoingMessage[s]) were declared but never read, so only the
|
|
1257
|
+
// aliases had any effect. Honour both, documented name first. Sound is on by default:
|
|
1258
|
+
// the composer owns the send sound now that the message list plays incoming sounds only.
|
|
1259
|
+
const disableOutgoingSound = disableSoundForOutgoingMessages ?? disableSoundForMessages ?? false;
|
|
1260
|
+
const outgoingSound = customSoundForOutgoingMessage ?? customSoundForMessage;
|
|
1261
|
+
|
|
1247
1262
|
// Auto-expand is always enabled (internal behavior)
|
|
1248
1263
|
const autoExpand = true;
|
|
1249
1264
|
|
|
@@ -1471,7 +1486,8 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
1471
1486
|
// Cancel all in-flight uploads and discard the tray on unmount / conversation switch
|
|
1472
1487
|
useEffect(() => {
|
|
1473
1488
|
return () => {
|
|
1474
|
-
|
|
1489
|
+
// Offline OFF: destroy the batch as today; ON: detach so it can be restored.
|
|
1490
|
+
uploadQueue.leave();
|
|
1475
1491
|
setSelectedAttachments([]);
|
|
1476
1492
|
};
|
|
1477
1493
|
// uploadQueue is stable (useMemo with [] deps), so this only runs on unmount
|
|
@@ -1520,13 +1536,13 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
1520
1536
|
// Pass the target conversation so the SDK can hand receiver/receiverType to the server for
|
|
1521
1537
|
// RBAC/SBAC presign authorization. Refs are read fresh (uploadQueue is memoized, refs are not).
|
|
1522
1538
|
newAttachments.forEach(a =>
|
|
1523
|
-
uploadQueue.enqueue(a, { receiver: chatWithId.current, receiverType: chatWith.current })
|
|
1539
|
+
uploadQueue.enqueue(a, { receiver: chatWithId.current, receiverType: chatWith.current, parentMessageId })
|
|
1524
1540
|
);
|
|
1525
1541
|
} catch {
|
|
1526
1542
|
// upload queue errors are surfaced per-file via onFileFailed
|
|
1527
1543
|
}
|
|
1528
1544
|
},
|
|
1529
|
-
[selectedAttachments.length, uploadQueue]
|
|
1545
|
+
[selectedAttachments.length, uploadQueue, parentMessageId]
|
|
1530
1546
|
);
|
|
1531
1547
|
|
|
1532
1548
|
// §5.0 — clipboard paste: the native editor extracts pasted image(s)/file(s) to temp files
|
|
@@ -1562,13 +1578,13 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
1562
1578
|
// Pass the target conversation so the SDK can hand receiver/receiverType to the server for
|
|
1563
1579
|
// RBAC/SBAC presign authorization. Refs are read fresh (uploadQueue is memoized, refs are not).
|
|
1564
1580
|
newAttachments.forEach(a =>
|
|
1565
|
-
uploadQueue.enqueue(a, { receiver: chatWithId.current, receiverType: chatWith.current })
|
|
1581
|
+
uploadQueue.enqueue(a, { receiver: chatWithId.current, receiverType: chatWith.current, parentMessageId })
|
|
1566
1582
|
);
|
|
1567
1583
|
} catch {
|
|
1568
1584
|
// upload queue errors are surfaced per-file via onFileFailed
|
|
1569
1585
|
}
|
|
1570
1586
|
},
|
|
1571
|
-
[enableMultipleAttachments, uploadQueue]
|
|
1587
|
+
[enableMultipleAttachments, uploadQueue, parentMessageId]
|
|
1572
1588
|
);
|
|
1573
1589
|
|
|
1574
1590
|
// §8.2 — staged image/video items (LOCAL URIs) for the full-screen tray preview viewer — the
|
|
@@ -1970,6 +1986,31 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
1970
1986
|
replyMessageRef.current = replyMessage;
|
|
1971
1987
|
}, [replyMessage]);
|
|
1972
1988
|
|
|
1989
|
+
// Offline ON: moving to another (receiver, type, thread parent) detaches the batch, which the
|
|
1990
|
+
// SDK keeps for a restore when the user comes back (BEH-UPLOAD-14). Offline OFF: today's tray.
|
|
1991
|
+
const trayOwner = `${user?.getUid?.() ?? ""}|${group?.getGuid?.() ?? ""}|${parentMessageId ?? ""}`;
|
|
1992
|
+
const trayOwnerRef = React.useRef(trayOwner);
|
|
1993
|
+
useEffect(() => {
|
|
1994
|
+
if (trayOwnerRef.current === trayOwner) return;
|
|
1995
|
+
trayOwnerRef.current = trayOwner;
|
|
1996
|
+
if (!isOfflineOn()) return;
|
|
1997
|
+
uploadQueue.detach();
|
|
1998
|
+
selectedAttachmentsRef.current = [];
|
|
1999
|
+
setSelectedAttachments([]);
|
|
2000
|
+
}, [trayOwner, uploadQueue]);
|
|
2001
|
+
|
|
2002
|
+
// Offline ON: restore this chat's tray and clear it with the session. Offline OFF: nothing.
|
|
2003
|
+
useOfflineUploadTray(
|
|
2004
|
+
uploadQueue,
|
|
2005
|
+
{
|
|
2006
|
+
receiver: user?.getUid?.() ?? group?.getGuid?.(),
|
|
2007
|
+
receiverType: user?.getUid?.() ? ReceiverTypeConstants.user : group?.getGuid?.() ? ReceiverTypeConstants.group : undefined,
|
|
2008
|
+
parentMessageId,
|
|
2009
|
+
},
|
|
2010
|
+
selectedAttachmentsRef,
|
|
2011
|
+
setSelectedAttachments
|
|
2012
|
+
);
|
|
2013
|
+
|
|
1973
2014
|
// Configure receiver from user prop
|
|
1974
2015
|
useEffect(() => {
|
|
1975
2016
|
if (user) {
|
|
@@ -2218,10 +2259,28 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
2218
2259
|
}
|
|
2219
2260
|
}, []);
|
|
2220
2261
|
|
|
2262
|
+
// An agent chat that opens on its last conversation (CometChatMessageList's
|
|
2263
|
+
// loadLastAgentConversation) announces that conversation through ccActiveChatChanged.
|
|
2264
|
+
// Continue THAT conversation: without it the next question went out with no parent, the
|
|
2265
|
+
// server started a new conversation the list doesn't track, and every later question was
|
|
2266
|
+
// stamped with the new root and filtered out of the list until a reload (ENG-41058).
|
|
2267
|
+
// Read through a ref so the once-registered listener sees current props.
|
|
2268
|
+
const adoptAgentConversationRef = React.useRef<(item: any) => void>(() => {});
|
|
2269
|
+
adoptAgentConversationRef.current = (item: any) => {
|
|
2270
|
+
if (!isAgenticUser() || parentMessageId || parentMessageIdRef.current) return;
|
|
2271
|
+
if (item?.parentMessageId) return; // a thread view's list, not the main agent chat
|
|
2272
|
+
const msg = item?.message;
|
|
2273
|
+
if (!msg || item?.user?.getUid?.() !== user?.getUid?.()) return;
|
|
2274
|
+
const loadedParentId = Number(msg.getParentMessageId?.());
|
|
2275
|
+
const rootId = loadedParentId > 0 ? loadedParentId : Number(msg.getId?.());
|
|
2276
|
+
if (rootId > 0) parentMessageIdRef.current = rootId;
|
|
2277
|
+
};
|
|
2278
|
+
|
|
2221
2279
|
// Add edit message event listener
|
|
2222
2280
|
useEffect(() => {
|
|
2223
2281
|
CometChatUIEventHandler.addMessageListener(editMessageListenerID, {
|
|
2224
2282
|
ccMessageEdited: (item: { message: any; status: string }) => previewMessage(item),
|
|
2283
|
+
ccActiveChatChanged: (item: any) => adoptAgentConversationRef.current(item),
|
|
2225
2284
|
});
|
|
2226
2285
|
|
|
2227
2286
|
return () => {
|
|
@@ -2530,14 +2589,19 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
2530
2589
|
|
|
2531
2590
|
// §7/§12.1 — independent per-message send: one kind can fail while others deliver.
|
|
2532
2591
|
const outgoing = buildMessage(group, index, muid);
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2592
|
+
// Gate read once, at send: OFF runs today's code unchanged; ON goes through the
|
|
2593
|
+
// kit's one send helper (hub reports state and the public events, once).
|
|
2594
|
+
const routed = routeSend(outgoing, "media", () => {
|
|
2595
|
+
CometChat.sendMediaMessage(outgoing)
|
|
2596
|
+
.then((msg: any) => {
|
|
2597
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
2598
|
+
message: msg,
|
|
2599
|
+
status: messageStatus.success,
|
|
2600
|
+
});
|
|
2601
|
+
})
|
|
2602
|
+
.catch(() => markSendFailed(outgoing));
|
|
2603
|
+
}, {});
|
|
2604
|
+
void routed;
|
|
2541
2605
|
});
|
|
2542
2606
|
|
|
2543
2607
|
// ENG-36991 — clear the swipe-to-reply preview FIRST, before the teardown below. clearInputBox()
|
|
@@ -2550,14 +2614,11 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
2550
2614
|
setShowActionSheet(false);
|
|
2551
2615
|
clearInputBox();
|
|
2552
2616
|
|
|
2553
|
-
if (!
|
|
2554
|
-
CometChatSoundManager.play(
|
|
2555
|
-
CometChatSoundManager.SoundOutput.outgoingMessage,
|
|
2556
|
-
customSoundForMessage
|
|
2557
|
-
);
|
|
2617
|
+
if (!disableOutgoingSound) {
|
|
2618
|
+
CometChatSoundManager.play('outgoingMessage', outgoingSound);
|
|
2558
2619
|
}
|
|
2559
2620
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2560
|
-
}, [uploadQueue, parentMessageId,
|
|
2621
|
+
}, [uploadQueue, parentMessageId, disableOutgoingSound, outgoingSound]);
|
|
2561
2622
|
|
|
2562
2623
|
/**
|
|
2563
2624
|
* Send media message (image, video, audio, file)
|
|
@@ -2672,42 +2733,43 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
2672
2733
|
});
|
|
2673
2734
|
|
|
2674
2735
|
// Play sound if enabled
|
|
2675
|
-
if (!
|
|
2736
|
+
if (!disableOutgoingSound) {
|
|
2676
2737
|
playAudio();
|
|
2677
2738
|
}
|
|
2678
2739
|
|
|
2679
2740
|
// Send message via SDK
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2741
|
+
// Gate read once, at send: OFF runs today's code unchanged; ON goes through the
|
|
2742
|
+
// kit's one send helper (hub reports state and the public events, once).
|
|
2743
|
+
const routed = routeSend(mediaMessage, "media", () => {
|
|
2744
|
+
CometChat.sendMediaMessage(mediaMessage)
|
|
2745
|
+
.then((message: CometChat.BaseMessage) => {
|
|
2746
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
2747
|
+
message: message,
|
|
2748
|
+
status: messageStatus.success,
|
|
2749
|
+
});
|
|
2750
|
+
})
|
|
2751
|
+
.catch((error: CometChat.CometChatException) => {
|
|
2752
|
+
onError?.(error);
|
|
2753
|
+
(localMessage as any).data.metaData = { error: true };
|
|
2754
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
2755
|
+
message: localMessage,
|
|
2756
|
+
status: messageStatus.error,
|
|
2757
|
+
});
|
|
2693
2758
|
});
|
|
2694
|
-
|
|
2759
|
+
}, {
|
|
2760
|
+
onFailed: quietAwareOnError(onError),
|
|
2761
|
+
});
|
|
2762
|
+
void routed;
|
|
2695
2763
|
};
|
|
2696
2764
|
|
|
2697
2765
|
/**
|
|
2698
|
-
* Play outgoing message sound
|
|
2766
|
+
* Play outgoing message sound.
|
|
2767
|
+
* play() switches on the sound's NAME. Passing SoundOutput.outgoingMessage (the asset
|
|
2768
|
+
* itself) matched no case, so the composer never made a sound (GitHub #117). A missing
|
|
2769
|
+
* custom sound falls back to the built-in one.
|
|
2699
2770
|
*/
|
|
2700
2771
|
const playAudio = () => {
|
|
2701
|
-
|
|
2702
|
-
CometChatSoundManager.play(
|
|
2703
|
-
CometChatSoundManager.SoundOutput.outgoingMessage,
|
|
2704
|
-
customSoundForMessage
|
|
2705
|
-
);
|
|
2706
|
-
} else {
|
|
2707
|
-
CometChatSoundManager.play(
|
|
2708
|
-
CometChatSoundManager.SoundOutput.outgoingMessage
|
|
2709
|
-
);
|
|
2710
|
-
}
|
|
2772
|
+
CometChatSoundManager.play('outgoingMessage', outgoingSound);
|
|
2711
2773
|
};
|
|
2712
2774
|
|
|
2713
2775
|
/**
|
|
@@ -4428,7 +4490,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
4428
4490
|
});
|
|
4429
4491
|
|
|
4430
4492
|
// Play sound if enabled
|
|
4431
|
-
if (!
|
|
4493
|
+
if (!disableOutgoingSound) {
|
|
4432
4494
|
playAudio();
|
|
4433
4495
|
}
|
|
4434
4496
|
|
|
@@ -4447,42 +4509,60 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
4447
4509
|
}
|
|
4448
4510
|
|
|
4449
4511
|
// Send message via SDK
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4512
|
+
// Gate read once, at send: OFF runs today's code unchanged; ON goes through the
|
|
4513
|
+
// kit's one send helper (hub reports state and the public events, once).
|
|
4514
|
+
const routed = routeSend(textMessage, "text", () => {
|
|
4515
|
+
CometChat.sendMessage(textMessage)
|
|
4516
|
+
.then((message: CometChat.BaseMessage) => {
|
|
4517
|
+
/**
|
|
4518
|
+
* For agentic users without parentMessageId prop:
|
|
4519
|
+
* - Store the message ID as parent for subsequent messages
|
|
4520
|
+
* - Start streaming for the message
|
|
4521
|
+
*/
|
|
4522
|
+
if (isAgenticUser() && !parentMessageId && message?.getId) {
|
|
4523
|
+
const messageId = typeof message.getId() === 'string'
|
|
4524
|
+
? Number(message.getId())
|
|
4525
|
+
: message.getId();
|
|
4461
4526
|
|
|
4462
|
-
|
|
4527
|
+
// Store parent message ID for subsequent messages
|
|
4528
|
+
if (!isNaN(messageId) && !parentMessageIdRef.current) {
|
|
4529
|
+
parentMessageIdRef.current = messageId;
|
|
4530
|
+
}
|
|
4531
|
+
|
|
4532
|
+
// Start streaming for agentic user messages
|
|
4533
|
+
if (messageId && !isNaN(messageId)) {
|
|
4534
|
+
startStreamingForRunId(String(messageId));
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
|
|
4538
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
4539
|
+
message: message,
|
|
4540
|
+
status: messageStatus.success,
|
|
4541
|
+
});
|
|
4542
|
+
})
|
|
4543
|
+
.catch((error: CometChat.CometChatException) => {
|
|
4544
|
+
onError?.(error);
|
|
4545
|
+
(textMessage as any).data.metaData = { error: true };
|
|
4546
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
4547
|
+
message: textMessage,
|
|
4548
|
+
status: messageStatus.error,
|
|
4549
|
+
});
|
|
4550
|
+
});
|
|
4551
|
+
}, {
|
|
4552
|
+
onSent: (message: any) => {
|
|
4553
|
+
if (isAgenticUser() && !parentMessageId && message?.getId) {
|
|
4554
|
+
const messageId = typeof message.getId() === 'string' ? Number(message.getId()) : message.getId();
|
|
4463
4555
|
if (!isNaN(messageId) && !parentMessageIdRef.current) {
|
|
4464
4556
|
parentMessageIdRef.current = messageId;
|
|
4465
4557
|
}
|
|
4466
|
-
|
|
4467
|
-
// Start streaming for agentic user messages
|
|
4468
4558
|
if (messageId && !isNaN(messageId)) {
|
|
4469
4559
|
startStreamingForRunId(String(messageId));
|
|
4470
4560
|
}
|
|
4471
4561
|
}
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
});
|
|
4477
|
-
})
|
|
4478
|
-
.catch((error: CometChat.CometChatException) => {
|
|
4479
|
-
onError?.(error);
|
|
4480
|
-
(textMessage as any).data.metaData = { error: true };
|
|
4481
|
-
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
4482
|
-
message: textMessage,
|
|
4483
|
-
status: messageStatus.error,
|
|
4484
|
-
});
|
|
4485
|
-
});
|
|
4562
|
+
},
|
|
4563
|
+
onFailed: quietAwareOnError(onError),
|
|
4564
|
+
});
|
|
4565
|
+
void routed;
|
|
4486
4566
|
};
|
|
4487
4567
|
|
|
4488
4568
|
/**
|
|
@@ -4551,6 +4631,11 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
4551
4631
|
});
|
|
4552
4632
|
}
|
|
4553
4633
|
|
|
4634
|
+
// The composer is cleared and leaves edit mode before the request, offline on or off. A failed
|
|
4635
|
+
// edit goes to onError (plus the offline error notice below); the text is not put back, as on
|
|
4636
|
+
// the Android UI Kit.
|
|
4637
|
+
const offlineOn = isOfflineOn();
|
|
4638
|
+
|
|
4554
4639
|
// Clear input and preview
|
|
4555
4640
|
clearInputBox();
|
|
4556
4641
|
setMessagePreview(null);
|
|
@@ -4562,7 +4647,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
4562
4647
|
}
|
|
4563
4648
|
|
|
4564
4649
|
// Play sound if enabled
|
|
4565
|
-
if (!
|
|
4650
|
+
if (!disableOutgoingSound) {
|
|
4566
4651
|
playAudio();
|
|
4567
4652
|
}
|
|
4568
4653
|
|
|
@@ -4576,6 +4661,9 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
4576
4661
|
})
|
|
4577
4662
|
.catch((error: CometChat.CometChatException) => {
|
|
4578
4663
|
onError?.(error);
|
|
4664
|
+
// Offline ON: today's error notice too (ENG-41199).
|
|
4665
|
+
const errorText = offlineMutationErrorText(offlineOn, t);
|
|
4666
|
+
if (errorText) showToast(errorText);
|
|
4579
4667
|
});
|
|
4580
4668
|
};
|
|
4581
4669
|
|