@cometchat/chat-uikit-react-native 5.2.1 → 5.2.3

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.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/src/CometChatConversations/CometChatConversations.tsx +3 -5
  3. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +9 -5
  4. package/src/CometChatMessageList/CometChatMessageList.tsx +94 -3
  5. package/src/CometChatMessageList/style.ts +43 -0
  6. package/src/calls/CallingExtensionDecorator.tsx +29 -4
  7. package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +21 -12
  8. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +3 -0
  9. package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -0
  10. package/src/shared/events/ListenerInitializer.ts +3 -0
  11. package/src/shared/events/messages.ts +1 -0
  12. package/src/shared/icons/components/message-blocked.tsx +32 -0
  13. package/src/shared/icons/icon-mapping.tsx +3 -1
  14. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +6 -0
  15. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +7 -0
  16. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +6 -0
  17. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +6 -0
  18. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +10 -3
  19. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +6 -0
  20. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +7 -0
  21. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +7 -0
  22. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +7 -0
  23. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +6 -0
  24. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +6 -0
  25. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +7 -0
  26. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +6 -0
  27. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +6 -0
  28. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +6 -0
  29. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +7 -0
  30. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +6 -0
  31. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +6 -0
  32. package/src/shared/utils/MessageReceiptUtils.ts +32 -0
  33. package/src/shared/utils/MessageUtils.tsx +107 -4
  34. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +2 -2
  35. package/src/shared/views/CometChatConfirmDialog/style.ts +9 -6
  36. package/src/theme/default/typography.ts +4 -4
  37. package/src/theme/provider.tsx +2 -2
  38. package/src/theme/type.ts +19 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "5.2.1",
3
+ "version": "5.2.3",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
@@ -49,6 +49,7 @@ import { ErrorEmptyView } from "../shared/views/ErrorEmptyView/ErrorEmptyView";
49
49
  import { useTheme } from "../theme";
50
50
  import { Skeleton } from "./Skeleton";
51
51
  import { ConversationStyle, Style } from "./style";
52
+ import MessageReceiptUtils from "../shared/utils/MessageReceiptUtils";
52
53
  import { deepMerge } from "../shared/helper/helperFunctions";
53
54
  import Delete from "../shared/icons/components/delete";
54
55
  import { DeepPartial } from "../shared/helper/types";
@@ -896,13 +897,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
896
897
  lastMessage.getSender().getUid() == loggedInUser.current!.getUid() &&
897
898
  !lastMessage.getDeletedAt()
898
899
  ) {
899
- let status: MessageReceipt = MessageReceipt.ERROR;
900
- if (lastMessage?.hasOwnProperty("readAt")) status = MessageReceipt.READ;
901
- else if (lastMessage?.hasOwnProperty("deliveredAt")) status = MessageReceipt.DELIVERED;
902
- else if (lastMessage?.hasOwnProperty("sentAt")) status = MessageReceipt.SENT;
900
+ const status = MessageReceiptUtils.getReceiptStatus(lastMessage);
903
901
  readReceipt =
904
902
  !receiptsVisibility || lastMessage?.getDeletedAt() ? null : (
905
- <CometChatReceipt receipt={status} style={mergedStyles.itemStyle.receiptStyles} />
903
+ <CometChatReceipt receipt={status as MessageReceipt} style={mergedStyles.itemStyle.receiptStyles} />
906
904
  );
907
905
  }
908
906
 
@@ -1495,7 +1495,9 @@ export const CometChatMessageComposer = React.forwardRef(
1495
1495
  if (shouldOpenList(selection, searchString, tracker)) {
1496
1496
  activeCharacter.current = tracker;
1497
1497
  searchStringRef.current = searchString;
1498
+ // Show the suggestion list immediately (even while data is loading) to avoid layout jumps
1498
1499
  setShowMentionList(true);
1500
+ setSuggestionListLoader(true);
1499
1501
 
1500
1502
  let formatter = allFormatters.current.get(tracker);
1501
1503
  if (formatter instanceof CometChatMentionsFormatter) {
@@ -1514,6 +1516,7 @@ export const CometChatMessageComposer = React.forwardRef(
1514
1516
  searchStringRef.current = "";
1515
1517
  setShowMentionList(false);
1516
1518
  setMentionsSearchData([]);
1519
+ setSuggestionListLoader(false);
1517
1520
  }
1518
1521
  }, 100);
1519
1522
  };
@@ -1701,7 +1704,6 @@ export const CometChatMessageComposer = React.forwardRef(
1701
1704
  };
1702
1705
 
