@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
|
@@ -48,6 +48,10 @@ import {
|
|
|
48
48
|
ViewAlignment,
|
|
49
49
|
} from "../shared/constants/UIKitConstants";
|
|
50
50
|
import { MessageEvents } from "../shared/events";
|
|
51
|
+
import { afterFirstAnswer, quietAwareOnError, routeSend } from "../shared/offline/send";
|
|
52
|
+
import { isOfflineOn } from "../shared/offline/gate";
|
|
53
|
+
import { useOfflineThreadTrayReset, useOfflineUploadTray } from "../shared/offline/useOfflineUploadTray";
|
|
54
|
+
import { offlineMutationErrorText } from "../shared/offline/notices";
|
|
51
55
|
import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
|
|
52
56
|
import { CometChatMessageEvents } from "../shared/events/CometChatMessageEvents";
|
|
53
57
|
import { CometChatMessageComposerAction, DeepPartial } from "../shared/helper/types";
|
|
@@ -197,9 +201,11 @@ export interface CometChatMessageComposerInterface {
|
|
|
197
201
|
group?: CometChat.Group;
|
|
198
202
|
|
|
199
203
|
/**
|
|
200
|
-
* Flag to turn off sound for outgoing messages.
|
|
204
|
+
* Flag to turn off sound for outgoing messages. The composer owns the send sound;
|
|
205
|
+
* CometChatMessageList only plays incoming-message sounds.
|
|
201
206
|
*
|
|
202
207
|
* @type {boolean}
|
|
208
|
+
* @defaultValue false
|
|
203
209
|
*/
|
|
204
210
|
disableSoundForOutgoingMessages?: boolean;
|
|
205
211
|
|
|
@@ -497,7 +503,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
497
503
|
id,
|
|
498
504
|
user,
|
|
499
505
|
group,
|
|
500
|
-
disableSoundForOutgoingMessages =
|
|
506
|
+
disableSoundForOutgoingMessages = false,
|
|
501
507
|
customSoundForOutgoingMessage,
|
|
502
508
|
disableTypingEvents: propDisableTypingEvents,
|
|
503
509
|
initialComposertext,
|
|
@@ -751,10 +757,10 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
751
757
|
// RBAC/SBAC presign authorization. Read the refs fresh here (uploadQueue is memoized at mount,
|
|
752
758
|
// the refs are not) — constructor-time capture would be stale.
|
|
753
759
|
newAttachments.forEach(a =>
|
|
754
|
-
uploadQueue.enqueue(a, { receiver: chatWithId.current, receiverType: chatWith.current })
|
|
760
|
+
uploadQueue.enqueue(a, { receiver: chatWithId.current, receiverType: chatWith.current, parentMessageId })
|
|
755
761
|
);
|
|
756
762
|
},
|
|
757
|
-
[selectedAttachments, uploadQueue]
|
|
763
|
+
[selectedAttachments, uploadQueue, parentMessageId]
|
|
758
764
|
);
|
|
759
765
|
|
|
760
766
|
const handleRemoveAttachment = useCallback(
|
|
@@ -818,7 +824,8 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
818
824
|
if (sendButtonDelayTimer.current) {
|
|
819
825
|
clearTimeout(sendButtonDelayTimer.current);
|
|
820
826
|
}
|
|
821
|
-
|
|
827
|
+
// Offline OFF: destroy the batch as today; ON: detach so it can be restored.
|
|
828
|
+
uploadQueue.leave();
|
|
822
829
|
};
|
|
823
830
|
}, []);
|
|
824
831
|
|
|
@@ -1117,15 +1124,11 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1117
1124
|
void launchPicker(fileType);
|
|
1118
1125
|
};
|
|
1119
1126
|
|
|
1127
|
+
// play() switches on the sound's NAME. Passing SoundOutput.outgoingMessage (the asset
|
|
1128
|
+
// itself) matched no case, so the composer never made a sound and its sound props did
|
|
1129
|
+
// nothing (GitHub #117). A missing custom sound falls back to the built-in one.
|
|
1120
1130
|
const playAudio = () => {
|
|
1121
|
-
|
|
1122
|
-
CometChatSoundManager.play(
|
|
1123
|
-
CometChatSoundManager.SoundOutput.outgoingMessage,
|
|
1124
|
-
customSoundForOutgoingMessage
|
|
1125
|
-
);
|
|
1126
|
-
} else {
|
|
1127
|
-
CometChatSoundManager.play(CometChatSoundManager.SoundOutput.outgoingMessage);
|
|
1128
|
-
}
|
|
1131
|
+
CometChatSoundManager.play('outgoingMessage', customSoundForOutgoingMessage);
|
|
1129
1132
|
};
|
|
1130
1133
|
|
|
1131
1134
|
const sendMultiAttachmentMediaMessage = useCallback(() => {
|
|
@@ -1200,31 +1203,46 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1200
1203
|
|
|
1201
1204
|
// §7/§12.1 — independent per-message send: one kind can fail while others deliver.
|
|
1202
1205
|
const outgoing = buildMessage(group, index, muid);
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1206
|
+
// Gate read once, at send: OFF runs today's code unchanged; ON goes through the
|
|
1207
|
+
// kit's one send helper (hub reports state and the public events, once).
|
|
1208
|
+
const routed = routeSend(outgoing, "media", () => {
|
|
1209
|
+
CometChat.sendMediaMessage(outgoing)
|
|
1210
|
+
.then((msg: any) => {
|
|
1211
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1212
|
+
message: msg,
|
|
1213
|
+
status: messageStatus.success,
|
|
1214
|
+
});
|
|
1215
|
+
if (replyMessageId) {
|
|
1216
|
+
CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
|
|
1217
|
+
message: msg,
|
|
1218
|
+
status: messageStatus.success,
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
})
|
|
1222
|
+
.catch((error: any) => {
|
|
1223
|
+
// Preserve the batch metadata; just flag this message's optimistic echo as failed.
|
|
1224
|
+
const currentData = localMessage.getData() || {};
|
|
1225
|
+
localMessage.setData({ ...currentData, metaData: { error: true } });
|
|
1226
|
+
const md = (localMessage.getMetadata?.() as Record<string, unknown>) || {};
|
|
1227
|
+
localMessage.setMetadata({ ...md, error: true });
|
|
1228
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1229
|
+
message: localMessage,
|
|
1230
|
+
status: messageStatus.error,
|
|
1231
|
+
});
|
|
1232
|
+
onError && onError(error);
|
|
1208
1233
|
});
|
|
1234
|
+
}, {
|
|
1235
|
+
onSent: (msg: any) => {
|
|
1209
1236
|
if (replyMessageId) {
|
|
1210
1237
|
CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
|
|
1211
1238
|
message: msg,
|
|
1212
1239
|
status: messageStatus.success,
|
|
1213
1240
|
});
|
|
1214
1241
|
}
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
localMessage.setData({ ...currentData, metaData: { error: true } });
|
|
1220
|
-
const md = (localMessage.getMetadata?.() as Record<string, unknown>) || {};
|
|
1221
|
-
localMessage.setMetadata({ ...md, error: true });
|
|
1222
|
-
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1223
|
-
message: localMessage,
|
|
1224
|
-
status: messageStatus.error,
|
|
1225
|
-
});
|
|
1226
|
-
onError && onError(error);
|
|
1227
|
-
});
|
|
1242
|
+
},
|
|
1243
|
+
onFailed: quietAwareOnError(onError),
|
|
1244
|
+
});
|
|
1245
|
+
void routed;
|
|
1228
1246
|
});
|
|
1229
1247
|
|
|
1230
1248
|
// Clear composer state immediately
|
|
@@ -1237,14 +1255,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1237
1255
|
setReplyMessage(null);
|
|
1238
1256
|
|
|
1239
1257
|
if (!disableSoundForOutgoingMessages) {
|
|
1240
|
-
|
|
1241
|
-
CometChatSoundManager.play(
|
|
1242
|
-
CometChatSoundManager.SoundOutput.outgoingMessage,
|
|
1243
|
-
customSoundForOutgoingMessage
|
|
1244
|
-
);
|
|
1245
|
-
} else {
|
|
1246
|
-
CometChatSoundManager.play(CometChatSoundManager.SoundOutput.outgoingMessage);
|
|
1247
|
-
}
|
|
1258
|
+
CometChatSoundManager.play('outgoingMessage', customSoundForOutgoingMessage);
|
|
1248
1259
|
}
|
|
1249
1260
|
}, [
|
|
1250
1261
|
uploadQueue,
|
|
@@ -1393,8 +1404,36 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1393
1404
|
}, 1000);
|
|
1394
1405
|
}
|
|
1395
1406
|
|
|
1396
|
-
|
|
1397
|
-
|
|
1407
|
+
// Gate read once, at send: OFF runs today's code unchanged; ON goes through the
|
|
1408
|
+
// kit's one send helper (hub reports state and the public events, once).
|
|
1409
|
+
const routed = routeSend(textMessage, "text", () => {
|
|
1410
|
+
CometChat.sendMessage(textMessage)
|
|
1411
|
+
.then((message: any) => {
|
|
1412
|
+
if (isAgenticUser() && !parentMessageId && message?.getId) {
|
|
1413
|
+
const messageId = typeof message.getId() === 'string' ? Number(message.getId()) : message.getId();
|
|
1414
|
+
if (!isNaN(messageId) && !parentMessageIdRef.current) {
|
|
1415
|
+
parentMessageIdRef.current = messageId;
|
|
1416
|
+
}
|
|
1417
|
+
if (messageId && !isNaN(messageId)) {
|
|
1418
|
+
startStreamingForRunId(String(messageId));
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1423
|
+
message: message,
|
|
1424
|
+
status: messageStatus.success,
|
|
1425
|
+
});
|
|
1426
|
+
})
|
|
1427
|
+
.catch((error: any) => {
|
|
1428
|
+
onError && onError(error);
|
|
1429
|
+
textMessage.setMetadata({ error: true });
|
|
1430
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1431
|
+
message: textMessage,
|
|
1432
|
+
status: messageStatus.error,
|
|
1433
|
+
});
|
|
1434
|
+
});
|
|
1435
|
+
}, {
|
|
1436
|
+
onSent: (message: any) => {
|
|
1398
1437
|
if (isAgenticUser() && !parentMessageId && message?.getId) {
|
|
1399
1438
|
const messageId = typeof message.getId() === 'string' ? Number(message.getId()) : message.getId();
|
|
1400
1439
|
if (!isNaN(messageId) && !parentMessageIdRef.current) {
|
|
@@ -1404,20 +1443,10 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1404
1443
|
startStreamingForRunId(String(messageId));
|
|
1405
1444
|
}
|
|
1406
1445
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
});
|
|
1412
|
-
})
|
|
1413
|
-
.catch((error: any) => {
|
|
1414
|
-
onError && onError(error);
|
|
1415
|
-
textMessage.setMetadata({ error: true });
|
|
1416
|
-
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1417
|
-
message: textMessage,
|
|
1418
|
-
status: messageStatus.error,
|
|
1419
|
-
});
|
|
1420
|
-
});
|
|
1446
|
+
},
|
|
1447
|
+
onFailed: quietAwareOnError(onError),
|
|
1448
|
+
});
|
|
1449
|
+
void routed;
|
|
1421
1450
|
};
|
|
1422
1451
|
|
|
1423
1452
|
/** edit message */
|
|
@@ -1463,9 +1492,13 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1463
1492
|
outgoing = textMessage;
|
|
1464
1493
|
}
|
|
1465
1494
|
|
|
1495
|
+
// The composer is cleared and leaves edit mode before the request, offline on or off. A failed
|
|
1496
|
+
// edit goes to onError (plus the offline error notice below); the text is not put back, as on
|
|
1497
|
+
// the Android UI Kit.
|
|
1498
|
+
const offlineOn = isOfflineOn();
|
|
1499
|
+
|
|
1466
1500
|
inputValueRef.current = "";
|
|
1467
1501
|
clearInputBox();
|
|
1468
|
-
messageInputRef.current.textContent = "";
|
|
1469
1502
|
|
|
1470
1503
|
setMessagePreview(null);
|
|
1471
1504
|
|
|
@@ -1487,6 +1520,9 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1487
1520
|
})
|
|
1488
1521
|
.catch((error: any) => {
|
|
1489
1522
|
onError && onError(error);
|
|
1523
|
+
// Offline ON: today's error notice too (ENG-41199).
|
|
1524
|
+
const errorText = offlineMutationErrorText(offlineOn, t);
|
|
1525
|
+
if (errorText) showToast(errorText);
|
|
1490
1526
|
});
|
|
1491
1527
|
};
|
|
1492
1528
|
|
|
@@ -1621,25 +1657,40 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1621
1657
|
});
|
|
1622
1658
|
|
|
1623
1659
|
if (!disableSoundForOutgoingMessages) playAudio();
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
if (replyMessageId) {
|
|
1631
|
-
CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
|
|
1660
|
+
// Gate read once, at send: OFF runs today's code unchanged; ON goes through the
|
|
1661
|
+
// kit's one send helper (hub reports state and the public events, once).
|
|
1662
|
+
const routed = routeSend(mediaMessage, "media", () => {
|
|
1663
|
+
CometChat.sendMediaMessage(mediaMessage)
|
|
1664
|
+
.then((message: any) => {
|
|
1665
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1632
1666
|
message: message,
|
|
1633
1667
|
status: messageStatus.success,
|
|
1634
1668
|
});
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1669
|
+
if (replyMessageId) {
|
|
1670
|
+
CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
|
|
1671
|
+
message: message,
|
|
1672
|
+
status: messageStatus.success,
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
setReplyMessage(null);
|
|
1676
|
+
setWarningMessage("");
|
|
1677
|
+
setShowRecordAudio(false);
|
|
1678
|
+
})
|
|
1679
|
+
.catch((error: any) => {
|
|
1680
|
+
setShowRecordAudio(false);
|
|
1681
|
+
if (error?.code === "ERR_PERMISSION_DENIED") {
|
|
1682
|
+
onError && onError(error);
|
|
1683
|
+
// Set error in data.metaData where the message list receipt logic checks
|
|
1684
|
+
const currentData = localMessage.getData() || {};
|
|
1685
|
+
localMessage.setData({ ...currentData, metaData: { error: true } });
|
|
1686
|
+
localMessage.setMetadata({ error: true });
|
|
1687
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1688
|
+
message: localMessage,
|
|
1689
|
+
status: messageStatus.error,
|
|
1690
|
+
});
|
|
1691
|
+
setReplyMessage(null);
|
|
1692
|
+
return;
|
|
1693
|
+
}
|
|
1643
1694
|
onError && onError(error);
|
|
1644
1695
|
// Set error in data.metaData where the message list receipt logic checks
|
|
1645
1696
|
const currentData = localMessage.getData() || {};
|
|
@@ -1650,19 +1701,19 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1650
1701
|
status: messageStatus.error,
|
|
1651
1702
|
});
|
|
1652
1703
|
setReplyMessage(null);
|
|
1653
|
-
return;
|
|
1654
|
-
}
|
|
1655
|
-
onError && onError(error);
|
|
1656
|
-
// Set error in data.metaData where the message list receipt logic checks
|
|
1657
|
-
const currentData = localMessage.getData() || {};
|
|
1658
|
-
localMessage.setData({ ...currentData, metaData: { error: true } });
|
|
1659
|
-
localMessage.setMetadata({ error: true });
|
|
1660
|
-
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
1661
|
-
message: localMessage,
|
|
1662
|
-
status: messageStatus.error,
|
|
1663
1704
|
});
|
|
1664
|
-
|
|
1665
|
-
|
|
1705
|
+
}, {
|
|
1706
|
+
onSent: (message: any) => {
|
|
1707
|
+
if (replyMessageId) {
|
|
1708
|
+
CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
|
|
1709
|
+
message: message,
|
|
1710
|
+
status: messageStatus.success,
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
},
|
|
1714
|
+
onFailed: quietAwareOnError(onError),
|
|
1715
|
+
});
|
|
1716
|
+
afterFirstAnswer(routed, () => { setReplyMessage(null); setWarningMessage(""); setShowRecordAudio(false); });
|
|
1666
1717
|
};
|
|
1667
1718
|
|
|
1668
1719
|
const startTyping = (endTypingTimeout?: any, typingMetadata?: any) => {
|
|
@@ -1885,6 +1936,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1885
1936
|
: sendTextMessage;
|
|
1886
1937
|
return (
|
|
1887
1938
|
<TouchableOpacity
|
|
1939
|
+
testID="CometChatComposer.send"
|
|
1888
1940
|
onPress={handleSendPress}
|
|
1889
1941
|
style={[
|
|
1890
1942
|
{
|
|
@@ -1964,7 +2016,9 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1964
2016
|
// for the SAME conversation doesn't wipe a tray the user is mid-staging. Skip the first
|
|
1965
2017
|
// assignment (chatWithId.current === null → nothing staged yet).
|
|
1966
2018
|
if (chatWithId.current != null && chatWithId.current !== newChatWithId) {
|
|
1967
|
-
|
|
2019
|
+
// Offline OFF: destroy the batch as today. Offline ON: detach; the SDK keeps it for a
|
|
2020
|
+
// restore when the user comes back (BEH-UPLOAD-14).
|
|
2021
|
+
uploadQueue.leave();
|
|
1968
2022
|
setSelectedAttachments([]);
|
|
1969
2023
|
selectedAttachmentsRef.current = [];
|
|
1970
2024
|
}
|
|
@@ -1987,6 +2041,22 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1987
2041
|
}
|
|
1988
2042
|
}, [user, group, chatRef]);
|
|
1989
2043
|
|
|
2044
|
+
// Offline ON: a thread switch in the same chat lets go of the previous thread's tray. The
|
|
2045
|
+
// receiver guard above only sees chat switches. Offline OFF: nothing.
|
|
2046
|
+
useOfflineThreadTrayReset(uploadQueue, parentMessageId, selectedAttachmentsRef, setSelectedAttachments);
|
|
2047
|
+
|
|
2048
|
+
// Offline ON: restore this chat's tray and clear it with the session. Offline OFF: nothing.
|
|
2049
|
+
useOfflineUploadTray(
|
|
2050
|
+
uploadQueue,
|
|
2051
|
+
{
|
|
2052
|
+
receiver: user?.getUid?.() ?? group?.getGuid?.(),
|
|
2053
|
+
receiverType: user?.getUid?.() ? ReceiverTypeConstants.user : group?.getGuid?.() ? ReceiverTypeConstants.group : undefined,
|
|
2054
|
+
parentMessageId,
|
|
2055
|
+
},
|
|
2056
|
+
selectedAttachmentsRef,
|
|
2057
|
+
setSelectedAttachments
|
|
2058
|
+
);
|
|
2059
|
+
|
|
1990
2060
|
const handleOnClick = (CustomView: any) => {
|
|
1991
2061
|
let view = CustomView(
|
|
1992
2062
|
user,
|
|
@@ -2108,6 +2178,23 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
2108
2178
|
replyMessage,
|
|
2109
2179
|
]);
|
|
2110
2180
|
|
|
2181
|
+
// An agent chat that opens on its last conversation (CometChatMessageList's
|
|
2182
|
+
// loadLastAgentConversation) announces that conversation through ccActiveChatChanged.
|
|
2183
|
+
// Continue THAT conversation: without it the next question went out with no parent, the
|
|
2184
|
+
// server started a new conversation the list doesn't track, and every later question was
|
|
2185
|
+
// stamped with the new root and filtered out of the list until a reload (ENG-41058).
|
|
2186
|
+
// Read through a ref so the once-registered listener sees current props.
|
|
2187
|
+
const adoptAgentConversationRef = useRef<(item: any) => void>(() => {});
|
|
2188
|
+
adoptAgentConversationRef.current = (item: any) => {
|
|
2189
|
+
if (!isAgenticUser() || parentMessageId || parentMessageIdRef.current) return;
|
|
2190
|
+
if (item?.parentMessageId) return; // a thread view's list, not the main agent chat
|
|
2191
|
+
const msg = item?.message;
|
|
2192
|
+
if (!msg || item?.user?.getUid?.() !== user?.getUid?.()) return;
|
|
2193
|
+
const loadedParentId = Number(msg.getParentMessageId?.());
|
|
2194
|
+
const rootId = loadedParentId > 0 ? loadedParentId : Number(msg.getId?.());
|
|
2195
|
+
if (rootId > 0) parentMessageIdRef.current = String(rootId);
|
|
2196
|
+
};
|
|
2197
|
+
|
|
2111
2198
|
useEffect(() => {
|
|
2112
2199
|
CometChatUIEventHandler.addMessageListener(editMessageListenerID, {
|
|
2113
2200
|
ccMessageEdited: (item: any) => {
|
|
@@ -2118,6 +2205,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
2118
2205
|
previewMessage(item);
|
|
2119
2206
|
}
|
|
2120
2207
|
},
|
|
2208
|
+
ccActiveChatChanged: (item: any) => adoptAgentConversationRef.current(item),
|
|
2121
2209
|
});
|
|
2122
2210
|
CometChatMessageEvents.addListener(
|
|
2123
2211
|
CometChatMessageEvents.ccReplyToMessage,
|
|
@@ -11,6 +11,7 @@ import { deepMerge } from "../shared/helper/helperFunctions";
|
|
|
11
11
|
import { Icon } from "../shared/icons/Icon";
|
|
12
12
|
import { CometChatAvatar } from "../shared/views/CometChatAvatar";
|
|
13
13
|
import { CometChatStatusIndicator } from "../shared/views/CometChatStatusIndicator";
|
|
14
|
+
import { usePresenceHidden } from "../shared/offline/usePresenceHidden";
|
|
14
15
|
import { useTheme } from "../theme";
|
|
15
16
|
import { MessageHeaderStyle } from "./styles";
|
|
16
17
|
import { CommonUtils } from "../shared/utils/CommonUtils";
|
|
@@ -230,6 +231,8 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
230
231
|
const [userObj, setUserObj] = useState<CometChat.User | undefined>(user);
|
|
231
232
|
const [userStatus, setUserStatus] = useState(user && user.getStatus ? user.getStatus() : "");
|
|
232
233
|
const [typingText, setTypingText] = useState("");
|
|
234
|
+
// Offline ON, SDK not connected: no presence subtitle and no typing text (nothing can arrive).
|
|
235
|
+
const presenceHidden = usePresenceHidden();
|
|
233
236
|
const [showOptionsMenu, setShowOptionsMenu] = useState(false);
|
|
234
237
|
const [tooltipPosition, setTooltipPosition] = useState({ pageX: 0, pageY: 0 });
|
|
235
238
|
const receiverTypeRef = useRef(
|
|
@@ -450,7 +453,7 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
450
453
|
*/
|
|
451
454
|
const SubtitleViewFnc = useCallback(() => {
|
|
452
455
|
try {
|
|
453
|
-
if (typingText !== "")
|
|
456
|
+
if (typingText !== "" && !presenceHidden)
|
|
454
457
|
return (
|
|
455
458
|
<Text
|
|
456
459
|
numberOfLines={1}
|
|
@@ -473,7 +476,8 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
473
476
|
userObj &&
|
|
474
477
|
!(userObj.getBlockedByMe() || userObj.getHasBlockedMe()) &&
|
|
475
478
|
usersStatusVisibility &&
|
|
476
|
-
userStatus
|
|
479
|
+
userStatus &&
|
|
480
|
+
!presenceHidden
|
|
477
481
|
) {
|
|
478
482
|
subtitle =
|
|
479
483
|
userStatus === UserStatusConstants.online
|
|
@@ -490,7 +494,7 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
490
494
|
errorHandler(error);
|
|
491
495
|
return <></>;
|
|
492
496
|
}
|
|
493
|
-
}, [userObj, groupObj, messageHeaderStyles, usersStatusVisibility, userStatus]);
|
|
497
|
+
}, [userObj, groupObj, messageHeaderStyles, usersStatusVisibility, userStatus, presenceHidden]);
|
|
494
498
|
|
|
495
499
|
/**
|
|
496
500
|
* Error handler to call onError with a proper CometChatException.
|
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
2
|
import { CometChatUIEventHandler, CometChatUIKit } from "../shared";
|
|
3
|
+
import { OfflineHub } from "../shared/offline/OfflineHub";
|
|
4
|
+
import { dispatchSweptGroupAction } from "../shared/offline/groupActions";
|
|
5
|
+
|
|
6
|
+
/** Hub subscriptions for swept group actions, per header group listener id. */
|
|
7
|
+
const sweptGroupActionSubscriptions = new Map<string, { unsubscribe(): void }>();
|
|
8
|
+
|
|
9
|
+
/** The header's GroupListener handlers, shared by the live listener and swept actions. */
|
|
10
|
+
export const groupListenerHandlers = (handleGroupListener: (group: CometChat.Group) => void) => ({
|
|
11
|
+
onGroupMemberKicked: (
|
|
12
|
+
message: any,
|
|
13
|
+
kickedUser: CometChat.User,
|
|
14
|
+
kickedBy: CometChat.User,
|
|
15
|
+
kickedFrom: CometChat.Group
|
|
16
|
+
) => {
|
|
17
|
+
handleGroupListener(kickedFrom);
|
|
18
|
+
},
|
|
19
|
+
onGroupMemberBanned: (
|
|
20
|
+
message: any,
|
|
21
|
+
bannedUser: CometChat.User,
|
|
22
|
+
bannedBy: CometChat.User,
|
|
23
|
+
bannedFrom: CometChat.Group
|
|
24
|
+
) => {
|
|
25
|
+
handleGroupListener(bannedFrom);
|
|
26
|
+
},
|
|
27
|
+
onMemberAddedToGroup: (
|
|
28
|
+
message: any,
|
|
29
|
+
userAdded: CometChat.User,
|
|
30
|
+
userAddedBy: CometChat.User,
|
|
31
|
+
userAddedIn: CometChat.Group
|
|
32
|
+
) => {
|
|
33
|
+
console.log("onMemberAddedToGroup", userAddedIn);
|
|
34
|
+
handleGroupListener(userAddedIn);
|
|
35
|
+
},
|
|
36
|
+
onGroupMemberLeft: (
|
|
37
|
+
message: any,
|
|
38
|
+
leavingUser: CometChat.User,
|
|
39
|
+
group: CometChat.Group
|
|
40
|
+
) => {
|
|
41
|
+
handleGroupListener(group);
|
|
42
|
+
},
|
|
43
|
+
onGroupMemberJoined: (
|
|
44
|
+
message: any,
|
|
45
|
+
joinedUser: CometChat.User,
|
|
46
|
+
joinedGroup: CometChat.Group
|
|
47
|
+
) => {
|
|
48
|
+
handleGroupListener(joinedGroup);
|
|
49
|
+
},
|
|
50
|
+
onGroupMemberScopeChanged: (
|
|
51
|
+
message: CometChat.Action,
|
|
52
|
+
changedUser: CometChat.GroupMember,
|
|
53
|
+
newScope: CometChat.GroupMemberScope,
|
|
54
|
+
oldScope: CometChat.GroupMemberScope,
|
|
55
|
+
changedGroup: CometChat.Group
|
|
56
|
+
) => {
|
|
57
|
+
if (changedUser.getUid() !== CometChatUIKit.loggedInUser?.getUid()) return;
|
|
58
|
+
changedGroup.setScope(newScope);
|
|
59
|
+
handleGroupListener(changedGroup);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
3
62
|
|
|
4
63
|
export const listners = {
|
|
5
64
|
addListener: {
|
|
@@ -26,62 +85,20 @@ export const listners = {
|
|
|
26
85
|
msgTypingIndicator(typistDetails, "");
|
|
27
86
|
},
|
|
28
87
|
}),
|
|
29
|
-
groupListener: ({ groupListenerId, handleGroupListener }: any) =>
|
|
30
|
-
|
|
88
|
+
groupListener: ({ groupListenerId, handleGroupListener }: any) => {
|
|
89
|
+
const handlers = groupListenerHandlers(handleGroupListener);
|
|
90
|
+
CometChat.addGroupListener(groupListenerId, new CometChat.GroupListener(handlers));
|
|
91
|
+
// Offline (ON path): a group action the catch-up sweep delivered fires no GroupListener
|
|
92
|
+
// callback; run the same handlers for it (UIT-SYNC-13). Inert with offline off.
|
|
93
|
+
sweptGroupActionSubscriptions.get(groupListenerId)?.unsubscribe();
|
|
94
|
+
sweptGroupActionSubscriptions.set(
|
|
31
95
|
groupListenerId,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
kickedUser: CometChat.User,
|
|
36
|
-
kickedBy: CometChat.User,
|
|
37
|
-
kickedFrom: CometChat.Group
|
|
38
|
-
) => {
|
|
39
|
-
handleGroupListener(kickedFrom);
|
|
40
|
-
},
|
|
41
|
-
onGroupMemberBanned: (
|
|
42
|
-
message: any,
|
|
43
|
-
bannedUser: CometChat.User,
|
|
44
|
-
bannedBy: CometChat.User,
|
|
45
|
-
bannedFrom: CometChat.Group
|
|
46
|
-
) => {
|
|
47
|
-
handleGroupListener(bannedFrom);
|
|
48
|
-
},
|
|
49
|
-
onMemberAddedToGroup: (
|
|
50
|
-
message: any,
|
|
51
|
-
userAdded: CometChat.User,
|
|
52
|
-
userAddedBy: CometChat.User,
|
|
53
|
-
userAddedIn: CometChat.Group
|
|
54
|
-
) => {
|
|
55
|
-
console.log("onMemberAddedToGroup", userAddedIn);
|
|
56
|
-
handleGroupListener(userAddedIn);
|
|
57
|
-
},
|
|
58
|
-
onGroupMemberLeft: (
|
|
59
|
-
message: any,
|
|
60
|
-
leavingUser: CometChat.User,
|
|
61
|
-
group: CometChat.Group
|
|
62
|
-
) => {
|
|
63
|
-
handleGroupListener(group);
|
|
64
|
-
},
|
|
65
|
-
onGroupMemberJoined: (
|
|
66
|
-
message: any,
|
|
67
|
-
joinedUser: CometChat.User,
|
|
68
|
-
joinedGroup: CometChat.Group
|
|
69
|
-
) => {
|
|
70
|
-
handleGroupListener(joinedGroup);
|
|
71
|
-
},
|
|
72
|
-
onGroupMemberScopeChanged: (
|
|
73
|
-
message: CometChat.Action,
|
|
74
|
-
changedUser: CometChat.GroupMember,
|
|
75
|
-
newScope: CometChat.GroupMemberScope,
|
|
76
|
-
oldScope: CometChat.GroupMemberScope,
|
|
77
|
-
changedGroup: CometChat.Group
|
|
78
|
-
) => {
|
|
79
|
-
if (changedUser.getUid() !== CometChatUIKit.loggedInUser?.getUid()) return;
|
|
80
|
-
changedGroup.setScope(newScope);
|
|
81
|
-
handleGroupListener(changedGroup);
|
|
82
|
-
},
|
|
96
|
+
OfflineHub.getInstance().groupActionSwept$.subscribe((event) => {
|
|
97
|
+
if (event.gen !== OfflineHub.getInstance().gen) return;
|
|
98
|
+
dispatchSweptGroupAction(event.message, handlers);
|
|
83
99
|
})
|
|
84
|
-
)
|
|
100
|
+
);
|
|
101
|
+
},
|
|
85
102
|
},
|
|
86
103
|
removeListner: {
|
|
87
104
|
removeUserListener: ({ userStatusListenerId }: any) =>
|
|
@@ -90,7 +107,10 @@ export const listners = {
|
|
|
90
107
|
removeMessageListener: ({ msgTypingListenerId }: any) =>
|
|
91
108
|
CometChatUIEventHandler.removeMessageListener(msgTypingListenerId),
|
|
92
109
|
|
|
93
|
-
removeGroupListener: ({ groupListenerId }: any) =>
|
|
94
|
-
|
|
110
|
+
removeGroupListener: ({ groupListenerId }: any) => {
|
|
111
|
+
sweptGroupActionSubscriptions.get(groupListenerId)?.unsubscribe();
|
|
112
|
+
sweptGroupActionSubscriptions.delete(groupListenerId);
|
|
113
|
+
return CometChat.removeGroupListener(groupListenerId);
|
|
114
|
+
},
|
|
95
115
|
},
|
|
96
116
|
};
|