@cometchat/chat-uikit-react-native 5.3.0 → 5.3.2
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/package.json +1 -1
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +47 -2
- package/src/CometChatConversations/CometChatConversations.tsx +2 -4
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +6 -0
- package/src/CometChatMessageList/CometChatMessageList.tsx +71 -29
- package/src/CometChatSearch/CometChatSearch.tsx +27 -26
- package/src/calls/CallUtils.ts +4 -4
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +2 -0
- package/src/shared/events/ListenerInitializer.ts +6 -0
- package/src/shared/events/messages.ts +2 -0
- package/src/shared/utils/CommonUtils.ts +18 -1
- package/src/shared/utils/MessageReceiptUtils.ts +5 -4
- package/src/shared/utils/MessageUtils.tsx +5 -3
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +1 -1
- package/src/shared/views/CometChatList/Header.tsx +2 -1
- package/src/shared/views/CometChatListItem/style.ts +1 -0
package/package.json
CHANGED
|
@@ -3418,11 +3418,56 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
3418
3418
|
const applyInlineStyles = (text: string, styles: any[]): string => {
|
|
3419
3419
|
if (!styles || styles.length === 0 || !text) return text;
|
|
3420
3420
|
|
|
3421
|
+
// Build mention ranges by finding mention promptText within this block's text.
|
|
3422
|
+
// This is more robust than position-based mapping because mentionMap positions
|
|
3423
|
+
// are based on plain text (with list prefixes) while block text has prefixes stripped.
|
|
3424
|
+
const mentionRanges: Array<[number, number]> = [];
|
|
3425
|
+
mentionMap.current.forEach((value, _key) => {
|
|
3426
|
+
const pt = value.promptText || '';
|
|
3427
|
+
if (pt) {
|
|
3428
|
+
let searchFrom = 0;
|
|
3429
|
+
// Find all occurrences of this mention's promptText in the block text
|
|
3430
|
+
while (searchFrom < text.length) {
|
|
3431
|
+
const idx = text.indexOf(pt, searchFrom);
|
|
3432
|
+
if (idx === -1) break;
|
|
3433
|
+
mentionRanges.push([idx, idx + pt.length]);
|
|
3434
|
+
searchFrom = idx + pt.length;
|
|
3435
|
+
}
|
|
3436
|
+
}
|
|
3437
|
+
});
|
|
3438
|
+
|
|
3439
|
+
// Split styles around mention ranges so mentions stay clean.
|
|
3440
|
+
const filteredStyles: any[] = [];
|
|
3441
|
+
for (const s of styles) {
|
|
3442
|
+
if (s.style === 'link' || mentionRanges.length === 0) {
|
|
3443
|
+
filteredStyles.push(s);
|
|
3444
|
+
continue;
|
|
3445
|
+
}
|
|
3446
|
+
const sStart = Math.max(0, s.start);
|
|
3447
|
+
const sEnd = Math.min(text.length, s.end);
|
|
3448
|
+
// Collect non-mention sub-ranges of this style
|
|
3449
|
+
let cursor = sStart;
|
|
3450
|
+
// Sort mention ranges for consistent processing
|
|
3451
|
+
const sorted = [...mentionRanges].sort((a, b) => a[0] - b[0]);
|
|
3452
|
+
for (const [mStart, mEnd] of sorted) {
|
|
3453
|
+
if (mStart >= sEnd || mEnd <= sStart) continue; // no overlap
|
|
3454
|
+
// Add the part before the mention
|
|
3455
|
+
if (cursor < mStart) {
|
|
3456
|
+
filteredStyles.push({ ...s, start: cursor, end: mStart });
|
|
3457
|
+
}
|
|
3458
|
+
cursor = Math.max(cursor, mEnd);
|
|
3459
|
+
}
|
|
3460
|
+
// Add the part after the last mention
|
|
3461
|
+
if (cursor < sEnd) {
|
|
3462
|
+
filteredStyles.push({ ...s, start: cursor, end: sEnd });
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
|
|
3421
3466
|
// Collect all boundary positions where style sets change
|
|
3422
3467
|
const boundaries = new Set<number>();
|
|
3423
3468
|
boundaries.add(0);
|
|
3424
3469
|
boundaries.add(text.length);
|
|
3425
|
-
for (const s of
|
|
3470
|
+
for (const s of filteredStyles) {
|
|
3426
3471
|
boundaries.add(Math.max(0, s.start));
|
|
3427
3472
|
boundaries.add(Math.min(text.length, s.end));
|
|
3428
3473
|
}
|
|
@@ -3440,7 +3485,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
|
|
|
3440
3485
|
|
|
3441
3486
|
const active: string[] = [];
|
|
3442
3487
|
let linkUrl = '';
|
|
3443
|
-
for (const s of
|
|
3488
|
+
for (const s of filteredStyles) {
|
|
3444
3489
|
const sStart = Math.max(0, s.start);
|
|
3445
3490
|
const sEnd = Math.min(text.length, s.end);
|
|
3446
3491
|
if (sStart <= segStart && sEnd >= segEnd) {
|
|
@@ -668,8 +668,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
668
668
|
if (
|
|
669
669
|
conv &&
|
|
670
670
|
conv?.getLastMessage &&
|
|
671
|
-
(conv.getLastMessage().id
|
|
672
|
-
conv.getLastMessage().messageId == receipt.getMessageId())
|
|
671
|
+
(String(typeof conv.getLastMessage().getId === 'function' ? conv.getLastMessage().getId() : conv.getLastMessage().id) === String(receipt.getMessageId()))
|
|
673
672
|
) {
|
|
674
673
|
let newConversation = CommonUtils.clone(conv);
|
|
675
674
|
if (receipt.getReadAt()) {
|
|
@@ -903,7 +902,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
903
902
|
{listPrefix}{messageText}{'...'}
|
|
904
903
|
</Text>
|
|
905
904
|
);
|
|
906
|
-
} else if (messageText) {
|
|
905
|
+
} else if (messageText && typeof messageText === 'string') {
|
|
907
906
|
messageText = (
|
|
908
907
|
<Text
|
|
909
908
|
style={[mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
|
|
@@ -1705,7 +1704,6 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1705
1704
|
|
|
1706
1705
|
return (
|
|
1707
1706
|
<View style={[
|
|
1708
|
-
{ flex: 1 },
|
|
1709
1707
|
isAgentic ? { justifyContent: 'center' } : null
|
|
1710
1708
|
]}>
|
|
1711
1709
|
<Text
|
|
@@ -454,6 +454,8 @@ export const CometChatGroupMembers = (props: CometChatGroupMembersInterface) =>
|
|
|
454
454
|
action.setSender(loggedInUser.current);
|
|
455
455
|
action.setReceiver(group);
|
|
456
456
|
action.setConversationId("group_" + group.getGuid());
|
|
457
|
+
// Initialize data to prevent crash when SDK accesses getData().metadata during render
|
|
458
|
+
action.setData({ metadata: {} });
|
|
457
459
|
|
|
458
460
|
// Emit the group event for a kicked member.
|
|
459
461
|
CometChatUIEventHandler.emitGroupEvent(CometChatGroupsEvents.ccGroupMemberKicked, {
|
|
@@ -496,6 +498,8 @@ export const CometChatGroupMembers = (props: CometChatGroupMembersInterface) =>
|
|
|
496
498
|
action.setMuid(String(getUnixTimestampInMilliseconds()));
|
|
497
499
|
action.setSender(loggedInUser.current);
|
|
498
500
|
action.setReceiver(group);
|
|
501
|
+
// Initialize data to prevent crash when SDK accesses getData().metadata during render
|
|
502
|
+
action.setData({ metadata: {} });
|
|
499
503
|
group.setMembersCount(group.getMembersCount() - 1);
|
|
500
504
|
|
|
501
505
|
// Emit the group event for a banned member.
|
|
@@ -928,6 +932,8 @@ export const CometChatGroupMembers = (props: CometChatGroupMembersInterface) =>
|
|
|
928
932
|
action.setMuid(String(getUnixTimestampInMilliseconds()));
|
|
929
933
|
action.setSender(loggedInUser.current);
|
|
930
934
|
action.setReceiver(group);
|
|
935
|
+
// Initialize data to prevent crash when SDK accesses getData().metadata during render
|
|
936
|
+
action.setData({ metadata: {} });
|
|
931
937
|
|
|
932
938
|
// Emit the group event for a scope change.
|
|
933
939
|
CometChatUIEventHandler.emitGroupEvent(
|
|
@@ -936,11 +936,17 @@ export const CometChatMessageList = memo(
|
|
|
936
936
|
const [itemPositions, setItemPositions] = useState<Map<string, { y: number; height: number }>>(new Map());
|
|
937
937
|
const markUnreadMessageAsRead = (message?: CometChat.BaseMessage) => {
|
|
938
938
|
const messageToMark = message || messagesContentListRef.current[0];
|
|
939
|
-
if (
|
|
939
|
+
if (
|
|
940
|
+
messageToMark &&
|
|
941
|
+
messageToMark.getSender?.()?.getUid() !== loggedInUser.current?.getUid()
|
|
942
|
+
) {
|
|
940
943
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageRead, {
|
|
941
944
|
message: messageToMark,
|
|
942
945
|
});
|
|
943
|
-
CometChat.markAsRead(messageToMark)
|
|
946
|
+
CometChat.markAsRead(messageToMark).catch((error: any) => {
|
|
947
|
+
console.log("Error marking unread message as read", error);
|
|
948
|
+
onError && onError(error);
|
|
949
|
+
});
|
|
944
950
|
setUnreadCount(0);
|
|
945
951
|
}
|
|
946
952
|
};
|
|
@@ -1107,7 +1113,10 @@ export const CometChatMessageList = memo(
|
|
|
1107
1113
|
|
|
1108
1114
|
} else {
|
|
1109
1115
|
for (let index = 0; index < previousMessagesFetched.length; index++) {
|
|
1110
|
-
|
|
1116
|
+
const message=previousMessagesFetched[index];
|
|
1117
|
+
CometChat.markAsRead(message).catch((error: any) => {
|
|
1118
|
+
console.log("Error marking message as read", error);
|
|
1119
|
+
})
|
|
1111
1120
|
if (
|
|
1112
1121
|
message &&
|
|
1113
1122
|
!message.hasOwnProperty("readAt") &&
|
|
@@ -1697,7 +1706,10 @@ export const CometChatMessageList = memo(
|
|
|
1697
1706
|
}, []);
|
|
1698
1707
|
|
|
1699
1708
|
const markMessageAsRead = (message: any) => {
|
|
1700
|
-
if (
|
|
1709
|
+
if (
|
|
1710
|
+
!message?.readAt &&
|
|
1711
|
+
message?.getSender?.()?.getUid() !== loggedInUser.current?.getUid()
|
|
1712
|
+
) {
|
|
1701
1713
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageRead, { message });
|
|
1702
1714
|
CometChat.markAsRead(message).catch((error: any) => {
|
|
1703
1715
|
console.log("Error", error);
|
|
@@ -1952,6 +1964,7 @@ export const CometChatMessageList = memo(
|
|
|
1952
1964
|
addToMessageList(newMessage);
|
|
1953
1965
|
}
|
|
1954
1966
|
scrollToBottom();
|
|
1967
|
+
|
|
1955
1968
|
markMessageAsRead(newMessage);
|
|
1956
1969
|
latestMessageRef.current = newMessage;
|
|
1957
1970
|
} else {
|
|
@@ -2202,9 +2215,13 @@ export const CometChatMessageList = memo(
|
|
|
2202
2215
|
) {
|
|
2203
2216
|
return;
|
|
2204
2217
|
}
|
|
2218
|
+
// Use getter method for messageId (SDK receipt objects expose it via getMessageId())
|
|
2219
|
+
let receiptMessageId = typeof receipt.getMessageId === 'function' ? receipt.getMessageId() : receipt["messageId"];
|
|
2205
2220
|
let index = messagesContentListRef.current.findIndex(
|
|
2206
|
-
(msg
|
|
2207
|
-
msg
|
|
2221
|
+
(msg) => {
|
|
2222
|
+
const msgId = typeof msg.getId === 'function' ? msg.getId() : msg["id"];
|
|
2223
|
+
return String(msgId) === String(receiptMessageId);
|
|
2224
|
+
}
|
|
2208
2225
|
);
|
|
2209
2226
|
|
|
2210
2227
|
if (index == -1) return;
|
|
@@ -2786,15 +2803,16 @@ export const CometChatMessageList = memo(
|
|
|
2786
2803
|
inConnecting: () => { },
|
|
2787
2804
|
onDisconnected: () => {
|
|
2788
2805
|
streamOnDisconnected();
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2806
|
+
const currentMessages = messagesContentListRef.current;
|
|
2807
|
+
if (currentMessages.length > 0 && !currentMessages[0].id) {
|
|
2808
|
+
for (let i = 0; i < currentMessages.length; i++) {
|
|
2809
|
+
if (currentMessages[i].id) {
|
|
2810
|
+
lastID.current = currentMessages[i].id;
|
|
2793
2811
|
break;
|
|
2794
2812
|
}
|
|
2795
2813
|
}
|
|
2796
|
-
} else {
|
|
2797
|
-
lastID.current =
|
|
2814
|
+
} else if (currentMessages.length > 0) {
|
|
2815
|
+
lastID.current = currentMessages[0].id;
|
|
2798
2816
|
}
|
|
2799
2817
|
},
|
|
2800
2818
|
})
|
|
@@ -2816,7 +2834,7 @@ export const CometChatMessageList = memo(
|
|
|
2816
2834
|
}
|
|
2817
2835
|
}
|
|
2818
2836
|
};
|
|
2819
|
-
}, [unreadCount, user, group, isAgenticUser
|
|
2837
|
+
}, [unreadCount, user, group, isAgenticUser]);
|
|
2820
2838
|
|
|
2821
2839
|
useEffect(() => {
|
|
2822
2840
|
if (aiAssistantTools) {
|
|
@@ -2934,7 +2952,7 @@ export const CometChatMessageList = memo(
|
|
|
2934
2952
|
return item.getType();
|
|
2935
2953
|
})();
|
|
2936
2954
|
|
|
2937
|
-
if (item.getSender()
|
|
2955
|
+
if (item.getSender()?.getUid() != loggedInUser.current?.getUid()) {
|
|
2938
2956
|
return (
|
|
2939
2957
|
overridenBubbleStyles.get(type)?.incoming ??
|
|
2940
2958
|
mergedTheme.messageListStyles.incomingMessageBubbleStyles
|
|
@@ -3518,19 +3536,43 @@ export const CometChatMessageList = memo(
|
|
|
3518
3536
|
isThreaded?: boolean;
|
|
3519
3537
|
currentIndex?: number;
|
|
3520
3538
|
}) => {
|
|
3521
|
-
const { message, showOptions = true, isThreaded = false, currentIndex } = params
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3539
|
+
const { message, showOptions = true, isThreaded = false, currentIndex } = params
|
|
3540
|
+
|
|
3541
|
+
const hasTemplate = useMemo(() => {
|
|
3542
|
+
// Detect InteractiveMessage instances where Object.assign
|
|
3543
|
+
// (from mergeObjects during history fetch dedup) overwrote `category` and `type`
|
|
3544
|
+
let lookupCategory: string = message.getCategory();
|
|
3545
|
+
let lookupType: string = message.getType();
|
|
3546
|
+
|
|
3547
|
+
const hasInteractiveData =
|
|
3548
|
+
typeof (message as any).getInteractiveData === 'function' &&
|
|
3549
|
+
(message as any).getInteractiveData() != null;
|
|
3550
|
+
|
|
3551
|
+
if (hasInteractiveData && lookupCategory !== MessageCategoryConstants.interactive) {
|
|
3552
|
+
lookupCategory = MessageCategoryConstants.interactive;
|
|
3553
|
+
const interactiveData = (message as any).getInteractiveData();
|
|
3554
|
+
if (interactiveData?.formFields) {
|
|
3555
|
+
lookupType = MessageTypeConstants.form;
|
|
3556
|
+
} else if (interactiveData?.scheduleElement || interactiveData?.timezoneCode) {
|
|
3557
|
+
lookupType = MessageTypeConstants.scheduler;
|
|
3558
|
+
} else if (interactiveData?.cardActions) {
|
|
3559
|
+
lookupType = MessageTypeConstants.card;
|
|
3560
|
+
}
|
|
3561
|
+
(message as any).category = lookupCategory;
|
|
3562
|
+
(message as any).type = lookupType;
|
|
3563
|
+
}
|
|
3564
|
+
|
|
3565
|
+
const defaultTemplate = templatesMap.get(
|
|
3566
|
+
`${lookupCategory}_${lookupType}`
|
|
3567
|
+
);
|
|
3568
|
+
|
|
3569
|
+
if (templates?.length > 0) {
|
|
3570
|
+
const customTemplate = templates.find(
|
|
3571
|
+
(template) =>
|
|
3572
|
+
template.type === lookupType && template.category === lookupCategory
|
|
3573
|
+
);
|
|
3574
|
+
return customTemplate ?? defaultTemplate;
|
|
3575
|
+
}
|
|
3534
3576
|
|
|
3535
3577
|
return defaultTemplate;
|
|
3536
3578
|
}, [message, templatesMap, templates]);
|
|
@@ -3577,10 +3619,10 @@ export const CometChatMessageList = memo(
|
|
|
3577
3619
|
|
|
3578
3620
|
const BottomView = useMemo(() => {
|
|
3579
3621
|
const moderationStatus = getModerationStatus(message);
|
|
3580
|
-
const isOutgoing = message
|
|
3622
|
+
const isOutgoing = message?.getSender?.()?.getUid() === loggedInUser.current?.getUid();
|
|
3581
3623
|
|
|
3582
3624
|
// Check for MIME type error (ERR_PERMISSION_DENIED)
|
|
3583
|
-
const hasErrorMetadata =
|
|
3625
|
+
const hasErrorMetadata = message?.getData?.()?.metaData?.error;
|
|
3584
3626
|
const hasErrorInMetadata = (message as any)?.getMetadata?.()?.error;
|
|
3585
3627
|
if (isOutgoing && (hasErrorMetadata || hasErrorInMetadata) && !isAgenticUser) {
|
|
3586
3628
|
return (
|
|
@@ -339,34 +339,38 @@ const t = getCometChatTranslation();
|
|
|
339
339
|
|
|
340
340
|
interface LinkPreviewImageProps {
|
|
341
341
|
uri: string;
|
|
342
|
+
fallbackUri?: string;
|
|
342
343
|
mergedStyles: any;
|
|
343
344
|
theme: any;
|
|
344
345
|
}
|
|
345
346
|
|
|
346
|
-
const
|
|
347
|
+
const LinkFallbackIcon = ({ mergedStyles, theme }: { mergedStyles: any; theme: any }) => (
|
|
348
|
+
<View style={mergedStyles.messageItemStyle?.iconContainerStyle}>
|
|
349
|
+
<Icon
|
|
350
|
+
name='link-fill'
|
|
351
|
+
size={48}
|
|
352
|
+
height={48}
|
|
353
|
+
width={48}
|
|
354
|
+
color={theme.color.iconSecondary}
|
|
355
|
+
/>
|
|
356
|
+
</View>
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
const LinkPreviewImage: React.FC<LinkPreviewImageProps> = ({ uri, fallbackUri, mergedStyles, theme }) => {
|
|
347
360
|
const [imageError, setImageError] = useState(false);
|
|
361
|
+
const [fallbackError, setFallbackError] = useState(false);
|
|
348
362
|
|
|
349
|
-
if (imageError) {
|
|
350
|
-
return
|
|
351
|
-
<View style={mergedStyles.messageItemStyle?.iconContainerStyle}>
|
|
352
|
-
<Icon
|
|
353
|
-
name='link-fill'
|
|
354
|
-
size={48}
|
|
355
|
-
height={48}
|
|
356
|
-
width={48}
|
|
357
|
-
color={theme.color.iconSecondary}
|
|
358
|
-
/>
|
|
359
|
-
</View>
|
|
360
|
-
);
|
|
363
|
+
if (imageError && (!fallbackUri || fallbackError)) {
|
|
364
|
+
return <LinkFallbackIcon mergedStyles={mergedStyles} theme={theme} />;
|
|
361
365
|
}
|
|
362
366
|
|
|
363
367
|
return (
|
|
364
368
|
<View style={mergedStyles.messageItemStyle?.iconContainerStyle}>
|
|
365
369
|
<Image
|
|
366
|
-
source={{ uri }}
|
|
370
|
+
source={{ uri: imageError ? fallbackUri! : uri }}
|
|
367
371
|
style={mergedStyles.messageItemStyle?.linkPreviewImageStyle}
|
|
368
372
|
resizeMode="cover"
|
|
369
|
-
onError={() => setImageError(true)}
|
|
373
|
+
onError={() => imageError ? setFallbackError(true) : setImageError(true)}
|
|
370
374
|
/>
|
|
371
375
|
</View>
|
|
372
376
|
);
|
|
@@ -1481,25 +1485,22 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
1481
1485
|
return (
|
|
1482
1486
|
<LinkPreviewImage
|
|
1483
1487
|
uri={thumbnailUrl}
|
|
1488
|
+
fallbackUri={firstLink.favicon !== thumbnailUrl ? firstLink.favicon : undefined}
|
|
1484
1489
|
mergedStyles={mergedStyles}
|
|
1485
1490
|
theme={theme}
|
|
1486
1491
|
/>
|
|
1487
1492
|
);
|
|
1488
1493
|
} else {
|
|
1489
1494
|
// Fallback to link icon if no thumbnail
|
|
1490
|
-
return
|
|
1491
|
-
<View style={mergedStyles.messageItemStyle?.iconContainerStyle}>
|
|
1492
|
-
<Icon
|
|
1493
|
-
name='link-fill'
|
|
1494
|
-
size={48}
|
|
1495
|
-
height={48}
|
|
1496
|
-
width={48}
|
|
1497
|
-
color={theme.color.iconSecondary}
|
|
1498
|
-
/>
|
|
1499
|
-
</View>
|
|
1500
|
-
);
|
|
1495
|
+
return <LinkFallbackIcon mergedStyles={mergedStyles} theme={theme} />;
|
|
1501
1496
|
}
|
|
1502
1497
|
}
|
|
1498
|
+
|
|
1499
|
+
// Show link icon for text messages in Links filter that lack preview metadata
|
|
1500
|
+
if (searchState.activeFilters.includes(CometChatSearchFilter.Links)) {
|
|
1501
|
+
return <LinkFallbackIcon mergedStyles={mergedStyles} theme={theme} />;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1503
1504
|
return null;
|
|
1504
1505
|
}
|
|
1505
1506
|
|
package/src/calls/CallUtils.ts
CHANGED
|
@@ -85,8 +85,8 @@ export class CallUtils {
|
|
|
85
85
|
callMessageText = `${t("CALL_REJECTED")}`;
|
|
86
86
|
selectedIcon = call["type"] === "audio" ? "call" : "video-call";
|
|
87
87
|
} else {
|
|
88
|
-
callMessageText = `${t("
|
|
89
|
-
|
|
88
|
+
callMessageText = `${t("CALL_REJECTED")}`;
|
|
89
|
+
selectedIcon = call["type"] === "audio" ? "call" : "video-call";
|
|
90
90
|
}
|
|
91
91
|
break;
|
|
92
92
|
case CALL_BUSY:
|
|
@@ -124,8 +124,8 @@ export class CallUtils {
|
|
|
124
124
|
return callStatus === CALL_UNANSWERED;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
// Incoming calls: treat BUSY as missed as well
|
|
128
|
-
return [CALL_UNANSWERED, CALL_CANCELLED, CALL_BUSY].includes(callStatus);
|
|
127
|
+
// Incoming calls: treat BUSY and REJECTED as missed as well
|
|
128
|
+
return [CALL_UNANSWERED, CALL_CANCELLED, CALL_BUSY, CALL_REJECTED].includes(callStatus);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/**
|
|
@@ -199,6 +199,8 @@ export class CometChatUIKit {
|
|
|
199
199
|
}
|
|
200
200
|
if (authToken) {
|
|
201
201
|
let user = await CometChat.login(authToken).catch((e) => Promise.reject(e));
|
|
202
|
+
CometChatUIKit.setLoggedInUser(user);
|
|
203
|
+
CometChatUIKit.setConversationUpdateSettings(await CometChat.getConversationUpdateSettings());
|
|
202
204
|
this.enableExtensions();
|
|
203
205
|
return user;
|
|
204
206
|
}
|
|
@@ -90,6 +90,12 @@ export class ListenerInitializer {
|
|
|
90
90
|
},
|
|
91
91
|
onMessageModerated: (message: CometChat.BaseMessage) => {
|
|
92
92
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessageModerated, message);
|
|
93
|
+
},
|
|
94
|
+
onMessagesDeliveredToAll: (messageReceipt: CometChat.MessageReceipt) => {
|
|
95
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessagesDeliveredToAll, messageReceipt);
|
|
96
|
+
},
|
|
97
|
+
onMessagesReadByAll: (messageReceipt: CometChat.MessageReceipt) => {
|
|
98
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessagesReadByAll, messageReceipt);
|
|
93
99
|
}
|
|
94
100
|
});
|
|
95
101
|
}
|
|
@@ -26,4 +26,6 @@ export enum MessageEvents {
|
|
|
26
26
|
onMessageReactionRemoved = "onMessageReactionRemoved",
|
|
27
27
|
onMessageModerated = "onMessageModerated",
|
|
28
28
|
onAIAssistantMessageReceived = "onAIAssistantMessageReceived",
|
|
29
|
+
onMessagesDeliveredToAll = "onMessagesDeliveredToAll",
|
|
30
|
+
onMessagesReadByAll = "onMessagesReadByAll",
|
|
29
31
|
}
|
|
@@ -54,7 +54,24 @@ export class CommonUtils {
|
|
|
54
54
|
// Copy properties from obj2 to the new instance
|
|
55
55
|
Object.assign(merged, obj2);
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
// Preserve SDK message class identity after merge.
|
|
58
|
+
// When obj2 is a raw JSON object from the REST API history fetch,
|
|
59
|
+
// it contains flat `category` and `type` own properties (e.g. "message"/"text")
|
|
60
|
+
const protectedProps = ['category', 'type'];
|
|
61
|
+
for (const prop of protectedProps) {
|
|
62
|
+
const getterName = `get${prop.charAt(0).toUpperCase() + prop.slice(1)}`;
|
|
63
|
+
if (
|
|
64
|
+
typeof (obj1 as any)[getterName] === 'function' &&
|
|
65
|
+
typeof (obj2 as any)[getterName] !== 'function'
|
|
66
|
+
) {
|
|
67
|
+
const correctValue = (obj1 as any)[getterName]();
|
|
68
|
+
if (correctValue !== undefined && (merged as any)[prop] !== correctValue) {
|
|
69
|
+
(merged as any)[prop] = correctValue;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return merged;
|
|
58
75
|
}
|
|
59
76
|
|
|
60
77
|
/**
|
|
@@ -19,11 +19,12 @@ export const MessageReceiptUtils = {
|
|
|
19
19
|
if (hasError) return MessageReceipt.ERROR;
|
|
20
20
|
|
|
21
21
|
// Deleted messages treated as error for receipts
|
|
22
|
-
if (
|
|
22
|
+
if (message.getDeletedAt?.()) return MessageReceipt.ERROR;
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
if (
|
|
24
|
+
// Use getter methods for receipt state (SDK objects expose these via getters)
|
|
25
|
+
if (message.getReadAt?.()) return MessageReceipt.READ;
|
|
26
|
+
if (message.getDeliveredAt?.()) return MessageReceipt.DELIVERED;
|
|
27
|
+
if (message.getSentAt?.()) return MessageReceipt.SENT;
|
|
27
28
|
|
|
28
29
|
return MessageReceipt.WAIT;
|
|
29
30
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
2
|
import React, { JSX } from "react";
|
|
3
|
-
import { ColorValue, Text, View } from "react-native";
|
|
3
|
+
import { ColorValue, PixelRatio, Text, View } from "react-native";
|
|
4
4
|
import { MessageBubbleAlignmentType } from "../base";
|
|
5
5
|
import {
|
|
6
6
|
CometChatCustomMessageTypes,
|
|
@@ -174,7 +174,7 @@ const getHeaderView = (
|
|
|
174
174
|
) {
|
|
175
175
|
const senderName = (item.getSender()?.getName() || "").trim();
|
|
176
176
|
return (
|
|
177
|
-
<View style={{
|
|
177
|
+
<View style={{flexDirection: "row" }}>
|
|
178
178
|
{Boolean(senderName) && (
|
|
179
179
|
<Text style={_style.senderNameTextStyles} numberOfLines={1} ellipsizeMode={"tail"}>
|
|
180
180
|
{senderName}
|
|
@@ -349,12 +349,14 @@ export const getMessagePreviewInternal = (
|
|
|
349
349
|
text: string,
|
|
350
350
|
{ iconColor, theme }: { iconColor?: ColorValue; theme?: CometChatTheme }
|
|
351
351
|
) => {
|
|
352
|
+
const fontScale = PixelRatio.getFontScale();
|
|
353
|
+
const iconSize = (theme?.spacing?.spacing?.s4 ?? 16) * fontScale;
|
|
352
354
|
return (
|
|
353
355
|
<>
|
|
354
356
|
{iconName && (
|
|
355
357
|
<Icon
|
|
356
358
|
name={iconName}
|
|
357
|
-
size={
|
|
359
|
+
size={iconSize}
|
|
358
360
|
color={iconColor || theme?.color?.textSecondary}
|
|
359
361
|
containerStyle={{ marginRight: theme?.spacing?.spacing?.s0_5 }}
|
|
360
362
|
/>
|
|
@@ -199,7 +199,7 @@ export const CometChatAudioBubble = ({
|
|
|
199
199
|
|
|
200
200
|
const displayDuration = useCallback(
|
|
201
201
|
() => (
|
|
202
|
-
<Text style={playProgressTextStyle}>
|
|
202
|
+
<Text allowFontScaling={false} style={playProgressTextStyle}>
|
|
203
203
|
{`${String(Math.floor((currentTime || 0) / 60)).padStart(2, "0")}:${String(
|
|
204
204
|
Math.floor((currentTime || 0) % 60)
|
|
205
205
|
).padStart(2, "0")}`}
|
|
@@ -292,7 +292,7 @@ export default function Header({
|
|
|
292
292
|
flexDirection: 'row' as const,
|
|
293
293
|
alignItems: 'center' as const,
|
|
294
294
|
gap: theme.spacing.spacing.s2,
|
|
295
|
-
|
|
295
|
+
minHeight: 48,
|
|
296
296
|
alignSelf: 'stretch',
|
|
297
297
|
},
|
|
298
298
|
searchStyle?.containerStyle,
|
|
@@ -323,6 +323,7 @@ export default function Header({
|
|
|
323
323
|
}}
|
|
324
324
|
submitBehavior='submit'
|
|
325
325
|
numberOfLines={1}
|
|
326
|
+
allowFontScaling={false}
|
|
326
327
|
style={[
|
|
327
328
|
{
|
|
328
329
|
flex: 1,
|