@cometchat/chat-uikit-react-native 5.5.4 → 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/src/main/java/com/reactnativecometchatuikit/FileManager.java +78 -3
- package/android/src/main/java/com/reactnativecometchatuikit/SafeFileName.java +78 -0
- package/ios/CCLocalFileGuard.h +19 -0
- package/ios/CCLocalFileGuard.m +34 -0
- package/ios/FileManager.m +70 -6
- package/ios/VideoManager.m +1 -1
- package/package.json +18 -3
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +124 -55
- 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 +146 -66
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +7 -3
- package/src/CometChatMessageHeader/listners.ts +76 -56
- package/src/CometChatMessageList/CometChatMessageList.tsx +1371 -188
- 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/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
- 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
|
@@ -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]);
|
|
@@ -1481,7 +1486,8 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
1481
1486
|
// Cancel all in-flight uploads and discard the tray on unmount / conversation switch
|
|
1482
1487
|
useEffect(() => {
|
|
1483
1488
|
return () => {
|
|
1484
|
-
|
|
1489
|
+
// Offline OFF: destroy the batch as today; ON: detach so it can be restored.
|
|
1490
|
+
uploadQueue.leave();
|
|
1485
1491
|
setSelectedAttachments([]);
|
|
1486
1492
|
};
|
|
1487
1493
|
// uploadQueue is stable (useMemo with [] deps), so this only runs on unmount
|
|
@@ -1530,13 +1536,13 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
1530
1536
|
// Pass the target conversation so the SDK can hand receiver/receiverType to the server for
|
|
1531
1537
|
// RBAC/SBAC presign authorization. Refs are read fresh (uploadQueue is memoized, refs are not).
|
|
1532
1538
|
newAttachments.forEach(a =>
|
|
1533
|
-
uploadQueue.enqueue(a, { receiver: chatWithId.current, receiverType: chatWith.current })
|
|
1539
|
+
uploadQueue.enqueue(a, { receiver: chatWithId.current, receiverType: chatWith.current, parentMessageId })
|
|
1534
1540
|
);
|
|
1535
1541
|
} catch {
|
|
1536
1542
|
// upload queue errors are surfaced per-file via onFileFailed
|
|
1537
1543
|
}
|
|
1538
1544
|
},
|
|
1539
|
-
[selectedAttachments.length, uploadQueue]
|
|
1545
|
+
[selectedAttachments.length, uploadQueue, parentMessageId]
|
|
1540
1546
|
);
|
|
1541
1547
|
|
|
1542
1548
|
// §5.0 — clipboard paste: the native editor extracts pasted image(s)/file(s) to temp files
|
|
@@ -1572,13 +1578,13 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
1572
1578
|
// Pass the target conversation so the SDK can hand receiver/receiverType to the server for
|
|
1573
1579
|
// RBAC/SBAC presign authorization. Refs are read fresh (uploadQueue is memoized, refs are not).
|
|
1574
1580
|
newAttachments.forEach(a =>
|
|
1575
|
-
uploadQueue.enqueue(a, { receiver: chatWithId.current, receiverType: chatWith.current })
|
|
1581
|
+
uploadQueue.enqueue(a, { receiver: chatWithId.current, receiverType: chatWith.current, parentMessageId })
|
|
1576
1582
|
);
|
|
1577
1583
|
} catch {
|
|
1578
1584
|
// upload queue errors are surfaced per-file via onFileFailed
|
|
1579
1585
|
}
|
|
1580
1586
|
},
|
|
1581
|
-
[enableMultipleAttachments, uploadQueue]
|
|
1587
|
+
[enableMultipleAttachments, uploadQueue, parentMessageId]
|
|
1582
1588
|
);
|
|
1583
1589
|
|
|
1584
1590
|
// §8.2 — staged image/video items (LOCAL URIs) for the full-screen tray preview viewer — the
|
|
@@ -1980,6 +1986,31 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
1980
1986
|
replyMessageRef.current = replyMessage;
|
|
1981
1987
|
}, [replyMessage]);
|
|
1982
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
|
+
|
|
1983
2014
|
// Configure receiver from user prop
|
|
1984
2015
|
useEffect(() => {
|
|
1985
2016
|
if (user) {
|
|
@@ -2558,14 +2589,19 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
2558
2589
|
|
|
2559
2590
|
// §7/§12.1 — independent per-message send: one kind can fail while others deliver.
|
|
2560
2591
|
const outgoing = buildMessage(group, index, muid);
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
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;
|
|
2569
2605
|
});
|
|
2570
2606
|
|
|
2571
2607
|
// ENG-36991 — clear the swipe-to-reply preview FIRST, before the teardown below. clearInputBox()
|
|
@@ -2702,21 +2738,28 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
2702
2738
|
}
|
|
2703
2739
|
|
|
2704
2740
|
// Send message via SDK
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
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
|
+
});
|
|
2718
2758
|
});
|
|
2719
|
-
|
|
2759
|
+
}, {
|
|
2760
|
+
onFailed: quietAwareOnError(onError),
|
|
2761
|
+
});
|
|
2762
|
+
void routed;
|
|
2720
2763
|
};
|
|
2721
2764
|
|
|
2722
2765
|
/**
|
|
@@ -4466,42 +4509,60 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
4466
4509
|
}
|
|
4467
4510
|
|
|
4468
4511
|
// Send message via SDK
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
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();
|
|
4480
4526
|
|
|
4481
|
-
|
|
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();
|
|
4482
4555
|
if (!isNaN(messageId) && !parentMessageIdRef.current) {
|
|
4483
4556
|
parentMessageIdRef.current = messageId;
|
|
4484
4557
|
}
|
|
4485
|
-
|
|
4486
|
-
// Start streaming for agentic user messages
|
|
4487
4558
|
if (messageId && !isNaN(messageId)) {
|
|
4488
4559
|
startStreamingForRunId(String(messageId));
|
|
4489
4560
|
}
|
|
4490
4561
|
}
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
});
|
|
4496
|
-
})
|
|
4497
|
-
.catch((error: CometChat.CometChatException) => {
|
|
4498
|
-
onError?.(error);
|
|
4499
|
-
(textMessage as any).data.metaData = { error: true };
|
|
4500
|
-
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
4501
|
-
message: textMessage,
|
|
4502
|
-
status: messageStatus.error,
|
|
4503
|
-
});
|
|
4504
|
-
});
|
|
4562
|
+
},
|
|
4563
|
+
onFailed: quietAwareOnError(onError),
|
|
4564
|
+
});
|
|
4565
|
+
void routed;
|
|
4505
4566
|
};
|
|
4506
4567
|
|
|
4507
4568
|
/**
|
|
@@ -4570,6 +4631,11 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
4570
4631
|
});
|
|
4571
4632
|
}
|
|
4572
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
|
+
|
|
4573
4639
|
// Clear input and preview
|
|
4574
4640
|
clearInputBox();
|
|
4575
4641
|
setMessagePreview(null);
|
|
@@ -4595,6 +4661,9 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
4595
4661
|
})
|
|
4596
4662
|
.catch((error: CometChat.CometChatException) => {
|
|
4597
4663
|
onError?.(error);
|
|
4664
|
+
// Offline ON: today's error notice too (ENG-41199).
|
|
4665
|
+
const errorText = offlineMutationErrorText(offlineOn, t);
|
|
4666
|
+
if (errorText) showToast(errorText);
|
|
4598
4667
|
});
|
|
4599
4668
|
};
|
|
4600
4669
|
|