1703
1706
  const textChangeHandler = (txt: string) => {
1704
- setPlainText(txt);
1705
1707
  if (messagePreview) {
1706
1708
  setHasEdited(txt.trim() !== originalText.trim());
1707
1709
  }
@@ -1726,7 +1728,9 @@ export const CometChatMessageComposer = React.forwardRef(
1726
1728
  let decr = 0;
1727
1729
 
1728
1730
  plainTextInput.current = newText;
1729
- setPlainText(newText);
1731
+ if (!(oldText.length > newText.length)) {
1732
+ setPlainText(newText);
1733
+ }
1730
1734
 
1731
1735
  const newMentionMap: Map<string, SuggestionItem> = new Map(mentionMap.current);
1732
1736
 
@@ -1995,7 +1999,6 @@ export const CometChatMessageComposer = React.forwardRef(
1995
1999
  {CustomView && CustomView}
1996
2000
  </Modal>
1997
2001
  <KeyboardAvoidingView
1998
- key={id}
1999
2002
  behavior={Platform.OS === "ios" ? "padding" : "height"}
2000
2003
  keyboardVerticalOffset={Platform.select({ ios: kbOffset })}
2001
2004
  {...keyboardAvoidingViewProps}
@@ -2034,11 +2037,12 @@ export const CometChatMessageComposer = React.forwardRef(
2034
2037
  mediaRecorderStyle={mergedComposerStyle.mediaRecorderStyle}
2035
2038
  />
2036
2039
 
2037
- {mentionsSearchData.length > 0 && (plainTextInput.current?.length ?? 0) > 0 && (
2040
+ {showMentionList && (plainTextInput.current?.length ?? 0) > 0 && (
2038
2041
  <View
2039
2042
  style={[
2040
2043
  theme.mentionsListStyle.containerStyle,
2041
- messagePreview ? { maxHeight: Dimensions.get("window").height * 0.2 } : {},
2044
+ // Keep height stable to reduce flicker when list data loads/empties
2045
+ { maxHeight: Dimensions.get("window").height * (messagePreview ? 0.2 : (Platform.OS === "ios" ? 0.15 : 0.22)) },
2042
2046
  ]}
2043
2047
  >
2044
2048
  <CometChatSuggestionList
@@ -70,6 +70,7 @@ import { CometChatBadge } from "../shared/views/CometChatBadge";
70
70
  import { CometChatDate } from "../shared/views/CometChatDate";
71
71
  import { CometChatEmojiKeyboard } from "../shared/views/CometChatEmojiKeyboard";
72
72
  import { CometChatMessageBubble } from "../shared/views/CometChatMessageBubble";
73
+ import { getModerationStatus, ModerationBottomView } from "../shared/utils/MessageUtils";
73
74
  import { CometChatQuickReactions } from "../shared/views/CometChatQuickReactions";
74
75
  import { CometChatReactionList } from "../shared/views/CometChatReactionList";
75
76
  import { CometChatReactions } from "../shared/views/CometChatReactions";
@@ -157,6 +158,10 @@ export interface CometChatMessageListProps {
157
158
  * Custom sound URL for messages.
158
159
  */
159
160
  customSoundForMessages?: string;
161
+ /**
162
+ * Hides moderation status UI (bottom view) and suppresses moderation toasts.
163
+ */
164
+ hideModerationStatus?: boolean;
160
165
  /**
161
166
  * Alignment type for the message list.
162
167
  */
@@ -459,6 +464,7 @@ export const CometChatMessageList = memo(
459
464
  receiptsVisibility = true,
460
465
  disableSoundForMessages,
461
466
  customSoundForMessages,
467
+ hideModerationStatus = false,
462
468
  alignment = "standard",
463
469
  avatarVisibility = true,
464
470
  datePattern,
@@ -521,6 +527,7 @@ export const CometChatMessageList = memo(
521
527
  const hideGroupActionMessages = isAgenticUser() ? true : propHideGroupActionMessages;
522
528
 
523
529
  const callListenerId = "call_" + new Date().getTime();
530
+ const effectiveHideModeration = hideModerationStatus;
524
531
  const groupListenerId = "group_" + new Date().getTime();
525
532
  const uiEventListener = "uiEvent_" + new Date().getTime();
526
533
  const callEventListener = "callEvent_" + new Date().getTime();
@@ -1364,6 +1371,35 @@ export const CometChatMessageList = memo(
1364
1371
  conversationId.current = newMessage.getConversationId();
1365
1372
  }
1366
1373
 
1374
+ // ----------------------------------------------------------------------------------
1375
+ // De-duplication / in-place update logic
1376
+ // ----------------------------------------------------------------------------------
1377
+ // Fix: Before inserting, check for an existing message with matching id OR muid.
1378
+ // If found, update it in place instead of inserting again.
1379
+ try {
1380
+ const incomingId = (newMessage as any)?.getId?.();
1381
+ const incomingMuid = (newMessage as any)?.muid || (newMessage as any)?.getMuid?.();
1382
+ const existingIndex = messagesContentListRef.current.findIndex((m: any) => {
1383
+ const mid = m?.getId?.();
1384
+ const mmuid = m?.muid || m?.getMuid?.();
1385
+ return (
1386
+ (incomingId && mid && String(mid) === String(incomingId)) ||
1387
+ (incomingMuid && mmuid && String(mmuid) === String(incomingMuid))
1388
+ );
1389
+ });
1390
+ if (existingIndex !== -1) {
1391
+ // Update existing message instead of duplicating.
1392
+ const updatedList = [...messagesContentListRef.current];
1393
+ updatedList[existingIndex] = CommonUtils.clone(newMessage);
1394
+ messagesContentListRef.current = updatedList;
1395
+ onLoad && onLoad([...messagesContentListRef.current].reverse());
1396
+ setMessagesList(updatedList);
1397
+ return; // prevent duplicate insert
1398
+ }
1399
+ } catch (e) {
1400
+ console.log('Error in message de-duplication:', e);
1401
+ }
1402
+
1367
1403
  const isStreamMessage = (newMessage as any).isStreamMessage;
1368
1404
  const targetMessageId = (newMessage as any).targetMessageId;
1369
1405
  if (isStreamMessage && targetMessageId) {
@@ -1782,6 +1818,9 @@ export const CometChatMessageList = memo(
1782
1818
  onMessageEdited: (editedMessage: any) => {
1783
1819
  messageEdited(editedMessage);
1784
1820
  },
1821
+ onMessageModerated: (moderatedMessage: any) => {
1822
+ messageEdited(moderatedMessage);
1823
+ },
1785
1824
  onFormMessageReceived: (formMessage: any) => {
1786
1825
  newMessage(formMessage);
1787
1826
  },
@@ -2194,6 +2233,8 @@ export const CometChatMessageList = memo(
2194
2233
  const nextItemIsDelivered =
2195
2234
  messagesContentListRef.current[currentIndex! - 1] &&
2196
2235
  messagesContentListRef.current[currentIndex! - 1].getDeliveredAt();
2236
+ // Moderation status should override other receipt states for immediate error display
2237
+ const moderationStatus = getModerationStatus(item);
2197
2238
  if (item.getReadAt() || nextItemIsRead) messageState = MessageReceipt.READ;
2198
2239
  else if (item.getDeliveredAt() || nextItemIsDelivered)
2199
2240
  messageState = MessageReceipt.DELIVERED;
@@ -2202,6 +2243,12 @@ export const CometChatMessageList = memo(
2202
2243
  else if (isOutgoingMessage) messageState = MessageReceipt.WAIT;
2203
2244
  else messageState = MessageReceipt.ERROR;
2204
2245
 
2246
+ // Moderation overrides
2247
+ if (moderationStatus === "pending") {
2248
+ messageState = MessageReceipt.WAIT; // show wait icon until approved/disapproved
2249
+ } else if (moderationStatus === "disapproved") {
2250
+ messageState = MessageReceipt.ERROR;
2251
+ }
2205
2252
  // Determine if message has been edited.
2206
2253
  // This example assumes you have a method (or property) like getEditedAt() that returns a timestamp when edited.
2207
2254
  const isEdited =
@@ -2310,6 +2357,11 @@ export const CometChatMessageList = memo(
2310
2357
  messageObject?.getReactions &&
2311
2358
  messageObject?.getReactions() &&
2312
2359
  messageObject?.getReactions().length > 0;
2360
+ const moderationStatus = getModerationStatus(messageObject);
2361
+ const isOutgoing = messageObject.getSender()?.getUid() === loggedInUser.current?.getUid();
2362
+ if (isOutgoing && moderationStatus && moderationStatus !== "unmoderated") {
2363
+ return null;
2364
+ }
2313
2365
  return hasReaction
2314
2366
  ? (params: { maxContentWidth?: number }) => {
2315
2367
  return (
@@ -2377,6 +2429,11 @@ export const CometChatMessageList = memo(
2377
2429
  let isThreaded = item.getReplyCount() > 0;
2378
2430
 
2379
2431
  let _style = getCurrentBubbleStyle(item);
2432
+ const moderationStatus = getModerationStatus(item);
2433
+ const isOutgoing = item.getSender()?.getUid() === loggedInUser.current?.getUid();
2434
+ if (isOutgoing && moderationStatus && moderationStatus !== "unmoderated") {
2435
+ return undefined; // hide thread view if moderated
2436
+ }
2380
2437
  return !isThreaded ? undefined : (
2381
2438
  <TouchableOpacity
2382
2439
  onPress={() => openThreadView(item, null)}
@@ -2503,6 +2560,20 @@ export const CometChatMessageList = memo(
2503
2560
  }
2504
2561
  return option;
2505
2562
  });
2563
+ // Restrict options for disapproved outgoing messages (only delete + copy for text)
2564
+ const moderationStatus = getModerationStatus(item);
2565
+ const isOutgoing = item.getSender?.()?.getUid?.() === loggedInUser.current?.getUid?.();
2566
+ if (moderationStatus === "disapproved" && isOutgoing) {
2567
+ optionsWithPressHandling = optionsWithPressHandling.filter((opt) => {
2568
+ if (opt.id === MessageOptionConstants.deleteMessage) return true;
2569
+ if (
2570
+ opt.id === MessageOptionConstants.copyMessage &&
2571
+ (item.getType?.() === MessageTypeConstants.text || item?.getType === MessageTypeConstants.text)
2572
+ )
2573
+ return true;
2574
+ return false;
2575
+ });
2576
+ }
2506
2577
  setShowMessageOptions(optionsWithPressHandling);
2507
2578
  },
2508
2579
  [mergedTheme]
@@ -2573,8 +2644,24 @@ export const CometChatMessageList = memo(
2573
2644
  }, [isThreaded, message, getLeadingView, hasTemplate, bubbleAlignment]);
2574
2645
 
2575
2646
  const BottomView = useMemo(() => {
2576
- return hasTemplate?.BottomView && hasTemplate?.BottomView(message, bubbleAlignment);
2577
- }, [hasTemplate, message, bubbleAlignment]);
2647
+ const moderationStatus = getModerationStatus(message);
2648
+ const isOutgoing = message.getSender()?.getUid() === loggedInUser.current?.getUid();
2649
+ if (effectiveHideModeration) {
2650
+ return hasTemplate?.BottomView && hasTemplate?.BottomView(message, bubbleAlignment);
2651
+ } else {
2652
+ if (isOutgoing && moderationStatus === "disapproved") {
2653
+ return (
2654
+ <ModerationBottomView
2655
+ status={moderationStatus}
2656
+ moderationStyle={
2657
+ mergedTheme.messageListStyles.outgoingMessageBubbleStyles.moderationStyle
2658
+ }
2659
+ />
2660
+ );
2661
+ }
2662
+ return hasTemplate?.BottomView && hasTemplate?.BottomView(message, bubbleAlignment);
2663
+ }
2664
+ }, [hasTemplate, message, bubbleAlignment, effectiveHideModeration]);
2578
2665
 
2579
2666
  const StatusInfoView = useMemo(() => {
2580
2667
  return hasTemplate?.StatusInfoView &&
@@ -2587,6 +2674,9 @@ export const CometChatMessageList = memo(
2587
2674
  if (hasTemplate?.BubbleView) return hasTemplate?.BubbleView(message);
2588
2675
 
2589
2676
  const onLongPress = useCallback(() => {
2677
+ // Ensure the keyboard is dismissed before showing options so the action sheet / menu isn't obscured
2678
+ Keyboard.dismiss();
2679
+
2590
2680
  if (message.getDeletedBy() != null) return;
2591
2681
 
2592
2682
  if (!message.getId()) {
@@ -3278,7 +3368,8 @@ export const CometChatMessageList = memo(
3278
3368
  />
3279
3369
  ) : (
3280
3370
  <View style={{ flex: 1 }}>
3281
- {!hideReactionOption && (
3371
+ {/* Show quick reactions for disapproved messages */}
3372
+ {!hideReactionOption && getModerationStatus(selectedMessage) !== "disapproved" && (
3282
3373
  <CometChatQuickReactions
3283
3374
  quickReactions={quickReactionList}
3284
3375
  onReactionPress={reactToMessage}
@@ -392,6 +392,26 @@ export const getMessageListStylesLight = (
392
392
  borderRadius: spacing.radius.r3,
393
393
  minWidth: 90,
394
394
  },
395
+ moderationStyle: {
396
+ containerStyle: {
397
+ backgroundColor: "#F9EAEF",
398
+ paddingVertical: 6,
399
+ borderBottomLeftRadius: 8,
400
+ borderBottomRightRadius: 8,
401
+ borderTopLeftRadius: 0,
402
+ borderTopRightRadius: 0,
403
+ flexDirection: "row",
404
+ alignItems: "center",
405
+ },
406
+ textStyle: {
407
+ color: color?.error,
408
+ ...typography?.body?.regular,
409
+ flexShrink: 1,
410
+ paddingHorizontal: 2,
411
+ alignSelf: "center",
412
+ },
413
+ iconTintColor: color?.error,
414
+ },
395
415
  dateStyles: {
396
416
  containerStyle: {
397
417
  paddingTop: spacing.padding.p2,
@@ -469,6 +489,7 @@ export const getMessageListStylesLight = (
469
489
  padding: spacing.padding.p1,
470
490
  paddingBottom: spacing.padding.p0,
471
491
  borderRadius: spacing.radius.r3,
492
+ overflow: "hidden",
472
493
  },
473
494
  imageStyle: {
474
495
  borderRadius: spacing.radius.r2,
@@ -874,6 +895,27 @@ export const getMessageListStylesDark = (
874
895
  borderRadius: spacing.radius.r3,
875
896
  minWidth: 90,
876
897
  },
898
+ moderationStyle: {
899
+ containerStyle: {
900
+ backgroundColor: "#3A0C05",
901
+ paddingVertical: 6,
902
+ borderBottomLeftRadius: 8,
903
+ borderBottomRightRadius: 8,
904
+ borderTopLeftRadius: 0,
905
+ borderTopRightRadius: 0,
906
+ flexDirection: "row",
907
+ alignItems: "center",
908
+ overflow: 'hidden',
909
+ },
910
+ textStyle: {
911
+ color: color?.error,
912
+ ...typography?.body?.regular,
913
+ flexShrink: 1,
914
+ paddingHorizontal: 2,
915
+ alignSelf: "center",
916
+ },
917
+ iconTintColor: color?.error,
918
+ },
877
919
  dateStyles: {
878
920
  containerStyle: {
879
921
  paddingTop: spacing.padding.p2,
@@ -951,6 +993,7 @@ export const getMessageListStylesDark = (
951
993
  padding: spacing.padding.p1,
952
994
  paddingBottom: spacing.padding.p0,
953
995
  borderRadius: spacing.radius.r3,
996
+ overflow: "hidden",
954
997
  },
955
998
  imageStyle: {
956
999
  borderRadius: spacing.radius.r2,
@@ -227,8 +227,12 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
227
227
  : theme.messageListStyles.incomingMessageBubbleStyles?.meetCallBubbleStyles;
228
228
 
229
229
  const sentAt = message?.getSentAt() ? message.getSentAt() * 1000 : Date.now();
230
+ const customData = message.getCustomData() as any;
230
231
  const callType = (message.getCustomData() as any).callType;
231
232
 
233
+ // Extract session ID with cross-platform compatibility
234
+ const sessionId = customData.sessionId || customData.sessionID;
235
+
232
236
  const BubbleIcon = (() => {
233
237
  if (isSentByMe) {
234
238
  if (callType === "audio") {
@@ -251,7 +255,7 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
251
255
  icon={BubbleIcon}
252
256
  onClick={() =>
253
257
  this.startDirectCall(
254
- (message.getCustomData() as any)["sessionId"],
258
+ sessionId,
255
259
  message,
256
260
  theme,
257
261
  callType
@@ -281,9 +285,27 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
281
285
  theme?: CometChatTheme,
282
286
  callType?: string
283
287
  ) {
284
- if (!(await permissionUtil.startResourceBasedTask(["mic", "camera"]))) {
288
+ // Validate session ID
289
+ if (!sessionId || sessionId === 'undefined' || sessionId === 'null') {
290
+ console.error('[CallingExtensionDecorator] Invalid session ID provided:', sessionId);
291
+ return;
292
+ }
293
+
294
+ // Request only the necessary permissions based on call type.
295
+ try {
296
+ const resources: ("mic" | "camera")[] = callType === "audio" ? ["mic"] : ["mic", "camera"];
297
+ const allowed = await permissionUtil.startResourceBasedTask(resources);
298
+ if (!allowed) {
299
+ console.warn(
300
+ `[CallingExtensionDecorator] Permission check failed for resources: ${resources.join(",")}. Aborting join.`
301
+ );
302
+ return;
303
+ }
304
+ } catch (e) {
305
+ console.error("[CallingExtensionDecorator] Unexpected error while requesting permissions", e);
285
306
  return;
286
307
  }
308
+
287
309
  const callSettingsBuilder = (
288
310
  this.configuration?.groupCallSettingsBuilder
289
311
  ? this.configuration?.groupCallSettingsBuilder(
@@ -300,6 +322,7 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
300
322
  });
301
323
  },
302
324
  onError: (error: CometChat.CometChatException) => {
325
+ console.error("[CallingExtensionDecorator] OngoingCallListener onError while joining", error);
303
326
  CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccShowOngoingCall, {
304
327
  child: null,
305
328
  });
@@ -313,6 +336,7 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
313
336
  sessionID={sessionId}
314
337
  callSettingsBuilder={callSettingsBuilder}
315
338
  onError={(e) => {
339
+ console.error("[CallingExtensionDecorator] CometChatOngoingCall onError for session", sessionId, e);
316
340
  CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccShowOngoingCall, {
317
341
  child: null,
318
342
  });
@@ -375,8 +399,9 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
375
399
  }
376
400
  return <></>;
377
401
  },
378
- options: (loggedInUser, messageObject, group) => {
379
- return super.getCommonOptions(loggedInUser, messageObject, group);
402
+ // Pass theme explicitly so common options (e.g. Message Privately) validate group context correctly.
403
+ options: (loggedInUser, messageObject, _theme, group) => {
404
+ return super.getCommonOptions(loggedInUser, messageObject, _theme, group);
380
405
  },
381
406
  });
382
407
  };
@@ -47,19 +47,28 @@ export const CometChatOngoingCall = (props: CometChatOngoingCallInterface): JSX.
47
47
  // Fetch the logged-in user and generate a token for the ongoing call session.
48
48
  CometChat.getLoggedinUser()
49
49
  .then((user) => {
50
- const authToken = user!.getAuthToken();
51
- CometChatCalls.generateToken(sessionID, authToken)
52
- .then((token: any) => {
53
- setToken(token.token);
54
- })
55
- .catch((rej: CometChat.CometChatException) => {
56
- setToken(undefined);
57
- onError && onError(rej);
58
- });
50
+ if (!user) {
51
+ throw new Error('No logged in user found');
52
+ }
53
+
54
+ const authToken = user.getAuthToken();
55
+ console.log('[CometChatOngoingCall] Got auth token, generating call token...');
56
+
57
+ return CometChatCalls.generateToken(sessionID, authToken);
59
58
  })
60
- .catch((rej) => {
61
- console.log("Error", rej);
62
- onError && onError(rej);
59
+ .then((token: any) => {
60
+ console.log('[CometChatOngoingCall] Successfully generated call token');
61
+ setToken(token.token);
62
+ })
63
+ .catch((rej: CometChat.CometChatException | Error) => {
64
+ console.error('[CometChatOngoingCall] Failed to generate token for session:', sessionID, rej);
65
+ setToken(undefined);
66
+ onError && onError(rej instanceof Error ?
67
+ new CometChat.CometChatException({
68
+ code: 'TOKEN_GENERATION_FAILED',
69
+ message: rej.message
70
+ }) : rej
71
+ );
63
72
  });
64
73
 
65
74
  // Cleanup call settings on unmount.
@@ -191,6 +191,9 @@ export class CometChatUIEventHandler {
191
191
  case listener._eventListener?.onAIAssistantMessageReceived?.name:
192
192
  listener._eventListener?.onAIAssistantMessageReceived?.(param);
193
193
  break;
194
+ case listener._eventListener?.onMessageModerated?.name:
195
+ listener._eventListener?.onMessageModerated?.(param);
196
+ break;
194
197
  }
195
198
  });
196
199
  }
@@ -36,6 +36,7 @@ type MessageUIEvents = {
36
36
  onMessageReactionRemoved?: Function;
37
37
  onMessagesDeliveredToAll?: Function;
38
38
  onMessagesReadByAll?: Function;
39
+ onMessageModerated?: Function;
39
40
  onAIAssistantMessageReceived?: Function;
40
41
  };
41
42
  export class MessageUIEventListener {
@@ -65,6 +66,7 @@ export class MessageUIEventListener {
65
66
  onMessageReactionRemoved?: Function = undefined;
66
67
  onMessagesDeliveredToAll?: Function = undefined;
67
68
  onMessagesReadByAll?: Function = undefined;
69
+ onMessageModerated?: Function = undefined;
68
70
  onAIAssistantMessageReceived?: Function = undefined;
69
71
  constructor({
70
72
  ccMessageSent,
@@ -93,6 +95,7 @@ export class MessageUIEventListener {
93
95
  onMessageReactionRemoved,
94
96
  onMessagesDeliveredToAll,
95
97
  onMessagesReadByAll,
98
+ onMessageModerated,
96
99
  onAIAssistantMessageReceived,
97
100
  }: MessageUIEvents) {
98
101
  if (!isFalsy(ccMessageError)) this.ccMessageError = ccMessageError;
@@ -129,6 +132,7 @@ export class MessageUIEventListener {
129
132
  this.onMessagesDeliveredToAll = onMessagesDeliveredToAll;
130
133
  if (!isFalsy(onMessagesReadByAll)) this.onMessagesReadByAll = onMessagesReadByAll;
131
134
  if (!isFalsy(onAIAssistantMessageReceived)) this.onAIAssistantMessageReceived = onAIAssistantMessageReceived;
135
+ if (!isFalsy(onMessageModerated)) this.onMessageModerated = onMessageModerated;
132
136
  }
133
137
  }
134
138
 
@@ -87,6 +87,9 @@ export class ListenerInitializer {
87
87
  },
88
88
  onAIAssistantMessageReceived: (message: CometChat.AIAssistantMessage) => {
89
89
  CometChatUIEventHandler.emitMessageEvent(MessageEvents.onAIAssistantMessageReceived, message);
90
+ },
91
+ onMessageModerated: (message: CometChat.BaseMessage) => {
92
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessageModerated, message);
90
93
  }
91
94
  });
92
95
  }
@@ -24,5 +24,6 @@ export enum MessageEvents {
24
24
  onCustomInteractiveMessageReceived = "onCustomInteractiveMessageReceived",
25
25
  onMessageReactionAdded = "onMessageReactionAdded",
26
26
  onMessageReactionRemoved = "onMessageReactionRemoved",
27
+ onMessageModerated = "onMessageModerated",
27
28
  onAIAssistantMessageReceived = "onAIAssistantMessageReceived",
28
29
  }
@@ -0,0 +1,32 @@
1
+ import Svg, { Mask, Path, G } from "react-native-svg";
2
+ import type { SvgProps } from "react-native-svg";
3
+ const SvgComponent = ({ height, width, color }: SvgProps) => (
4
+ <Svg
5
+ width={width}
6
+ height={height}
7
+ fill="none"
8
+ color={color}
9
+ viewBox="0 0 16 16"
10
+ >
11
+ <Mask
12
+ id="prefix__a"
13
+ width={16}
14
+ height={16}
15
+ x={0}
16
+ y={0}
17
+ maskUnits="userSpaceOnUse"
18
+ style={{
19
+ maskType: "alpha",
20
+ }}
21
+ >
22
+ <Path fill="#D9D9D9" d="M0 0h16v16H0z" />
23
+ </Mask>
24
+ <G mask="url(#prefix__a)">
25
+ <Path
26
+ fill="#F44649"
27
+ d="M2.283 13.667a.583.583 0 0 1-.514-.301.64.64 0 0 1-.086-.292.54.54 0 0 1 .085-.311l5.707-9.859a.6.6 0 0 1 .524-.301q.154 0 .293.073.14.074.232.228l5.707 9.859q.093.153.085.31a.64.64 0 0 1-.296.51.57.57 0 0 1-.304.084zm5.716-1.795q.229 0 .384-.155a.52.52 0 0 0 .155-.384.52.52 0 0 0-.155-.383.52.52 0 0 0-.384-.155.52.52 0 0 0-.383.155.52.52 0 0 0-.155.383q0 .229.155.384a.52.52 0 0 0 .383.155m0-1.744q.213 0 .357-.144a.48.48 0 0 0 .143-.356V7.295a.48.48 0 0 0-.143-.356.48.48 0 0 0-.357-.144.48.48 0 0 0-.356.144.48.48 0 0 0-.144.356v2.333q0 .213.144.356a.48.48 0 0 0 .357.144"
28
+ />
29
+ </G>
30
+ </Svg>
31
+ );
32
+ export default SvgComponent;
@@ -310,7 +310,7 @@ import AISendButton from "./components/ai-send-button";
310
310
  import AINewChatButton from "./components/ai-new-chat";
311
311
  import AIChatHistory from "./components/ai-chat-history";
312
312
  import AICopyOption from "./components/ai-copy-option";
313
-
313
+ import MessageBlocked from "./components/message-blocked";
314
314
 
315
315
  /**************************************** */
316
316
 
@@ -631,4 +631,6 @@ export const ICONS = {
631
631
  "ai-chat-history": AIChatHistory,
632
632
  "ai-copy-option": AICopyOption,
633
633
 
634
+ "message-blocked": MessageBlocked,
635
+
634
636
  } as const;
@@ -454,6 +454,12 @@
454
454
  "MESSAGE_LIST_ACTION_SCOPE_CHANGED": "${byName} hat ${onName} zum ${role} ernannt",
455
455
  "YOU_DONT_HAVE_STICKERS_YET": "Du hast noch keine Sticker.",
456
456
  "meeting": "Besprechung",
457
+ "START_REPORTING": "Bericht starten",
458
+ "LOGOUT": "Abmelden",
459
+ "AI_ASSISTANTS": "KI-Assistenten",
460
+ "CREATE_CONVERSATION": "Konversation erstellen",
461
+ "EDIT_MODERATION": "Bearbeitung fehlgeschlagen. Ihre Nachricht wurde aufgrund der Moderationsrichtlinien blockiert.",
462
+ "BLOCKED_MODERATION":"Ihre Nachricht wurde aufgrund der Moderationsrichtlinien blockiert.",
457
463
  "NO_CONVERSATION_HISTORY_FOUND": "Kein Gesprächsverlauf gefunden",
458
464
  "SOMETHING_WENT_WRONG_ON_OUR_END": "Etwas ist schief gelaufen. Bitte versuchen Sie es erneut",
459
465
  "START_A_CHAT": "Beginnen Sie einen Chat, indem Sie auf die Schaltfläche 'Neuer Chat' tippen",
@@ -441,6 +441,7 @@
441
441
  "DELETE_MESSAGE_CONFIRM":"Are you sure you want to delete this message? This action cannot be undone.",
442
442
  "APP_CREDENTIALS" : "App Credentials",
443
443
  "REGION": "Region",
444
+ "CHAT_PRIVATELY": "Chat Privately",
444
445
  "WRONG_TEXT":"Looks like something went wrong.",
445
446
  "WRONG_TEXT_TRY_AGAIN":"Please try again.",
446
447
  "BLOCKED_USER_DESC": "Can't send a message as the user is blocked",
@@ -453,6 +454,12 @@
453
454
  "MESSAGE_LIST_ACTION_SCOPE_CHANGED": "${byName} made ${onName} a ${role}",
454
455
  "YOU_DONT_HAVE_STICKERS_YET": "You don’t have any stickers yet.",
455
456
  "meeting": "Meeting",
457
+ "START_REPORTING": "Start Reporting",
458
+ "LOGOUT": "Logout",
459
+ "AI_ASSISTANTS": "AI Assistants",
460
+ "CREATE_CONVERSATION": "Create Conversation",
461
+ "EDIT_MODERATION": "Edit failed. Your message was blocked due to moderation policies.",
462
+ "BLOCKED_MODERATION":"Your message was blocked due to moderation policies.",
456
463
  "NO_CONVERSATION_HISTORY_FOUND": "No conversation history found",
457
464
  "SOMETHING_WENT_WRONG_ON_OUR_END": "Something went wrong on our end. Please try again.",
458
465
  "START_A_CHAT": "Click the 'New Chat' button to start a chat.",
@@ -454,6 +454,12 @@
454
454
  "MESSAGE_LIST_ACTION_SCOPE_CHANGED": "${byName} hizo a ${onName} ${role}",
455
455
  "YOU_DONT_HAVE_STICKERS_YET": "Aún no tienes ningún sticker.",
456
456
  "meeting": "Reunión",
457
+ "START_REPORTING": "Iniciar informe",
458
+ "LOGOUT": "Cerrar sesión",
459
+ "AI_ASSISTANTS": "Asistentes de IA",
460
+ "CREATE_CONVERSATION": "Crear conversación",
461
+ "EDIT_MODERATION": "Edición fallida. Tu mensaje fue bloqueado debido a las políticas de moderación.",
462
+ "BLOCKED_MODERATION":"Tu mensaje fue bloqueado debido a las políticas de moderación.",
457
463
  "NO_CONVERSATION_HISTORY_FOUND": "No se encontró el historial de conversaciones",
458
464
  "SOMETHING_WENT_WRONG_ON_OUR_END": "Algo salió mal de nuestro lado. Por favor, intenta de nuevo.",
459
465
  "START_A_CHAT": "Comienza un chat tocando el botón 'Nueva conversación'",
@@ -454,6 +454,12 @@
454
454
  "YOU_INITIATED_GROUP_AUDIO_CALL": "Vous avez lancé un appel audio",
455
455
  "YOU_INITIATED_GROUP_VIDEO_CALL": "Vous avez lancé un appel vidéo",
456
456
  "meeting": "Réunion",
457
+ "START_REPORTING": "Commencer le rapport",
458
+ "LOGOUT": "Se déconnecter",
459
+ "AI_ASSISTANTS": "Assistants IA",
460
+ "CREATE_CONVERSATION": "Créer une conversation",
461
+ "EDIT_MODERATION": "Édition échouée. Votre message a été bloqué en raison des politiques de modération",
462
+ "BLOCKED_MODERATION":"Votre message a été bloqué en raison des politiques de modération.",
457
463
  "NO_CONVERSATION_HISTORY_FOUND": "Aucun historique de conversation trouvé",
458
464
  "SOMETHING_WENT_WRONG_ON_OUR_END": "Quelque chose a mal tourné de notre côté. Veuillez réessayer",
459
465
  "START_A_CHAT": "Commencez un chat en appuyant sur le bouton 'Nouvelle conversation'",