@cometchat/chat-uikit-react-native 5.3.6 → 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 +1 -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/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/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/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/provider.tsx +12 -12
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import {
|
|
3
|
-
ColorValue,
|
|
4
3
|
ImageSourcePropType,
|
|
5
4
|
Modal,
|
|
6
5
|
Platform,
|
|
@@ -232,7 +231,7 @@ export const CometChatGroupMembers = (props: CometChatGroupMembersInterface) =>
|
|
|
232
231
|
hideError,
|
|
233
232
|
onBack,
|
|
234
233
|
selectionMode = "none",
|
|
235
|
-
style
|
|
234
|
+
style,
|
|
236
235
|
TrailingView,
|
|
237
236
|
LeadingView,
|
|
238
237
|
onEmpty,
|
|
@@ -254,7 +253,7 @@ export const CometChatGroupMembers = (props: CometChatGroupMembersInterface) =>
|
|
|
254
253
|
|
|
255
254
|
// Get theme information and merge with provided style overrides.
|
|
256
255
|
const theme = useTheme();
|
|
257
|
-
const mergedStyle = deepMerge(theme.groupMemberStyle, style);
|
|
256
|
+
const mergedStyle = useMemo(() => deepMerge(theme.groupMemberStyle, style ?? {}), [theme, style]);
|
|
258
257
|
|
|
259
258
|
// State management for UI elements
|
|
260
259
|
const [hideSearchError, setHideSearchError] = useState(false);
|
|
@@ -268,7 +267,7 @@ export const CometChatGroupMembers = (props: CometChatGroupMembersInterface) =>
|
|
|
268
267
|
const [currentUserRole, setCurrentUserRole] = useState<string | null>(null);
|
|
269
268
|
const listRef = useRef<any>(null);
|
|
270
269
|
const [isToolTipDismissed, setIsToolTipDismissed] = useState(false);
|
|
271
|
-
const loggedInUser = React.useRef(CometChatUIKit.loggedInUser
|
|
270
|
+
const loggedInUser = React.useRef(CometChatUIKit.loggedInUser);
|
|
272
271
|
|
|
273
272
|
// Derived: whether selected scope equals current user scope
|
|
274
273
|
const isScopeUnchanged = React.useMemo(() => {
|
|
@@ -302,7 +301,7 @@ export const CometChatGroupMembers = (props: CometChatGroupMembersInterface) =>
|
|
|
302
301
|
|
|
303
302
|
// Set current user role based on whether the logged in user is the owner or not.
|
|
304
303
|
useEffect(() => {
|
|
305
|
-
if (CometChatUIKit.loggedInUser
|
|
304
|
+
if (CometChatUIKit.loggedInUser?.getUid() === group.getOwner()) {
|
|
306
305
|
setCurrentUserRole("owner");
|
|
307
306
|
} else {
|
|
308
307
|
setCurrentUserRole(group.getScope());
|
|
@@ -448,7 +447,7 @@ export const CometChatGroupMembers = (props: CometChatGroupMembersInterface) =>
|
|
|
448
447
|
action.setActionBy(loggedInUser.current);
|
|
449
448
|
action.setActionOn(user);
|
|
450
449
|
action.setActionFor(group);
|
|
451
|
-
action.setMessage(`${loggedInUser.current
|
|
450
|
+
action.setMessage(`${loggedInUser.current?.getName()} kicked ${user.getName()}`);
|
|
452
451
|
action.setSentAt(getUnixTimestamp());
|
|
453
452
|
action.setMuid(String(getUnixTimestampInMilliseconds()));
|
|
454
453
|
action.setSender(loggedInUser.current);
|
|
@@ -493,7 +492,7 @@ export const CometChatGroupMembers = (props: CometChatGroupMembersInterface) =>
|
|
|
493
492
|
action.setActionBy(loggedInUser.current);
|
|
494
493
|
action.setActionOn(user);
|
|
495
494
|
action.setActionFor(group);
|
|
496
|
-
action.setMessage(`${loggedInUser.current
|
|
495
|
+
action.setMessage(`${loggedInUser.current?.getName()} banned ${user.getName()}`);
|
|
497
496
|
action.setSentAt(getUnixTimestamp());
|
|
498
497
|
action.setMuid(String(getUnixTimestampInMilliseconds()));
|
|
499
498
|
action.setSender(loggedInUser.current);
|
|
@@ -698,7 +697,7 @@ export const CometChatGroupMembers = (props: CometChatGroupMembersInterface) =>
|
|
|
698
697
|
}
|
|
699
698
|
|
|
700
699
|
// Only open if user is not self
|
|
701
|
-
if (member.uid === CometChatUIKit.loggedInUser
|
|
700
|
+
if (member.uid === CometChatUIKit.loggedInUser?.getUid()) {
|
|
702
701
|
return;
|
|
703
702
|
}
|
|
704
703
|
|
|
@@ -722,7 +721,7 @@ export const CometChatGroupMembers = (props: CometChatGroupMembersInterface) =>
|
|
|
722
721
|
}
|
|
723
722
|
}}
|
|
724
723
|
onListFetched={(fetchedList: CometChat.GroupMember[]) => {
|
|
725
|
-
const selfUid = loggedInUser.current
|
|
724
|
+
const selfUid = loggedInUser.current?.getUid();
|
|
726
725
|
let finalList = fetchedList;
|
|
727
726
|
if (excludeOwner) {
|
|
728
727
|
finalList = fetchedList.filter((m) => m.getUid() !== selfUid);
|
|
@@ -926,7 +925,7 @@ export const CometChatGroupMembers = (props: CometChatGroupMembersInterface) =>
|
|
|
926
925
|
action.setActionOn(selectedItem);
|
|
927
926
|
action.setActionFor(group);
|
|
928
927
|
action.setMessage(
|
|
929
|
-
`${loggedInUser.current
|
|
928
|
+
`${loggedInUser.current?.getName()} made ${selectedItem.getName()} ${scopeToSet} `
|
|
930
929
|
);
|
|
931
930
|
action.setSentAt(getUnixTimestamp());
|
|
932
931
|
action.setMuid(String(getUnixTimestampInMilliseconds()));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
let __listenerIdCounter = 0;
|
|
1
2
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
|
-
import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
3
|
+
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
4
|
import { ImageSourcePropType, Text, View } from "react-native";
|
|
4
5
|
import { CometChatList, CometChatListActionsInterface, CometChatRetryButton } from "../shared";
|
|
5
6
|
import { SelectionMode } from "../shared/base/Types";
|
|
@@ -21,8 +22,8 @@ import { JSX } from "react";
|
|
|
21
22
|
import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
|
|
22
23
|
|
|
23
24
|
// Unique listener IDs for group events and UI events.
|
|
24
|
-
const groupListenerId = "grouplist_" +
|
|
25
|
-
const uiEventListener = "uiEvents_" +
|
|
25
|
+
const groupListenerId = "grouplist_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
26
|
+
const uiEventListener = "uiEvents_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Props for the CometChatGroups component.
|
|
@@ -228,8 +229,8 @@ export const CometChatGroups = React.forwardRef((props: CometChatGroupsInterface
|
|
|
228
229
|
const [selectedGroup, setSelectedGroup] = useState<CometChat.Group | null>(null);
|
|
229
230
|
const tooltipPosition = useRef({ pageX: 0, pageY: 0 });
|
|
230
231
|
|
|
231
|
-
// Merge theme styles with any overrides.
|
|
232
|
-
const mergedStyle = deepMerge(theme.groupStyles, style);
|
|
232
|
+
// Merge theme styles with any overrides — memoized to avoid deepMerge on every render.
|
|
233
|
+
const mergedStyle = useMemo(() => deepMerge(theme.groupStyles, style), [theme, style]);
|
|
233
234
|
|
|
234
235
|
/**
|
|
235
236
|
* Expose imperative methods via ref.
|
|
@@ -329,7 +330,7 @@ export const CometChatGroups = React.forwardRef((props: CometChatGroupsInterface
|
|
|
329
330
|
* - If `options` is provided, it overrides everything.
|
|
330
331
|
* - Otherwise, if `addOptions` is provided, it returns those items only as no default as of now
|
|
331
332
|
*/
|
|
332
|
-
const buildMenuItems = (group: CometChat.Group): MenuItemInterface[] => {
|
|
333
|
+
const buildMenuItems = useCallback((group: CometChat.Group): MenuItemInterface[] => {
|
|
333
334
|
if (options) {
|
|
334
335
|
return options(group);
|
|
335
336
|
}
|
|
@@ -338,14 +339,14 @@ export const CometChatGroups = React.forwardRef((props: CometChatGroupsInterface
|
|
|
338
339
|
}
|
|
339
340
|
// No default menu items, so return empty if no user-defined items.
|
|
340
341
|
return [];
|
|
341
|
-
};
|
|
342
|
+
}, [options, addOptions]);
|
|
342
343
|
|
|
343
344
|
/**
|
|
344
345
|
* Invoked when a group item is long pressed.
|
|
345
346
|
* If the developer passed `onItemLongPress`, call that and stop.
|
|
346
347
|
* Otherwise, show the tooltip if there are any menu items for that group.
|
|
347
348
|
*/
|
|
348
|
-
const handleItemLongPress = (group: CometChat.Group, e?: any) => {
|
|
349
|
+
const handleItemLongPress = useCallback((group: CometChat.Group, e?: any) => {
|
|
349
350
|
// Call developer callback if provided
|
|
350
351
|
if (onItemLongPress) {
|
|
351
352
|
onItemLongPress(group);
|
|
@@ -370,20 +371,20 @@ export const CometChatGroups = React.forwardRef((props: CometChatGroupsInterface
|
|
|
370
371
|
// Show tooltip
|
|
371
372
|
setSelectedGroup(group);
|
|
372
373
|
setTooltipVisible(true);
|
|
373
|
-
};
|
|
374
|
+
}, [onItemLongPress, buildMenuItems]);
|
|
374
375
|
|
|
375
376
|
/**
|
|
376
377
|
* Methods below let you update/manipulate groups in the list.
|
|
377
378
|
*/
|
|
378
379
|
const addGroup = (group: CometChat.Group) => {
|
|
379
|
-
groupListRef.current
|
|
380
|
+
groupListRef.current?.addItemToList(
|
|
380
381
|
(grp: CometChat.Group) => grp.getGuid() === group.getGuid(),
|
|
381
382
|
0
|
|
382
383
|
);
|
|
383
384
|
};
|
|
384
385
|
|
|
385
386
|
const updateGroup = (group: CometChat.Group) => {
|
|
386
|
-
groupListRef.current
|
|
387
|
+
groupListRef.current?.updateList((grp: CometChat.Group) => grp.getGuid() === group.getGuid());
|
|
387
388
|
};
|
|
388
389
|
|
|
389
390
|
const removeGroup = (group: CometChat.Group) => {
|
|
@@ -395,22 +396,22 @@ export const CometChatGroups = React.forwardRef((props: CometChatGroupsInterface
|
|
|
395
396
|
*/
|
|
396
397
|
const handleGroupMemberRemoval = (...options: any) => {
|
|
397
398
|
const group = options[3];
|
|
398
|
-
groupListRef.current
|
|
399
|
+
groupListRef.current?.updateList(group);
|
|
399
400
|
};
|
|
400
401
|
|
|
401
402
|
const handleGroupMemberBan = (...options: any) => {
|
|
402
403
|
const group = options[3];
|
|
403
|
-
groupListRef.current
|
|
404
|
+
groupListRef.current?.updateList(group);
|
|
404
405
|
};
|
|
405
406
|
|
|
406
407
|
const handleGroupMemberAddition = (...options: any) => {
|
|
407
408
|
const group = options[3];
|
|
408
|
-
groupListRef.current
|
|
409
|
+
groupListRef.current?.updateList(group);
|
|
409
410
|
};
|
|
410
411
|
|
|
411
412
|
const handleGroupMemberScopeChange = (...options: any) => {
|
|
412
413
|
const group = options[4];
|
|
413
|
-
groupListRef.current
|
|
414
|
+
groupListRef.current?.updateList(group);
|
|
414
415
|
};
|
|
415
416
|
|
|
416
417
|
/**
|
|
@@ -513,28 +514,43 @@ export const CometChatGroups = React.forwardRef((props: CometChatGroupsInterface
|
|
|
513
514
|
};
|
|
514
515
|
}, []);
|
|
515
516
|
|
|
517
|
+
// Stable default SubtitleView — avoids inline lambda in render
|
|
518
|
+
const DefaultSubtitleView = useCallback((group: CometChat.Group) => (
|
|
519
|
+
<Text
|
|
520
|
+
style={[
|
|
521
|
+
style.itemStyle?.subtitleStyle,
|
|
522
|
+
theme.groupStyles.itemStyle?.subtitleStyle,
|
|
523
|
+
]}
|
|
524
|
+
>
|
|
525
|
+
{group.getMembersCount() +
|
|
526
|
+
" " +
|
|
527
|
+
t(group.getMembersCount() === 1 ? "MEMBER" : "MEMBERS")}
|
|
528
|
+
</Text>
|
|
529
|
+
), [style, theme, t]);
|
|
530
|
+
|
|
531
|
+
// Stable onListFetched callback
|
|
532
|
+
const handleListFetched = useCallback((fetchedList: CometChat.GroupMember[]) => {
|
|
533
|
+
if (fetchedList.length === 0) {
|
|
534
|
+
onEmpty?.();
|
|
535
|
+
} else {
|
|
536
|
+
onLoad?.(fetchedList);
|
|
537
|
+
}
|
|
538
|
+
}, [onEmpty, onLoad]);
|
|
539
|
+
|
|
540
|
+
// Stable request builder — avoids creating new instance every render
|
|
541
|
+
const defaultRequestBuilder = useMemo(
|
|
542
|
+
() => (groupsRequestBuilder && groupsRequestBuilder.setSearchKeyword(searchKeyword)) ||
|
|
543
|
+
new CometChat.GroupsRequestBuilder().setLimit(30).setSearchKeyword(searchKeyword),
|
|
544
|
+
[groupsRequestBuilder, searchKeyword]
|
|
545
|
+
);
|
|
546
|
+
|
|
516
547
|
return (
|
|
517
548
|
<View style={[Style.container, theme.groupStyles.containerStyle]}>
|
|
518
549
|
<CometChatList
|
|
519
550
|
hideHeader={hideHeader ?? hideHeader}
|
|
520
551
|
onItemPress={onItemPress}
|
|
521
552
|
onItemLongPress={handleItemLongPress}
|
|
522
|
-
SubtitleView={
|
|
523
|
-
SubtitleView
|
|
524
|
-
? SubtitleView
|
|
525
|
-
: (group: CometChat.Group) => (
|
|
526
|
-
<Text
|
|
527
|
-
style={[
|
|
528
|
-
style.itemStyle?.subtitleStyle,
|
|
529
|
-
theme.groupStyles.itemStyle?.subtitleStyle,
|
|
530
|
-
]}
|
|
531
|
-
>
|
|
532
|
-
{group.getMembersCount() +
|
|
533
|
-
" " +
|
|
534
|
-
t(group.getMembersCount() === 1 ? "MEMBER" : "MEMBERS")}
|
|
535
|
-
</Text>
|
|
536
|
-
)
|
|
537
|
-
}
|
|
553
|
+
SubtitleView={SubtitleView ? SubtitleView : DefaultSubtitleView}
|
|
538
554
|
statusIndicatorType={(group: CometChat.Group) =>
|
|
539
555
|
!groupTypeVisibility
|
|
540
556
|
? null
|
|
@@ -555,10 +571,7 @@ export const CometChatGroups = React.forwardRef((props: CometChatGroupsInterface
|
|
|
555
571
|
searchPlaceholderText={searchPlaceholderText}
|
|
556
572
|
ref={groupListRef}
|
|
557
573
|
listItemKey='guid'
|
|
558
|
-
requestBuilder={
|
|
559
|
-
(groupsRequestBuilder && groupsRequestBuilder.setSearchKeyword(searchKeyword)) ||
|
|
560
|
-
new CometChat.GroupsRequestBuilder().setLimit(30).setSearchKeyword(searchKeyword)
|
|
561
|
-
}
|
|
574
|
+
requestBuilder={defaultRequestBuilder}
|
|
562
575
|
searchRequestBuilder={searchRequestBuilder}
|
|
563
576
|
AppBarOptions={AppBarOptions}
|
|
564
577
|
hideBackButton={!showBackButton}
|
|
@@ -568,13 +581,7 @@ export const CometChatGroups = React.forwardRef((props: CometChatGroupsInterface
|
|
|
568
581
|
ItemView={ItemView}
|
|
569
582
|
onError={onError}
|
|
570
583
|
hideError={hideError}
|
|
571
|
-
onListFetched={
|
|
572
|
-
if (fetchedList.length === 0) {
|
|
573
|
-
onEmpty?.();
|
|
574
|
-
} else {
|
|
575
|
-
onLoad?.(fetchedList);
|
|
576
|
-
}
|
|
577
|
-
}}
|
|
584
|
+
onListFetched={handleListFetched}
|
|
578
585
|
onBack={onBack}
|
|
579
586
|
{...newProps}
|
|
580
587
|
/>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
let __listenerIdCounter = 0;
|
|
1
2
|
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
2
3
|
import { Keyboard } from "react-native";
|
|
3
4
|
import {
|
|
@@ -74,8 +75,8 @@ type MentionOverlap = {
|
|
|
74
75
|
|
|
75
76
|
const { FileManager, CommonUtil } = NativeModules;
|
|
76
77
|
|
|
77
|
-
const uiEventListenerShow = "uiEvent_show_" +
|
|
78
|
-
const uiEventListenerHide = "uiEvent_hide_" +
|
|
78
|
+
const uiEventListenerShow = "uiEvent_show_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
79
|
+
const uiEventListenerHide = "uiEvent_hide_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
|
|
@@ -453,9 +454,9 @@ export interface CometChatMessageComposerInterface {
|
|
|
453
454
|
|
|
454
455
|
export const CometChatMessageComposer = React.forwardRef(
|
|
455
456
|
(props: CometChatMessageComposerInterface, ref) => {
|
|
456
|
-
const editMessageListenerID = "editMessageListener_" +
|
|
457
|
-
const replyMessageListenerID = "replyMessageListener_" +
|
|
458
|
-
const UiEventListenerID = "UiEventListener_" +
|
|
457
|
+
const editMessageListenerID = "editMessageListener_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
458
|
+
const replyMessageListenerID = "replyMessageListener_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
459
|
+
const UiEventListenerID = "UiEventListener_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
459
460
|
|
|
460
461
|
const theme = useTheme();
|
|
461
462
|
const {t} = useCometChatTranslation()
|
|
@@ -1410,7 +1411,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1410
1411
|
|
|
1411
1412
|
if (!disableMentions) {
|
|
1412
1413
|
let mentionsFormatter = ChatConfigurator.getDataSource().getMentionsFormatter();
|
|
1413
|
-
mentionsFormatter.setLoggedInUser(CometChatUIKit.loggedInUser
|
|
1414
|
+
mentionsFormatter.setLoggedInUser(CometChatUIKit.loggedInUser);
|
|
1414
1415
|
mentionsFormatter.setContext("composer");
|
|
1415
1416
|
mentionsFormatter.setMentionsStyle(
|
|
1416
1417
|
mergedComposerStyle.mentionsStyle as CometChatTheme["mentionsStyle"]
|
|
@@ -1663,9 +1664,11 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1663
1664
|
};
|
|
1664
1665
|
}, []);
|
|
1665
1666
|
|
|
1667
|
+
const buildRecordedAudioFileName = (recordedFile: string): string => ((recordedFile || "").split(/[?#]/)[0]?.split("/").pop() || `audio-recording-${Date.now()}.m4a`).replace(/^audio-merged/, "audio-recording");
|
|
1668
|
+
|
|
1666
1669
|
const _sendRecordedAudio = (recordedFile: String) => {
|
|
1667
1670
|
let fileObj = {
|
|
1668
|
-
name:
|
|
1671
|
+
name: buildRecordedAudioFileName(String(recordedFile)),
|
|
1669
1672
|
type: "audio/mp4",
|
|
1670
1673
|
uri: recordedFile,
|
|
1671
1674
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
let __listenerIdCounter = 0;
|
|
1
2
|
import React, { JSX, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
3
|
import { Text, TouchableOpacity, View } from "react-native";
|
|
3
4
|
import { ChatConfigurator, getLastSeenTime } from "../shared";
|
|
@@ -17,6 +18,7 @@ import { DeepPartial } from "../shared/helper/types";
|
|
|
17
18
|
import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
|
|
18
19
|
import { CometChatAIAssistantChatHistory } from "../CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory";
|
|
19
20
|
import { CometChatTooltipMenu, MenuItemInterface } from "../shared/views/CometChatTooltipMenu";
|
|
21
|
+
import { skipNextAgentAutoLoad } from "../CometChatMessageList/CometChatMessageList";
|
|
20
22
|
|
|
21
23
|
export type CometChatMessageHeaderInterface = {
|
|
22
24
|
/**
|
|
@@ -133,9 +135,9 @@ interface Translations {
|
|
|
133
135
|
|
|
134
136
|
/** CometChatMessageHeader renders the header for a conversation. */
|
|
135
137
|
export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) => {
|
|
136
|
-
const userStatusListenerId = "user_status_" +
|
|
137
|
-
const msgTypingListenerId = "message_typing_" +
|
|
138
|
-
const groupListenerId = "head_group_" +
|
|
138
|
+
const userStatusListenerId = "user_status_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
139
|
+
const msgTypingListenerId = "message_typing_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
140
|
+
const groupListenerId = "head_group_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
139
141
|
const theme = useTheme();
|
|
140
142
|
const { t } = useCometChatTranslation();
|
|
141
143
|
|
|
@@ -166,7 +168,6 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
166
168
|
const [userObj, setUserObj] = useState<CometChat.User | undefined>(user);
|
|
167
169
|
const [userStatus, setUserStatus] = useState(user && user.getStatus ? user.getStatus() : "");
|
|
168
170
|
const [typingText, setTypingText] = useState("");
|
|
169
|
-
const [showHistoryModal, setShowHistoryModal] = useState(false);
|
|
170
171
|
const [showOptionsMenu, setShowOptionsMenu] = useState(false);
|
|
171
172
|
const [tooltipPosition, setTooltipPosition] = useState({ pageX: 0, pageY: 0 });
|
|
172
173
|
const receiverTypeRef = useRef(
|
|
@@ -259,7 +260,7 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
259
260
|
: undefined
|
|
260
261
|
: undefined
|
|
261
262
|
}
|
|
262
|
-
name={
|
|
263
|
+
name={userObj?.getName() ?? groupObj?.getName() ?? ""}
|
|
263
264
|
/>
|
|
264
265
|
</View>
|
|
265
266
|
);
|
|
@@ -287,8 +288,8 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
287
288
|
let subtitle = "";
|
|
288
289
|
|
|
289
290
|
if (groupObj) {
|
|
290
|
-
const count = groupObj?.["membersCount"];
|
|
291
|
-
if (count
|
|
291
|
+
const count = groupObj.getMembersCount?.() ?? groupObj?.["membersCount"];
|
|
292
|
+
if (count != null) {
|
|
292
293
|
subtitle = `${count} ${t(count === 1 ? "MEMBER" : "MEMBERS")}`;
|
|
293
294
|
}
|
|
294
295
|
}
|
|
@@ -348,12 +349,12 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
348
349
|
groupObj?.getGuid() === typist.getReceiverId()
|
|
349
350
|
) {
|
|
350
351
|
setTypingText(
|
|
351
|
-
status === "typing" ? `${typist.getSender()
|
|
352
|
+
status === "typing" ? `${typist.getSender()?.getName()}: ${t("IS_TYPING")}` : ""
|
|
352
353
|
);
|
|
353
354
|
} else if (
|
|
354
355
|
receiverTypeRef.current === CometChat.RECEIVER_TYPE.USER &&
|
|
355
356
|
receiverTypeRef.current === typist.getReceiverType() &&
|
|
356
|
-
userObj?.getUid() === typist.getSender()
|
|
357
|
+
userObj?.getUid() === typist.getSender()?.getUid() &&
|
|
357
358
|
!(userObj.getBlockedByMe() || userObj.getHasBlockedMe())
|
|
358
359
|
) {
|
|
359
360
|
setTypingText(status === "typing" ? t("TYPING") : "");
|
|
@@ -361,7 +362,7 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
361
362
|
};
|
|
362
363
|
|
|
363
364
|
const handleGroupListener = (groupDetails: CometChat.Group) => {
|
|
364
|
-
if (groupDetails?.getGuid() === groupObj?.getGuid() && groupDetails.getMembersCount()) {
|
|
365
|
+
if (groupDetails?.getGuid() === groupObj?.getGuid() && groupDetails.getMembersCount() != null) {
|
|
365
366
|
setGroupObj(CommonUtils.clone(groupDetails));
|
|
366
367
|
}
|
|
367
368
|
};
|
|
@@ -453,6 +454,7 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
453
454
|
const iconSecondary = theme.color.iconSecondary;
|
|
454
455
|
|
|
455
456
|
const handleNewChat = () => {
|
|
457
|
+
skipNextAgentAutoLoad();
|
|
456
458
|
if (onNewChatButtonClick) {
|
|
457
459
|
onNewChatButtonClick();
|
|
458
460
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
let __listenerIdCounter = 0;
|
|
1
2
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
3
|
import React, { JSX, useCallback, useEffect, useMemo, useState } from "react";
|
|
3
4
|
import { FlatList, ScrollView, Text, View } from "react-native";
|
|
@@ -21,7 +22,7 @@ import { deepMerge } from "../shared/helper/helperFunctions";
|
|
|
21
22
|
import { DeepPartial } from "../shared/helper/types";
|
|
22
23
|
import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
|
|
23
24
|
|
|
24
|
-
const listenerId = "uiEvents_" +
|
|
25
|
+
const listenerId = "uiEvents_" + Date.now() + "_" + (++__listenerIdCounter);
|
|
25
26
|
|
|
26
27
|
type Recipient = {
|
|
27
28
|
sender: CometChat.User | CometChat.Group;
|
|
@@ -261,8 +262,8 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
|
|
|
261
262
|
|
|
262
263
|
const receiptIndex = receipts.findIndex((rec) => {
|
|
263
264
|
return (
|
|
264
|
-
(rec as CometChat.MessageReceipt).getSender()
|
|
265
|
-
newReceipt.getSender()
|
|
265
|
+
(rec as CometChat.MessageReceipt).getSender()?.getUid() ===
|
|
266
|
+
newReceipt.getSender()?.getUid()
|
|
266
267
|
);
|
|
267
268
|
});
|
|
268
269
|
|