@cometchat/chat-uikit-react-native 5.3.5 → 5.3.7
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 +18 -1
- package/ios/FileManager.m +14 -3
- package/ios/SoundPlayer.m +24 -1
- package/package.json +2 -1
- package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +8 -3
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +14 -11
- package/src/CometChatConversations/CometChatConversations.tsx +89 -51
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +10 -11
- package/src/CometChatGroups/CometChatGroups.tsx +49 -42
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +10 -7
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +12 -10
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +4 -3
- package/src/CometChatMessageList/CometChatMessageList.tsx +398 -144
- package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +478 -0
- package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +613 -0
- package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +4 -1
- package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +811 -0
- package/src/CometChatNotificationFeed/Skeleton.tsx +43 -0
- package/src/CometChatNotificationFeed/index.ts +19 -0
- package/src/CometChatNotificationFeed/style.ts +333 -0
- package/src/CometChatNotificationFeed/utils.ts +124 -0
- package/src/CometChatSearch/CometChatSearch.tsx +8 -6
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +4 -3
- package/src/CometChatUsers/CometChatUsers.tsx +56 -43
- package/src/calls/CallingExtensionDecorator.tsx +1 -1
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +3 -2
- package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +7 -6
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +2 -1
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +2 -1
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +4 -4
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +5 -3
- package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +1 -1
- package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +5 -5
- package/src/extensions/Polls/PollsBubble.tsx +1 -1
- package/src/extensions/Polls/PollsDecorator.tsx +1 -1
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -2
- package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +9 -5
- package/src/index.ts +7 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +48 -20
- package/src/shared/events/ListenerInitializer.ts +2 -1
- package/src/shared/framework/MessageDataSource.tsx +19 -15
- package/src/shared/helper/helperFunctions.ts +5 -4
- package/src/shared/icons/components/notification-empty.tsx +27 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +8 -1
- package/src/shared/services/stream-message.service.ts +0 -1
- package/src/shared/utils/CommonUtils.ts +1 -1
- package/src/shared/utils/MessageUtils.tsx +15 -13
- package/src/shared/utils/conversationUtils.ts +2 -2
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +2 -2
- package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +17 -5
- package/src/shared/views/CometChatList/CometChatList.tsx +11 -15
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +3 -3
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +2 -1
- package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +15 -4
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -3
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +15 -1
- package/src/theme/default/default.ts +6 -0
- package/src/theme/provider.tsx +12 -12
- package/src/theme/type.ts +2 -0
|
@@ -561,6 +561,12 @@ public class FileManager extends ReactContextBaseJavaModule {
|
|
|
561
561
|
audioRecorder.setAudioSamplingRate(44100);
|
|
562
562
|
audioRecorder.setOutputFile(fileName);
|
|
563
563
|
|
|
564
|
+
// Keep screen on during recording to prevent device sleep
|
|
565
|
+
// Set BEFORE starting recorder to avoid race with auto-lock
|
|
566
|
+
activity.runOnUiThread(() -> {
|
|
567
|
+
activity.getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
568
|
+
});
|
|
569
|
+
|
|
564
570
|
audioRecorder.prepare();
|
|
565
571
|
audioRecorder.start();
|
|
566
572
|
|
|
@@ -573,6 +579,10 @@ public class FileManager extends ReactContextBaseJavaModule {
|
|
|
573
579
|
try { if (audioRecorder != null) audioRecorder.release(); } catch (Exception ignore) {}
|
|
574
580
|
audioRecorder = null;
|
|
575
581
|
stopAmplitudePolling();
|
|
582
|
+
// Clear the keep-screen-on flag since recording failed
|
|
583
|
+
activity.runOnUiThread(() -> {
|
|
584
|
+
activity.getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
585
|
+
});
|
|
576
586
|
callback.invoke("{\"success\": false, \"error\": \"" + e.getMessage() + "\"}");
|
|
577
587
|
}
|
|
578
588
|
}
|
|
@@ -849,6 +859,14 @@ public class FileManager extends ReactContextBaseJavaModule {
|
|
|
849
859
|
audioRecorder = null;
|
|
850
860
|
}
|
|
851
861
|
|
|
862
|
+
// Re-enable screen sleep since recording has stopped
|
|
863
|
+
Activity activity = getCurrentActivity();
|
|
864
|
+
if (activity != null) {
|
|
865
|
+
activity.runOnUiThread(() -> {
|
|
866
|
+
activity.getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
|
|
852
870
|
// Stop any playback
|
|
853
871
|
if (audioPlayer != null) {
|
|
854
872
|
try {
|
|
@@ -860,7 +878,6 @@ public class FileManager extends ReactContextBaseJavaModule {
|
|
|
860
878
|
|
|
861
879
|
// Build result JSON your JS expects: it parses .file (Android) and .duration (iOS use-case)
|
|
862
880
|
try {
|
|
863
|
-
Activity activity = getCurrentActivity();
|
|
864
881
|
JSONObject res = new JSONObject();
|
|
865
882
|
|
|
866
883
|
if (fileName != null) {
|
package/ios/FileManager.m
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
#import <React/RCTConvert.h>
|
|
7
7
|
#import <MobileCoreServices/MobileCoreServices.h>
|
|
8
8
|
#import <AVFoundation/AVFoundation.h>
|
|
9
|
+
#import <UIKit/UIKit.h>
|
|
9
10
|
|
|
10
11
|
static NSString *const E_DOCUMENT_PICKER_CANCELED = @"DOCUMENT_PICKER_CANCELED";
|
|
11
12
|
static NSString *const E_INVALID_DATA_RETURNED = @"INVALID_DATA_RETURNED";
|
|
@@ -411,9 +412,14 @@ RCT_EXPORT_METHOD(startRecording:(RCTResponseSenderBlock)callback) {
|
|
|
411
412
|
[self.recordingSession requestRecordPermission:^(BOOL granted) {
|
|
412
413
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
413
414
|
if (granted) {
|
|
414
|
-
//
|
|
415
|
-
[
|
|
416
|
-
|
|
415
|
+
// Disable idle timer to prevent device from sleeping during recording
|
|
416
|
+
[UIApplication sharedApplication].idleTimerDisabled = YES;
|
|
417
|
+
@try {
|
|
418
|
+
[self setupRecorderWithResult:callback];
|
|
419
|
+
} @catch (NSException *exception) {
|
|
420
|
+
[UIApplication sharedApplication].idleTimerDisabled = NO;
|
|
421
|
+
callback(@[[NSString stringWithFormat:@"{\"success\": false, \"error\": \"%@\"}", exception.reason]]);
|
|
422
|
+
}
|
|
417
423
|
} else {
|
|
418
424
|
callback(@[@"{\"granted\": false}"]);
|
|
419
425
|
// Failed to record
|
|
@@ -459,6 +465,7 @@ RCT_EXPORT_METHOD(resumeRecording:(RCTPromiseResolveBlock)resolve
|
|
|
459
465
|
self.audioRecorder = [[AVAudioRecorder alloc] initWithURL:self.audioFilename settings:settings error:&error];
|
|
460
466
|
if (error) {
|
|
461
467
|
[self stopRecordingWithSuccess:NO];
|
|
468
|
+
callback(@[[NSString stringWithFormat:@"{\"success\": false, \"error\": \"%@\"}", [error localizedDescription]]]);
|
|
462
469
|
} else {
|
|
463
470
|
self.audioRecorder.delegate = self;
|
|
464
471
|
self.audioRecorder.meteringEnabled = YES;
|
|
@@ -508,6 +515,10 @@ RCT_EXPORT_METHOD(stopRecordingAudio:(RCTResponseSenderBlock)callback) {
|
|
|
508
515
|
|
|
509
516
|
- (NSString *)stopRecordingWithSuccess:(BOOL)success {
|
|
510
517
|
[self stopAmplitudeTimer];
|
|
518
|
+
// Re-enable idle timer since recording has stopped
|
|
519
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
520
|
+
[UIApplication sharedApplication].idleTimerDisabled = NO;
|
|
521
|
+
});
|
|
511
522
|
if (success) {
|
|
512
523
|
[self.audioRecorder stop];
|
|
513
524
|
self.audioRecorder = nil;
|
package/ios/SoundPlayer.m
CHANGED
|
@@ -51,6 +51,19 @@ RCT_EXPORT_METHOD(prepareMediaPlayer:(NSString *) url
|
|
|
51
51
|
|
|
52
52
|
RCT_EXPORT_METHOD(play:(NSString *) url
|
|
53
53
|
callback:(RCTResponseSenderBlock) resolve) {
|
|
54
|
+
// Set audio session to Playback category to ensure audio plays even in silent mode
|
|
55
|
+
// Don't override if recording is active (PlayAndRecord category)
|
|
56
|
+
AVAudioSession *session = [AVAudioSession sharedInstance];
|
|
57
|
+
if (![session.category isEqualToString:AVAudioSessionCategoryPlayAndRecord]) {
|
|
58
|
+
NSError *sessionError = nil;
|
|
59
|
+
if (![session setCategory:AVAudioSessionCategoryPlayback error:&sessionError]) {
|
|
60
|
+
NSString *response = [NSString stringWithFormat:@"{\"success\":0, \"error\":\"%@\"}", [sessionError localizedDescription]];
|
|
61
|
+
resolve(@[response]);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
[session setActive:YES error:nil];
|
|
66
|
+
|
|
54
67
|
NSURL *nsurl;
|
|
55
68
|
if ([url hasPrefix:@"http"] || [url hasPrefix:@"https"]) {
|
|
56
69
|
nsurl = [NSURL URLWithString:url];
|
|
@@ -58,12 +71,22 @@ RCT_EXPORT_METHOD(play:(NSString *) url
|
|
|
58
71
|
nsurl = [NSURL fileURLWithPath:url]; // Use fileURLWithPath for local files
|
|
59
72
|
}
|
|
60
73
|
NSData *data = [NSData dataWithContentsOfURL:nsurl];
|
|
74
|
+
if (!data) {
|
|
75
|
+
resolve(@[@"{\"success\":0, \"error\":\"Failed to load audio data\"}"]);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
61
78
|
if ([audioPlayer isPlaying]) {
|
|
62
79
|
[audioPlayer stop];
|
|
63
80
|
[self sendEventWithName:@"soundPlayStatus" body:@{@"url": currentUrl}];
|
|
64
81
|
}
|
|
65
82
|
currentUrl = url;
|
|
66
|
-
|
|
83
|
+
NSError *playerError = nil;
|
|
84
|
+
audioPlayer = [[AVAudioPlayer alloc] initWithData:data error:&playerError];
|
|
85
|
+
if (!audioPlayer) {
|
|
86
|
+
NSString *response = [NSString stringWithFormat:@"{\"success\":0, \"error\":\"%@\"}", [playerError localizedDescription]];
|
|
87
|
+
resolve(@[response]);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
67
90
|
[audioPlayer setDelegate: self];
|
|
68
91
|
|
|
69
92
|
int playSuccess = [audioPlayer play];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cometchat/chat-uikit-react-native",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.7",
|
|
4
4
|
"description": "Ready-to-use Chat UI Components for React Native",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"module": "src/index",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"typescript": "^5.0.4"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
+
"@cometchat/cards-react-native": "^1.0.0",
|
|
68
69
|
"@types/prop-types": "^15.7.14",
|
|
69
70
|
"prop-types": "^15.8.1",
|
|
70
71
|
"react-native-markdown-display": "^7.0.2",
|
|
@@ -18,6 +18,7 @@ import { CometChatTooltipMenu } from "../shared/views/CometChatTooltipMenu";
|
|
|
18
18
|
import { CometChatConfirmDialog } from "../shared/views/CometChatConfirmDialog";
|
|
19
19
|
import Delete from "../shared/icons/components/delete";
|
|
20
20
|
import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
|
|
21
|
+
import { skipNextAgentAutoLoad } from "../CometChatMessageList/CometChatMessageList";
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
interface CometChatAIAssistantChatHistoryProps {
|
|
@@ -93,7 +94,7 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
|
|
|
93
94
|
return (theme as any).chatHistoryStyles || getChatHistoryStyleLight(theme.color, theme.spacing, theme.typography);
|
|
94
95
|
}, [theme]);
|
|
95
96
|
|
|
96
|
-
const mergedStyle = deepMerge(defaultStyles, style);
|
|
97
|
+
const mergedStyle = useMemo(() => deepMerge(defaultStyles, style ?? {}), [defaultStyles, style]);
|
|
97
98
|
|
|
98
99
|
// State variables
|
|
99
100
|
// Only show text messages in history
|
|
@@ -139,6 +140,7 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
|
|
|
139
140
|
if (newList.length === 0) {
|
|
140
141
|
setListState(States.empty);
|
|
141
142
|
// Call parent to reset agentic/parent state
|
|
143
|
+
skipNextAgentAutoLoad();
|
|
142
144
|
if (onNewChatButtonClick) {
|
|
143
145
|
onNewChatButtonClick();
|
|
144
146
|
}
|
|
@@ -253,7 +255,7 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
|
|
|
253
255
|
*/
|
|
254
256
|
const canDeleteMessage = useCallback((message: CometChat.BaseMessage): boolean => {
|
|
255
257
|
// Only allow deletion if user is the sender, message is not deleted, and not system/group
|
|
256
|
-
const isSender = message.getSender()
|
|
258
|
+
const isSender = message.getSender()?.getUid() === loggedInUserRef.current?.getUid();
|
|
257
259
|
const isDeletableCategory = message.getCategory && message.getCategory() === 'message';
|
|
258
260
|
const isNotDeleted = !message.getDeletedAt || !message.getDeletedAt();
|
|
259
261
|
return isSender && isDeletableCategory && isNotDeleted;
|
|
@@ -592,7 +594,10 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
|
|
|
592
594
|
{/* New Chat Button */}
|
|
593
595
|
<TouchableOpacity
|
|
594
596
|
style={mergedStyle.newChatButtonStyle}
|
|
595
|
-
onPress={
|
|
597
|
+
onPress={() => {
|
|
598
|
+
skipNextAgentAutoLoad();
|
|
599
|
+
onNewChatButtonClick?.();
|
|
600
|
+
}}
|
|
596
601
|
>
|
|
597
602
|
<Icon name="ai-new-chat" width={24} height={24} color={theme.color.textSecondary} />
|
|
598
603
|
<Text style={mergedStyle.newChatTextStyle}>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
let __listenerIdCounter = 0;
|
|
1
2
|
import React, { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo } from 'react';
|
|
2
3
|
import {
|
|
3
4
|
Animated,
|
|
@@ -110,11 +111,11 @@ import { ExtensionTypeConstants } from '../extensions/ExtensionConstants';
|
|
|
110
111
|
const { FileManager, CommonUtil } = NativeModules;
|
|
111
112
|
|
|
112
113
|
// Listener IDs at module scope (v5 pattern)
|
|
113
|
-
const editMessageListenerID = "editMessageListener_" +
|
|
114
|
-
const replyMessageListenerID = "replyMessageListener_" +
|
|
115
|
-
const uiEventListenerID = "uiEventListener_" +
|
|
116
|
-
const uiEventListenerShowID = "uiEventListenerShow_" +
|
|
117
|
-
const uiEventListenerHideID = "uiEventListenerHide_" +
|
|
114
|
+
const editMessageListenerID = "editMessageListener_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
115
|
+
const replyMessageListenerID = "replyMessageListener_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
116
|
+
const uiEventListenerID = "uiEventListener_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
117
|
+
const uiEventListenerShowID = "uiEventListenerShow_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
118
|
+
const uiEventListenerHideID = "uiEventListenerHide_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
118
119
|
|
|
119
120
|
// Mic/sticker animation constants (hoisted to module level)
|
|
120
121
|
const MIC_ANIM_DURATION = 150;
|
|
@@ -372,7 +373,7 @@ const EmojiButton = ({ user, group, composerIdMap, replyToMessage, closeReplyPre
|
|
|
372
373
|
customMessage.setCategory(CometChat.CATEGORY_CUSTOM as CometChat.MessageCategory);
|
|
373
374
|
customMessage.setParentMessageId(parentId);
|
|
374
375
|
customMessage.setMuid(String(getUnixTimestampInMilliseconds()));
|
|
375
|
-
customMessage.setSender(loggedInUser.current
|
|
376
|
+
customMessage.setSender(loggedInUser.current);
|
|
376
377
|
if (user || group) {
|
|
377
378
|
customMessage.setReceiver((user || group)!);
|
|
378
379
|
}
|
|
@@ -2033,7 +2034,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
2033
2034
|
receiverType
|
|
2034
2035
|
);
|
|
2035
2036
|
|
|
2036
|
-
mediaMessage.setSender(loggedInUser.current
|
|
2037
|
+
mediaMessage.setSender(loggedInUser.current);
|
|
2037
2038
|
mediaMessage.setReceiver((user || group)!);
|
|
2038
2039
|
mediaMessage.setType(messageType);
|
|
2039
2040
|
mediaMessage.setMuid(String(getUnixTimestampInMilliseconds()));
|
|
@@ -2066,7 +2067,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
2066
2067
|
receiverType
|
|
2067
2068
|
);
|
|
2068
2069
|
|
|
2069
|
-
localMessage.setSender(loggedInUser.current
|
|
2070
|
+
localMessage.setSender(loggedInUser.current);
|
|
2070
2071
|
localMessage.setReceiver((user || group)!);
|
|
2071
2072
|
localMessage.setType(messageType);
|
|
2072
2073
|
localMessage.setMuid(String(getUnixTimestampInMilliseconds()));
|
|
@@ -2142,12 +2143,14 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
2142
2143
|
* Send recorded audio as a media message
|
|
2143
2144
|
* Called when voice recording is completed and submitted
|
|
2144
2145
|
*/
|
|
2146
|
+
const buildRecordedAudioFileName = (recordedFile: string): string => ((recordedFile || '').split(/[?#]/)[0]?.split('/').pop() || `audio-recording-${Date.now()}.m4a`).replace(/^audio-merged/, 'audio-recording');
|
|
2147
|
+
|
|
2145
2148
|
const _sendRecordedAudio = (recordedFile: string) => {
|
|
2146
2149
|
// Invoke the onVoiceRecordingEnd callback if provided
|
|
2147
2150
|
onVoiceRecordingEnd?.(recordedFile);
|
|
2148
2151
|
|
|
2149
2152
|
const fileObj = {
|
|
2150
|
-
name:
|
|
2153
|
+
name: buildRecordedAudioFileName(recordedFile),
|
|
2151
2154
|
type: 'audio/mp4',
|
|
2152
2155
|
uri: recordedFile,
|
|
2153
2156
|
};
|
|
@@ -2166,7 +2169,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
2166
2169
|
*/
|
|
2167
2170
|
const handleInlineRecorderSubmit = useCallback((recordedFile: string) => {
|
|
2168
2171
|
const fileObj = {
|
|
2169
|
-
name:
|
|
2172
|
+
name: buildRecordedAudioFileName(recordedFile),
|
|
2170
2173
|
type: 'audio/mp4',
|
|
2171
2174
|
uri: recordedFile,
|
|
2172
2175
|
};
|
|
@@ -3721,7 +3724,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
3721
3724
|
chatWith.current
|
|
3722
3725
|
);
|
|
3723
3726
|
|
|
3724
|
-
textMessage.setSender(loggedInUser.current
|
|
3727
|
+
textMessage.setSender(loggedInUser.current);
|
|
3725
3728
|
textMessage.setReceiver((user || group)!);
|
|
3726
3729
|
textMessage.setMuid(String(getUnixTimestampInMilliseconds()));
|
|
3727
3730
|
|
|
@@ -61,12 +61,14 @@ import { MenuItemInterface } from "../shared/views/CometChatTooltipMenu/CometCha
|
|
|
61
61
|
import { JSX } from "react";
|
|
62
62
|
import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
|
|
63
63
|
|
|
64
|
+
let __listenerIdCounter = 0;
|
|
65
|
+
|
|
64
66
|
// Unique listener IDs for conversation, user, group, message and call events.
|
|
65
|
-
const conversationListenerId = "chatlist_" +
|
|
66
|
-
const userListenerId = "chatlist_user_" +
|
|
67
|
-
const groupListenerId = "chatlist_group_" +
|
|
68
|
-
const messageListenerId = "chatlist_message_" +
|
|
69
|
-
const callListenerId = "call_" +
|
|
67
|
+
const conversationListenerId = "chatlist_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
68
|
+
const userListenerId = "chatlist_user_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
69
|
+
const groupListenerId = "chatlist_group_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
70
|
+
const messageListenerId = "chatlist_message_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
71
|
+
const callListenerId = "call_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
70
72
|
|
|
71
73
|
/** Module-level rich text formatter — reused across renders (no GC churn) */
|
|
72
74
|
const conversationRichTextFormatter = new CometChatRichTextFormatter();
|
|
@@ -500,7 +502,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
500
502
|
} else {
|
|
501
503
|
delete newConversation["lastMessage"]["typing"];
|
|
502
504
|
}
|
|
503
|
-
conversationListRef.current
|
|
505
|
+
conversationListRef.current?.updateList(newConversation);
|
|
504
506
|
}
|
|
505
507
|
};
|
|
506
508
|
|
|
@@ -511,11 +513,11 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
511
513
|
const checkAndUpdateLastMessage = (newMessage: CometChat.BaseMessage) => {
|
|
512
514
|
CometChat.CometChatHelper.getConversationFromMessage(newMessage).then(
|
|
513
515
|
(conversation: CometChat.Conversation) => {
|
|
514
|
-
let conver: CometChat.Conversation = conversationListRef.current
|
|
516
|
+
let conver: CometChat.Conversation = conversationListRef.current?.getListItem(
|
|
515
517
|
conversation.getConversationId()
|
|
516
518
|
);
|
|
517
519
|
if (!conver) return;
|
|
518
|
-
let lastMessageId = conver.getLastMessage()
|
|
520
|
+
let lastMessageId = conver.getLastMessage()?.getId();
|
|
519
521
|
if (lastMessageId == newMessage.getId()) {
|
|
520
522
|
// Preserve the real-time user status from the existing conversation.
|
|
521
523
|
// The server-returned conversation may have stale user status/lastActiveAt.
|
|
@@ -542,7 +544,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
542
544
|
newLastMsg.setDeliveredAt(existingLastMsg.getDeliveredAt());
|
|
543
545
|
}
|
|
544
546
|
}
|
|
545
|
-
conversationListRef.current
|
|
547
|
+
conversationListRef.current?.updateList(CommonUtils.clone(conversation));
|
|
546
548
|
}
|
|
547
549
|
}
|
|
548
550
|
);
|
|
@@ -565,14 +567,15 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
565
567
|
// Do not update for custom messages if not allowed.
|
|
566
568
|
if (message.getCategory() == CometChatUiKitConstants.MessageCategoryConstants.custom) {
|
|
567
569
|
let customMessage = message as CometChat.CustomMessage;
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
570
|
+
|
|
571
|
+
// Group calls arrive as custom messages with type "meeting" —
|
|
572
|
+
// they should respect the call activities setting, not the custom messages setting.
|
|
573
|
+
if (customMessage.getType() === CometChatUiKitConstants.MessageTypeConstants.meeting) {
|
|
574
|
+
return CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities();
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// When "Include Custom Messages" is OFF, block all custom messages from updating unread count
|
|
578
|
+
if (!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCustomMessages()) {
|
|
576
579
|
return false;
|
|
577
580
|
}
|
|
578
581
|
}
|
|
@@ -605,7 +608,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
605
608
|
if (newMessage.getCategory() === MessageCategoryConstants.interactive) {
|
|
606
609
|
// TODO: Show unsupported message view.
|
|
607
610
|
}
|
|
608
|
-
const oldConversation: CometChat.Conversation = conversationListRef.current
|
|
611
|
+
const oldConversation: CometChat.Conversation = conversationListRef.current?.getListItem(
|
|
609
612
|
conversation.getConversationId()
|
|
610
613
|
);
|
|
611
614
|
if (oldConversation == undefined) {
|
|
@@ -617,7 +620,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
617
620
|
loggedInUser.current?.getUid()
|
|
618
621
|
)
|
|
619
622
|
newConversation.setUnreadMessageCount(1);
|
|
620
|
-
conversationListRef.current
|
|
623
|
+
conversationListRef.current?.addItemToList(newConversation, 0);
|
|
621
624
|
})
|
|
622
625
|
.catch((err) => onError && onError(err));
|
|
623
626
|
return;
|
|
@@ -649,7 +652,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
649
652
|
oldConversation.setLastMessage(newMessage);
|
|
650
653
|
if (newMessage.getSender().getUid() != loggedInUser.current?.getUid())
|
|
651
654
|
oldConversation.setUnreadMessageCount(oldConversation.getUnreadMessageCount() + 1);
|
|
652
|
-
conversationListRef.current
|
|
655
|
+
conversationListRef.current?.updateAndMoveToFirst(CommonUtils.clone(oldConversation));
|
|
653
656
|
})
|
|
654
657
|
.catch((err) => {
|
|
655
658
|
console.log("Error", err);
|
|
@@ -723,7 +726,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
723
726
|
if (
|
|
724
727
|
conv &&
|
|
725
728
|
(conv as CometChat.Conversation).getConversationType() == ConversationTypeConstants.group &&
|
|
726
|
-
(conv as CometChat.Conversation).getLastMessage().getSender().getUid() !== loggedInUser.current
|
|
729
|
+
(conv as CometChat.Conversation).getLastMessage().getSender().getUid() !== loggedInUser.current?.getUid()
|
|
727
730
|
) {
|
|
728
731
|
return;
|
|
729
732
|
}
|
|
@@ -788,48 +791,70 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
788
791
|
group?: CometChat.Group;
|
|
789
792
|
newScope?: CometChat.GroupMemberScope;
|
|
790
793
|
oldScope?: CometChat.GroupMemberScope;
|
|
791
|
-
} = {}
|
|
794
|
+
} = {},
|
|
795
|
+
_depth: number = 0
|
|
792
796
|
) => {
|
|
793
|
-
|
|
797
|
+
if (!conversationListRef.current) return;
|
|
798
|
+
|
|
799
|
+
let conversation: CometChat.Conversation = conversationListRef.current.getListItem(
|
|
794
800
|
message.getConversationId()
|
|
795
801
|
) as unknown as CometChat.Conversation;
|
|
796
|
-
let { action, actionOn,
|
|
802
|
+
let { action, actionOn, group, newScope, oldScope } = otherDetails;
|
|
803
|
+
|
|
797
804
|
if (conversation) {
|
|
798
|
-
if (action
|
|
805
|
+
if (action === "scopeChange" && actionOn?.getUid() !== loggedInUser.current?.getUid()) {
|
|
799
806
|
oldScope = undefined;
|
|
800
807
|
newScope = undefined;
|
|
801
808
|
}
|
|
802
|
-
|
|
803
|
-
oldScope ?? (conversation.getConversationWith() as CometChat.Group).getScope();
|
|
809
|
+
|
|
804
810
|
if (
|
|
805
811
|
action &&
|
|
806
812
|
["kicked", "banned", "left"].includes(action) &&
|
|
807
813
|
actionOn &&
|
|
808
|
-
actionOn.getUid()
|
|
814
|
+
actionOn.getUid() === loggedInUser.current?.getUid()
|
|
809
815
|
) {
|
|
810
|
-
conversationListRef.current
|
|
816
|
+
conversationListRef.current.removeItemFromList(message.getConversationId());
|
|
811
817
|
return;
|
|
812
818
|
} else {
|
|
813
819
|
if (!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnGroupActions()) {
|
|
814
820
|
return;
|
|
815
821
|
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
+
|
|
823
|
+
// Helper to apply group action updates to a conversation
|
|
824
|
+
const applyGroupUpdate = (conv: CometChat.Conversation, unreadCount?: number) => {
|
|
825
|
+
conv.setLastMessage(message);
|
|
826
|
+
if (group) {
|
|
827
|
+
const currentScope = (conv.getConversationWith() as CometChat.Group).getScope();
|
|
828
|
+
const resolvedScope = newScope ?? oldScope ?? currentScope;
|
|
829
|
+
if (!group.getScope()) {
|
|
830
|
+
group.setScope(resolvedScope);
|
|
831
|
+
}
|
|
832
|
+
conv.setConversationWith(group);
|
|
833
|
+
}
|
|
834
|
+
if (unreadCount !== undefined) {
|
|
835
|
+
conv.setUnreadMessageCount(unreadCount);
|
|
836
|
+
}
|
|
837
|
+
conversationListRef.current?.updateList(conv);
|
|
838
|
+
};
|
|
839
|
+
|
|
840
|
+
// Update immediately with incremented unread count for instant UI feedback
|
|
841
|
+
const currentUnread = conversation.getUnreadMessageCount() || 0;
|
|
842
|
+
applyGroupUpdate(conversation, currentUnread + 1);
|
|
822
843
|
}
|
|
823
844
|
} else {
|
|
845
|
+
if (_depth > 0) return; // Already retried once — don't recurse further
|
|
846
|
+
|
|
824
847
|
CometChat.CometChatHelper.getConversationFromMessage(message).then((newConversation) => {
|
|
825
|
-
const
|
|
848
|
+
const existingConv = conversationListRef.current?.getListItem(
|
|
826
849
|
message.getConversationId()
|
|
827
850
|
) as unknown as CometChat.Conversation;
|
|
828
|
-
if (
|
|
829
|
-
groupHandler(message);
|
|
851
|
+
if (existingConv) {
|
|
852
|
+
groupHandler(message, otherDetails, _depth + 1);
|
|
830
853
|
} else {
|
|
831
|
-
conversationListRef.current
|
|
854
|
+
conversationListRef.current?.addItemToList(newConversation, 0);
|
|
832
855
|
}
|
|
856
|
+
}).catch(() => {
|
|
857
|
+
// Silently ignore — conversation won't appear until next refresh
|
|
833
858
|
});
|
|
834
859
|
}
|
|
835
860
|
};
|
|
@@ -887,7 +912,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
887
912
|
* @param id - The conversation ID to remove.
|
|
888
913
|
*/
|
|
889
914
|
const removeConversation = (id: string) => {
|
|
890
|
-
let conversation = conversationListRef.current
|
|
915
|
+
let conversation = conversationListRef.current?.getListItem(id);
|
|
891
916
|
const { conversationWith, conversationType } = conversation;
|
|
892
917
|
let conversationWithId =
|
|
893
918
|
conversationType == "group" ? conversationWith.guid : conversationWith.uid;
|
|
@@ -897,7 +922,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
897
922
|
CometChatConversationEvents.ccConversationDeleted,
|
|
898
923
|
{ conversation: conversation }
|
|
899
924
|
);
|
|
900
|
-
conversationListRef.current
|
|
925
|
+
conversationListRef.current?.removeItemFromList(id);
|
|
901
926
|
removeItemFromSelectionList(id);
|
|
902
927
|
})
|
|
903
928
|
.catch((err) => console.log(err));
|
|
@@ -910,7 +935,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
910
935
|
* @returns A JSX.Element containing the preview.
|
|
911
936
|
*/
|
|
912
937
|
const getMessagePreview = (conversations: CometChat.Conversation, theme?: CometChatTheme) => {
|
|
913
|
-
const loggedInUserId = CometChatUIKit.loggedInUser
|
|
938
|
+
const loggedInUserId = CometChatUIKit.loggedInUser?.getUid() ?? "";
|
|
914
939
|
let lastMessage: CometChat.BaseMessage =
|
|
915
940
|
conversations?.getLastMessage && conversations.getLastMessage();
|
|
916
941
|
if (!lastMessage) return null;
|
|
@@ -1126,7 +1151,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1126
1151
|
|
|
1127
1152
|
if (
|
|
1128
1153
|
lastMessage &&
|
|
1129
|
-
lastMessage.getSender().getUid() == loggedInUser.current
|
|
1154
|
+
lastMessage.getSender().getUid() == loggedInUser.current?.getUid() &&
|
|
1130
1155
|
!lastMessage.getDeletedAt()
|
|
1131
1156
|
) {
|
|
1132
1157
|
const status = MessageReceiptUtils.getReceiptStatus(lastMessage);
|
|
@@ -1223,7 +1248,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1223
1248
|
loggedInUser.current?.getUid()
|
|
1224
1249
|
)
|
|
1225
1250
|
newConversation.setUnreadMessageCount(1);
|
|
1226
|
-
conversationListRef.current
|
|
1251
|
+
conversationListRef.current?.addItemToList(newConversation, 0);
|
|
1227
1252
|
})
|
|
1228
1253
|
.catch((err) => onError && onError(err));
|
|
1229
1254
|
}
|
|
@@ -1258,7 +1283,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1258
1283
|
// Get logged in user.
|
|
1259
1284
|
CometChat.getLoggedinUser()
|
|
1260
1285
|
.then((u) => {
|
|
1261
|
-
loggedInUser.current = u
|
|
1286
|
+
loggedInUser.current = u ?? undefined;
|
|
1262
1287
|
})
|
|
1263
1288
|
.catch((err) => console.log(err));
|
|
1264
1289
|
|
|
@@ -1420,12 +1445,12 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1420
1445
|
// Listen for conversation deletion events.
|
|
1421
1446
|
CometChatUIEventHandler.addConversationListener(conversationListenerId, {
|
|
1422
1447
|
ccConversationDeleted: ({ conversation }: { conversation: CometChat.Conversation }) => {
|
|
1423
|
-
conversationListRef.current
|
|
1448
|
+
conversationListRef.current?.removeItemFromList(conversation.getConversationId());
|
|
1424
1449
|
removeItemFromSelectionList(conversation.getConversationId());
|
|
1425
1450
|
},
|
|
1426
1451
|
// Handle conversation updates from external sources (e.g., when conversation properties change)
|
|
1427
1452
|
ccUpdateConversation: ({ conversation }: { conversation: CometChat.Conversation }) => {
|
|
1428
|
-
conversationListRef.current
|
|
1453
|
+
conversationListRef.current?.updateList(conversation);
|
|
1429
1454
|
},
|
|
1430
1455
|
});
|
|
1431
1456
|
// Listen for message events.
|
|
@@ -1439,6 +1464,17 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1439
1464
|
}
|
|
1440
1465
|
},
|
|
1441
1466
|
ccMessageRead: ({ message }: { message: CometChat.BaseMessage }) => {
|
|
1467
|
+
// When a message is marked as read, clear the unread count for that conversation
|
|
1468
|
+
if (message) {
|
|
1469
|
+
const convId = message.getConversationId?.();
|
|
1470
|
+
if (convId) {
|
|
1471
|
+
let conver: CometChat.Conversation = conversationListRef.current?.getListItem(convId);
|
|
1472
|
+
if (conver) {
|
|
1473
|
+
conver.setUnreadMessageCount(0);
|
|
1474
|
+
conversationListRef.current?.updateList(CommonUtils.clone(conver));
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1442
1478
|
checkAndUpdateLastMessage(message);
|
|
1443
1479
|
},
|
|
1444
1480
|
ccMessageDeleted: ({ message }: { message: CometChat.BaseMessage }) => {
|
|
@@ -1469,6 +1505,8 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1469
1505
|
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
|
|
1470
1506
|
},
|
|
1471
1507
|
onMessageDeleted: (deletedMessage: CometChat.BaseMessage) => {
|
|
1508
|
+
// Skip thread replies — they don't affect conversation unread count
|
|
1509
|
+
if (deletedMessage.getParentMessageId()) return;
|
|
1472
1510
|
checkAndUpdateLastMessage(deletedMessage);
|
|
1473
1511
|
},
|
|
1474
1512
|
onMessageEdited: (editedMessage: CometChat.BaseMessage) => {
|
|
@@ -1658,7 +1696,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1658
1696
|
return;
|
|
1659
1697
|
}
|
|
1660
1698
|
conversation = updateUnreadMessageCount(conversation);
|
|
1661
|
-
conversationListRef.current
|
|
1699
|
+
conversationListRef.current?.updateList(conversation);
|
|
1662
1700
|
})
|
|
1663
1701
|
.catch((e) => {
|
|
1664
1702
|
onError && onError(e);
|
|
@@ -1671,7 +1709,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1671
1709
|
return;
|
|
1672
1710
|
}
|
|
1673
1711
|
conversation = updateUnreadMessageCount(conversation);
|
|
1674
|
-
conversationListRef.current
|
|
1712
|
+
conversationListRef.current?.updateList(conversation);
|
|
1675
1713
|
})
|
|
1676
1714
|
.catch((e) => {
|
|
1677
1715
|
onError && onError(e);
|
|
@@ -1684,7 +1722,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1684
1722
|
return;
|
|
1685
1723
|
}
|
|
1686
1724
|
conversation = updateUnreadMessageCount(conversation);
|
|
1687
|
-
conversationListRef.current
|
|
1725
|
+
conversationListRef.current?.updateList(conversation);
|
|
1688
1726
|
})
|
|
1689
1727
|
.catch((e) => {
|
|
1690
1728
|
onError && onError(e);
|
|
@@ -1697,7 +1735,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1697
1735
|
return;
|
|
1698
1736
|
}
|
|
1699
1737
|
conversation = updateUnreadMessageCount(conversation);
|
|
1700
|
-
conversationListRef.current
|
|
1738
|
+
conversationListRef.current?.updateList(conversation);
|
|
1701
1739
|
})
|
|
1702
1740
|
.catch((e) => {
|
|
1703
1741
|
onError && onError(e);
|