@cometchat/chat-uikit-react-native 5.5.1 → 5.5.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 (61) hide show
  1. package/android/build.gradle +35 -89
  2. package/android/gradle.properties +5 -5
  3. package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +5 -1
  4. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +52 -0
  5. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +235 -4
  6. package/ios/FileManager.m +77 -3
  7. package/ios/RichTextEditorView.swift +234 -24
  8. package/package.json +7 -4
  9. package/react-native-cometchat-ui-kit.podspec +5 -19
  10. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +31 -27
  11. package/src/CometChatConversations/CometChatConversations.tsx +4 -0
  12. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +35 -28
  13. package/src/CometChatMessageList/CometChatMessageList.tsx +20 -18
  14. package/src/CometChatRichTextEditor/index.tsx +2 -1
  15. package/src/CometChatSearch/CometChatSearch.tsx +10 -5
  16. package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +56 -17
  17. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +12 -9
  18. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +13 -10
  19. package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +34 -27
  20. package/src/extensions/Polls/Polls.tsx +7 -7
  21. package/src/extensions/Polls/PollsBubble.tsx +2 -2
  22. package/src/globals.d.ts +6 -0
  23. package/src/shared/constants/textPatterns.ts +20 -2
  24. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +22 -11
  25. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +26 -14
  26. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +8 -0
  27. package/src/shared/formatters/codeElements.ts +21 -0
  28. package/src/shared/helper/types/index.ts +5 -0
  29. package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +4 -4
  30. package/src/shared/libs/ImageZoom/types/index.ts +2 -0
  31. package/src/shared/resources/CometChatSoundManager/sound.js +2 -3
  32. package/src/shared/services/UploadQueueService.ts +7 -0
  33. package/src/shared/utils/CometChatMessageHelper/index.ts +3 -0
  34. package/src/shared/utils/MarkdownUtils.ts +11 -4
  35. package/src/shared/utils/MessageUtils.tsx +7 -5
  36. package/src/shared/utils/groupMemberAddedRows.ts +28 -0
  37. package/src/shared/utils/linkPreviewSelection.ts +109 -0
  38. package/src/shared/utils/mentionTokens.ts +77 -0
  39. package/src/shared/utils/runAfterInteractions.ts +26 -0
  40. package/src/shared/utils/stripRichText.ts +2 -1
  41. package/src/shared/utils/tapGesture.ts +23 -0
  42. package/src/shared/utils/videoThumbnail.ts +74 -0
  43. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +21 -13
  44. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +13 -15
  45. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +1 -1
  46. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +2 -1
  47. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +2 -1
  48. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +3 -26
  49. package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +4 -2
  50. package/src/shared/views/CometChatList/Header.tsx +1 -1
  51. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +2 -1
  52. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +28 -8
  53. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -4
  54. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +36 -4
  55. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +2 -1
  56. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +57 -30
  57. package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +0 -478
  58. package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +0 -613
  59. package/src/CometChatMessageList/SEARCH_NAV_SLOWNESS_FINDINGS_AND_FIX.md +0 -313
  60. package/src/shared/CometChatUiKit/CometChatUIKit.changes.md +0 -76
  61. package/src/shared/CometChatUiKit/checkAuthSettings-review.md +0 -211
@@ -18,12 +18,12 @@ import {
18
18
  Dimensions,
19
19
  ImageSourcePropType,
20
20
  ImageStyle,
21
- InteractionManager,
22
21
  Keyboard,
23
22
  ColorValue,
24
23
  TouchableWithoutFeedbackProps,
25
24
  ScrollView,
26
25
  StyleSheet,
26
+ StatusBar,
27
27
  } from 'react-native';
28
28
  import { JSX } from 'react';
29
29
  import RichTextEditor, {
@@ -111,6 +111,7 @@ import {
111
111
  getUnixTimestampInMilliseconds,
112
112
  messageStatus,
113
113
  } from '../shared/utils/CometChatMessageHelper';
114
+ import { runAfterInteractions } from '../shared/utils/runAfterInteractions';
114
115
  import { MessageTypeConstants, ReceiverTypeConstants, ConversationOptionConstants, MentionsVisibility, MentionsTargetElement, ViewAlignment, EnterKeyBehavior, DISABLED_BUTTON_OPACITY } from '../shared/constants/UIKitConstants';
115
116
  import { MessageEvents } from '../shared/events';
116
117
  import { CometChatUIEventHandler } from '../shared/events/CometChatUIEventHandler/CometChatUIEventHandler';
@@ -118,6 +119,7 @@ import { CometChatMessageEvents } from '../shared/events/CometChatMessageEvents'
118
119
  import { ICONS } from './resources';
119
120
  import { CommonUtils } from '../shared/utils/CommonUtils';
120
121
  import { isCursorWithinMentionRange, getMentionRangeAtCursor } from '../shared/utils/MentionUtils';
122
+ import { escapeTypedMentionTokens, insertMentionTokens } from '../shared/utils/mentionTokens';
121
123
  import { stripMarkdown } from '../shared/utils/MarkdownUtils';
122
124
  import { commonVars } from '../shared/base/vars';
123
125
  import { permissionUtil } from '../shared/utils/PermissionUtil';
@@ -3042,7 +3044,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3042
3044
  // Update cursor position to the start of the first deleted mention
3043
3045
  const firstStart = overlaps[0].start;
3044
3046
  ignoreSelectionUntil.current = Date.now() + 500;
3045
- InteractionManager.runAfterInteractions(() => {
3047
+ runAfterInteractions(() => {
3046
3048
  inputRef.current?.setSelection?.(firstStart);
3047
3049
  setSelectionPosition({ start: firstStart, end: firstStart });
3048
3050
  syncMentionRanges();
@@ -3198,7 +3200,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3198
3200
  targetPosition = mentionRange.end;
3199
3201
  }
3200
3202
  if (targetPosition !== cursorPos) {
3201
- InteractionManager.runAfterInteractions(() => {
3203
+ runAfterInteractions(() => {
3202
3204
  inputRef.current?.setSelection?.(targetPosition);
3203
3205
  setSelectionPosition({ start: targetPosition, end: targetPosition });
3204
3206
  });
@@ -3437,24 +3439,9 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3437
3439
  * Convert mentions to underlying text format for sending
3438
3440
  * Iterates through mentionMap and replaces prompt text with underlying text
3439
3441
  */
3440
- const getRegexString = (str: string): string => {
3441
- // Get an array of the entries in the map using the spread operator
3442
- const entries = [...mentionMap.current.entries()].reverse();
3443
-
3444
- let uidInput = str;
3445
-
3446
- // Iterate over the array in reverse order
3447
- entries.forEach(([key, value]) => {
3448
- const [start, end] = key.split('_').map(Number);
3449
-
3450
- const pre = uidInput.substring(0, start);
3451
- const post = uidInput.substring(end);
3452
-
3453
- uidInput = pre + value.underlyingText + post;
3454
- });
3455
-
3456
- return uidInput;
3457
- };
3442
+ const getRegexString = (str: string): string =>
3443
+ // Token-looking text the user typed is escaped so it is stored as text, not a live mention.
3444
+ insertMentionTokens(str, mentionMap.current.entries());
3458
3445
 
3459
3446
  /**
3460
3447
  * Replace mention display names with underlying tokens in the given text.
@@ -3464,11 +3451,14 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3464
3451
  * when the same display name appears multiple times.
3465
3452
  */
3466
3453
  const replaceMentionsWithTokens = (text: string): string => {
3467
- if (mentionMap.current.size === 0) return text;
3454
+ // Escape token-looking text the user typed first; the picked mentions inserted below are
3455
+ // the only real tokens.
3456
+ const typed = escapeTypedMentionTokens(text);
3457
+ if (mentionMap.current.size === 0) return typed;
3468
3458
  const entries = [...mentionMap.current.entries()].sort((a, b) => {
3469
3459
  return parseInt(a[0].split('_')[0]) - parseInt(b[0].split('_')[0]);
3470
3460
  });
3471
- let result = text;
3461
+ let result = typed;
3472
3462
  let offset = 0;
3473
3463
  for (const [, value] of entries) {
3474
3464
  const displayName = value.promptText || '';
@@ -3514,8 +3504,10 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3514
3504
  itemLookup.set(item.id, item);
3515
3505
  }
3516
3506
 
3517
- // Single-pass: collect matches, build resolved text via array join
3518
- const mentionRegex = /<@(?:uid|all):(.*?)>/g;
3507
+ // Single-pass: collect matches, build resolved text via array join. The second
3508
+ // alternative is token text the user TYPED, stored escaped (`&lt;@all:…`); it goes back
3509
+ // into the editor as the literal `<@all:…` they typed, never as a mention.
3510
+ const mentionRegex = /<@(?:uid|all):(.*?)>|&lt;(@(?:uid|all):)/g;
3519
3511
  let match: RegExpExecArray | null;
3520
3512
  const segments: string[] = [];
3521
3513
  let lastIndex = 0;
@@ -3528,6 +3520,13 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3528
3520
  segments.push(before);
3529
3521
  resolvedLength += before.length;
3530
3522
 
3523
+ if (match[2] !== undefined) {
3524
+ segments.push("<" + match[2]);
3525
+ resolvedLength += match[2].length + 1;
3526
+ lastIndex = match.index + match[0].length;
3527
+ continue;
3528
+ }
3529
+
3531
3530
  const item = itemLookup.get(match[1]);
3532
3531
  const displayText = item?.promptText ?? `@${match[1]}`;
3533
3532
  segments.push(displayText);
@@ -4991,8 +4990,13 @@ export const CometChatCompactMessageComposer = React.forwardRef(
4991
4990
  {/* KeyboardAvoidingView wrapper */}
4992
4991
  <KeyboardAvoidingView
4993
4992
  key={id}
4994
- behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
4995
- keyboardVerticalOffset={Platform.select({ ios: kbOffset })}
4993
+ // "padding" on Android too: with edge-to-edge (always on from RN 0.87 / targetSdk 36) the window no
4994
+ // longer resizes for the keyboard, and "height" squashes this composer instead of lifting it.
4995
+ // When the window does resize (adjustResize), the keyboard overlap is 0 and padding adds nothing.
4996
+ behavior='padding'
4997
+ // The view is measured from its parent, the keyboard from the top of the screen: offset by
4998
+ // what sits above the parent — the top safe area on iOS, the status bar on Android.
4999
+ keyboardVerticalOffset={Platform.select({ ios: kbOffset, android: StatusBar.currentHeight ?? 0 })}
4996
5000
  {...keyboardAvoidingViewProps}
4997
5001
  >
4998
5002
  {/* Outer wrapper with padding (matches Figma: Message Composer) */}
@@ -1958,6 +1958,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
1958
1958
  });
1959
1959
  },
1960
1960
  ccCallEnded: ({ call }: any) => {
1961
+ // CometChatIncomingCall emits ccCallEnded with no call when the session ends. The SDK
1962
+ // throws inside getConversationFromMessage(undefined) without rejecting the promise it
1963
+ // returns, so the .catch below never runs and the error surfaces as an unhandled rejection.
1964
+ if (!call) return;
1961
1965
  CometChat.CometChatHelper.getConversationFromMessage(call)
1962
1966
  .then((conversation) => {
1963
1967
  if (!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()) {
@@ -1,12 +1,13 @@
1
1
  let __listenerIdCounter = 0;
2
2
  import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
3
- import { Keyboard } from "react-native";
3
+ import { Keyboard,
4
+ StatusBar,
5
+ } from "react-native";
4
6
  import {
5
7
  ColorValue,
6
8
  Dimensions,
7
9
  ImageSourcePropType,
8
10
  ImageStyle,
9
- InteractionManager,
10
11
  KeyboardAvoidingView,
11
12
  KeyboardAvoidingViewProps,
12
13
  Modal,
@@ -57,8 +58,10 @@ import {
57
58
  messageStatus,
58
59
  } from "../shared/utils/CometChatMessageHelper";
59
60
  import { CommonUtils } from "../shared/utils/CommonUtils";
61
+ import { runAfterInteractions } from "../shared/utils/runAfterInteractions";
60
62
  import { applyRawFormatters } from "../shared/formatters/applyRawFormatters";
61
63
  import { isCursorWithinMentionRange, getMentionRangeAtCursor } from "../shared/utils/MentionUtils";
64
+ import { insertMentionTokens } from "../shared/utils/mentionTokens";
62
65
  import { permissionUtil } from "../shared/utils/PermissionUtil";
63
66
  import { CometChatMediaRecorder } from "../shared/views/CometChatMediaRecorder";
64
67
  import { useTheme } from "../theme";
@@ -949,6 +952,19 @@ export const CometChatMessageComposer = React.forwardRef(
949
952
  }
950
953
  });
951
954
 
955
+ // Token text the user TYPED is stored escaped (`&lt;@all:…`); it goes back into the
956
+ // input as the literal `<@all:…` they typed. No `user`, so it never enters mentionMap.
957
+ const typedToken = /&lt;(@(?:uid|all):)/g;
958
+ let typedMatch: RegExpExecArray | null;
959
+ while ((typedMatch = typedToken.exec(rawText)) !== null) {
960
+ edits.push({
961
+ startIndex: typedMatch.index,
962
+ endIndex: typedToken.lastIndex,
963
+ replacement: "<" + typedMatch[1],
964
+ user: null,
965
+ });
966
+ }
967
+
952
968
  // Sort edits by startIndex to apply them in order
953
969
  edits.sort((a: any, b: any) => a.startIndex - b.startIndex);
954
970
 
@@ -966,6 +982,7 @@ export const CometChatMessageComposer = React.forwardRef(
966
982
  edit.replacement +
967
983
  rawText.substring(edit.endIndex);
968
984
  offset += edit.replacement.length - (edit.endIndex - edit.startIndex);
985
+ if (!edit.user) return; // un-escaped typed text, not a mention
969
986
  const rangeKey = `${adjustedStartIndex}_${adjustedStartIndex + edit.replacement.length}`;
970
987
  hashMap.set(rangeKey, edit.user);
971
988
  });
@@ -1268,7 +1285,7 @@ export const CometChatMessageComposer = React.forwardRef(
1268
1285
  }
1269
1286
 
1270
1287
  if (Platform.OS === "ios" && messageInputRef.current) {
1271
- InteractionManager.runAfterInteractions(() => {
1288
+ runAfterInteractions(() => {
1272
1289
  let textToProcess = plainTextInput.current;
1273
1290
  if (typeof inputMessage === 'string' && inputMessage.trim().length > 0) {
1274
1291
  textToProcess = inputMessage;
@@ -1343,7 +1360,7 @@ export const CometChatMessageComposer = React.forwardRef(
1343
1360
 
1344
1361
  // Clear the TextInput on iOS to remove auto-corrected text
1345
1362
  if (Platform.OS === "ios" && messageInputRef.current) {
1346
- InteractionManager.runAfterInteractions(() => {
1363
+ runAfterInteractions(() => {
1347
1364
  try {
1348
1365
  messageInputRef.current?.setNativeProps?.({ text: "" });
1349
1366
  messageInputRef.current?.clear?.();
@@ -2253,24 +2270,9 @@ export const CometChatMessageComposer = React.forwardRef(
2253
2270
  }, 100);
2254
2271
  };
2255
2272
 
2256
- const getRegexString = (str: string) => {
2257
- // Get an array of the entries in the map using the spread operator
2258
- const entries = [...mentionMap.current.entries()].reverse();
2259
-
2260
- let uidInput = str;
2261
-
2262
- // Iterate over the array in reverse order
2263
- entries.forEach(([key, value]) => {
2264
- let [start, end] = key.split("_").map(Number);
2265
-
2266
- let pre = uidInput.substring(0, start);
2267
- let post = uidInput.substring(end);
2268
-
2269
- uidInput = pre + value.underlyingText + post;
2270
- });
2271
-
2272
- return uidInput;
2273
- };
2273
+ // Picked mentions become their tokens; token-looking text the user typed is escaped so it
2274
+ // is stored — and rendered on every platform — as text, not a live mention.
2275
+ const getRegexString = (str: string) => insertMentionTokens(str, mentionMap.current.entries());
2274
2276
 
2275
2277
  const getPlainString = (
2276
2278
  str: string,
@@ -2425,7 +2427,7 @@ export const CometChatMessageComposer = React.forwardRef(
2425
2427
  mentionMap.current = deletionMentionMap;
2426
2428
 
2427
2429
  const firstStart = overlaps[0].start;
2428
- InteractionManager.runAfterInteractions(() => {
2430
+ runAfterInteractions(() => {
2429
2431
  messageInputRef.current?.setNativeProps({
2430
2432
  selection: { start: firstStart, end: firstStart },
2431
2433
  });
@@ -2606,9 +2608,9 @@ export const CometChatMessageComposer = React.forwardRef(
2606
2608
  (item.promptText?.length ?? 0) +
2607
2609
  1; // +1 for the space after mention
2608
2610
 
2609
- // On iOS, use InteractionManager to ensure selection is applied after UI updates
2611
+ // On iOS, defer so selection is applied after UI updates
2610
2612
  if (Platform.OS === "ios") {
2611
- InteractionManager.runAfterInteractions(() => {
2613
+ runAfterInteractions(() => {
2612
2614
  setSelectionPosition({
2613
2615
  start: newCursorPosition,
2614
2616
  end: newCursorPosition,
@@ -2742,8 +2744,13 @@ export const CometChatMessageComposer = React.forwardRef(
2742
2744
  {CustomView && CustomView}
2743
2745
  </Modal>
2744
2746
  <KeyboardAvoidingView
2745
- behavior={Platform.OS === "ios" ? "padding" : "height"}
2746
- keyboardVerticalOffset={Platform.select({ ios: kbOffset })}
2747
+ // "padding" on Android too: with edge-to-edge (always on from RN 0.87 / targetSdk 36) the window no
2748
+ // longer resizes for the keyboard, and "height" squashes this composer instead of lifting it.
2749
+ // When the window does resize (adjustResize), the keyboard overlap is 0 and padding adds nothing.
2750
+ behavior="padding"
2751
+ // The view is measured from its parent, the keyboard from the top of the screen: offset by
2752
+ // what sits above the parent — the top safe area on iOS, the status bar on Android.
2753
+ keyboardVerticalOffset={Platform.select({ ios: kbOffset, android: StatusBar.currentHeight ?? 0 })}
2747
2754
  {...keyboardAvoidingViewProps}
2748
2755
  >
2749
2756
  <View
@@ -2960,7 +2967,7 @@ export const CometChatMessageComposer = React.forwardRef(
2960
2967
  targetPosition = mentionRange.end;
2961
2968
  }
2962
2969
  if (targetPosition !== cursorPos) {
2963
- InteractionManager.runAfterInteractions(() => {
2970
+ runAfterInteractions(() => {
2964
2971
  // Move the cursor IMPERATIVELY — the input is uncontrolled (the `selection`
2965
2972
  // prop was removed). A controlled `selection` prop re-fires onSelectionChange
2966
2973
  // on every re-render, which hard-freezes iOS once the attachment tray adds
@@ -70,7 +70,10 @@ import { ChatConfigurator } from "../shared/framework/ChatConfigurator";
70
70
  import { deepClone, deepMerge } from "../shared/helper/helperFunctions";
71
71
  import { Icon, IconName } from "../shared/icons/Icon";
72
72
  import { CometChatMessageTemplate } from "../shared/modals/CometChatMessageTemplate";
73
- import { getUnixTimestamp, messageStatus } from "../shared/utils/CometChatMessageHelper";
73
+ import { messageStatus } from "../shared/utils/CometChatMessageHelper";
74
+ import { groupMemberAddedRows } from "../shared/utils/groupMemberAddedRows";
75
+ import { selectLinkPreview } from "../shared/utils/linkPreviewSelection";
76
+ import { unescapeTypedMentionTokens } from "../shared/utils/mentionTokens";
74
77
  import { CommonUtils } from "../shared/utils/CommonUtils";
75
78
  import { CometChatBatchMediaContext, BatchMediaResult } from "../shared/utils/batchMediaContext";
76
79
  import { CometChatUIKit } from "../shared/CometChatUiKit/CometChatUIKit";
@@ -965,9 +968,9 @@ export const CometChatMessageList = memo(
965
968
  });
966
969
 
967
970
  const fileIncoming = deepMerge(incomingBubbleStyles, incomingBubbleStyles.fileBubbleStyles ?? {});
968
- if (fileIncoming.containerStyle) fileIncoming.containerStyle.height = undefined;
971
+ if (fileIncoming.containerStyle) Object.assign(fileIncoming.containerStyle, { height: undefined });
969
972
  const fileOutgoing = deepMerge(outgoingBubbleStyles, outgoingBubbleStyles.fileBubbleStyles ?? {});
970
- if (fileOutgoing.containerStyle) fileOutgoing.containerStyle.height = undefined;
973
+ if (fileOutgoing.containerStyle) Object.assign(fileOutgoing.containerStyle, { height: undefined });
971
974
 
972
975
  styleCache.set(MessageTypeConstants.file, {
973
976
  incoming: fileIncoming,
@@ -975,9 +978,9 @@ export const CometChatMessageList = memo(
975
978
  });
976
979
 
977
980
  const audioIncoming = deepMerge(incomingBubbleStyles, incomingBubbleStyles.audioBubbleStyles ?? {});
978
- if (audioIncoming.containerStyle) audioIncoming.containerStyle.height = undefined;
981
+ if (audioIncoming.containerStyle) Object.assign(audioIncoming.containerStyle, { height: undefined });
979
982
  const audioOutgoing = deepMerge(outgoingBubbleStyles, outgoingBubbleStyles.audioBubbleStyles ?? {});
980
- if (audioOutgoing.containerStyle) audioOutgoing.containerStyle.height = undefined;
983
+ if (audioOutgoing.containerStyle) Object.assign(audioOutgoing.containerStyle, { height: undefined });
981
984
 
982
985
  styleCache.set(MessageTypeConstants.audio, {
983
986
  incoming: audioIncoming,
@@ -3581,15 +3584,10 @@ export const CometChatMessageList = memo(
3581
3584
  message["action"] = "banned";
3582
3585
  newMessage(message, false);
3583
3586
  },
3584
- ccGroupMemberAdded: ({ message, usersAdded, userAddedIn }: any) => {
3585
- usersAdded.forEach((user: any) => {
3586
- message["message"] = `${loggedInUser.current?.getName()} added ${user.name}`;
3587
- message["muid"] = String(getUnixTimestamp());
3588
- message["sentAt"] = getUnixTimestamp();
3589
- message["actionOn"] = user;
3590
- message["action"] = "added";
3591
- newMessage(message, false);
3592
- });
3587
+ ccGroupMemberAdded: (event: any) => {
3588
+ groupMemberAddedRows(event, loggedInUser.current?.getName()).forEach((row) =>
3589
+ newMessage(row, false)
3590
+ );
3593
3591
  },
3594
3592
  ccGroupMemberKicked: ({ message }: any) => {
3595
3593
  message["action"] = "kicked";
@@ -3846,7 +3844,8 @@ export const CometChatMessageList = memo(
3846
3844
  }
3847
3845
  if (item.getType() === MessageTypeConstants.text) {
3848
3846
  let linkData = getExtensionData(item, ExtensionConstants.linkPreview);
3849
- if (linkData && linkData.links.length != 0) {
3847
+ // Same choice as the bubble: no card (e.g. every address is in code) → text style.
3848
+ if (selectLinkPreview(linkData?.links, (item as CometChat.TextMessage).getText())) {
3850
3849
  return ExtensionConstants.linkPreview;
3851
3850
  }
3852
3851
  }
@@ -4493,7 +4492,7 @@ export const CometChatMessageList = memo(
4493
4492
  // getPlainString resolves mention tokens but leaves the rich-text wire format alone.
4494
4493
  // copyMessageText puts clean plain text on the clipboard for every other app and keeps
4495
4494
  // the colour in a private representation our own composer restores on paste.
4496
- ClipboardPasteHandler.copyMessageText(getPlainString(item["text"], item), textFormatters);
4495
+ ClipboardPasteHandler.copyMessageText(unescapeTypedMentionTokens(getPlainString(item["text"], item)), textFormatters);
4497
4496
  // Defer modal dismiss to next frame to avoid Fabric race condition
4498
4497
  // where unmounting the Modal while Clipboard is still accessing views
4499
4498
  // causes EXC_BAD_ACCESS (SIGSEGV) at null pointer in mount phase.
@@ -4558,7 +4557,8 @@ export const CometChatMessageList = memo(
4558
4557
  // The app's own token becomes UI Kit markup BEFORE stripping, the same order the pinned
4559
4558
  // panel uses. Without it a consumer's `(#e11d48)text()` reaches the share sheet verbatim.
4560
4559
  let strippedText = stripMarkdown(applyRawFormatters(rawText, textFormatters));
4561
- let textMessage = getPlainString(strippedText, messageObject);
4560
+ // Tokens become names; typed token text (stored escaped) reads as typed.
4561
+ let textMessage = unescapeTypedMentionTokens(getPlainString(strippedText, messageObject));
4562
4562
  let fileUrl = messageObject.getData()["url"];
4563
4563
 
4564
4564
  const getFileName = () => {
@@ -5819,7 +5819,9 @@ export const CometChatMessageList = memo(
5819
5819
  onViewableItemsChanged={handleViewableItemsChanged}
5820
5820
  // Performance optimizations
5821
5821
  windowSize={10}
5822
- removeClippedSubviews={Platform.OS === 'android'}
5822
+ // ENG-40210: keep clipping off. On Android it attaches/detaches rows outside Fabric's
5823
+ // mount queue and crashes (addViewAt IndexOutOfBounds), after a push tap and on plain launch.
5824
+ removeClippedSubviews={false}
5823
5825
  maxToRenderPerBatch={5}
5824
5826
  updateCellsBatchingPeriod={100}
5825
5827
  initialNumToRender={15}
@@ -58,7 +58,8 @@ const dispatchCommand = (
58
58
  ) => {
59
59
  const viewTag = findNodeHandle(ref.current);
60
60
  if (viewTag != null) {
61
- UIManager.dispatchViewManagerCommand(viewTag, command, args);
61
+ // Newer RN typings declare commandID as number only; the native side accepts command names.
62
+ UIManager.dispatchViewManagerCommand(viewTag, command as unknown as number, args);
62
63
  }
63
64
  };
64
65
 
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect, useReducer, useRef, useState, useMemo, JSX } from 'react';
2
- import { View, TextInput, TouchableOpacity, Text, Image, ImageBackground, FlatList, ImageSourcePropType, StyleSheet } from 'react-native';
2
+ import { View, TextInput, TouchableOpacity, Text, Image, ImageBackground, FlatList, ImageSourcePropType, StyleSheet, Platform } from 'react-native';
3
3
  import { CometChat } from '@cometchat/chat-sdk-react-native';
4
4
  import {
5
5
  CometChatAvatar,
@@ -18,6 +18,8 @@ import { deepMerge } from '../shared/helper/helperFunctions';
18
18
  import { DeepPartial } from '../shared/helper/types';
19
19
  import { getCometChatTranslation } from '../shared/resources/CometChatLocalizeNew/LocalizationManager';
20
20
  import { CommonUtils } from '../shared/utils/CommonUtils';
21
+ import { selectLinkPreview } from "../shared/utils/linkPreviewSelection";
22
+ import { unescapeTypedMentionTokens } from "../shared/utils/mentionTokens";
21
23
  import { stripMarkdown } from '../shared/utils/MarkdownUtils';
22
24
  import { CometChatRichTextFormatter } from '../shared/formatters/CometChatRichTextFormatter';
23
25
  import { CometChatTextFormatter } from '../shared/formatters/CometChatTextFormatter';
@@ -62,6 +64,9 @@ const formatPreviewText = (
62
64
  console.log(e)
63
65
  }
64
66
 
67
+ // Tokens are resolved above; typed token text (stored escaped) now reads as typed.
68
+ text = unescapeTypedMentionTokens(text);
69
+
65
70
  return searchRichTextFormatter.getFormattedText(text) ?? text;
66
71
  };
67
72
 
@@ -761,7 +766,7 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
761
766
  const theme = useTheme();
762
767
  const errorHandler = useCometChatErrorHandler(onError);
763
768
  const timeoutIdRef = useRef<any | null>(null);
764
- const searchInputRef = useRef<TextInput>(null);
769
+ const searchInputRef = useRef<React.ComponentRef<typeof TextInput>>(null);
765
770
 
766
771
  // Merge theme styles with provided style overrides
767
772
  const mergedStyles = useMemo(() => {
@@ -1646,8 +1651,8 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
1646
1651
  const metadata = textMessage.getMetadata();
1647
1652
  const linkPreview = metadata && (metadata as any)['@injected'] && (metadata as any)['@injected']['extensions'] && (metadata as any)['@injected']['extensions']['link-preview'];
1648
1653
 
1649
- if (linkPreview && linkPreview.links && linkPreview.links.length > 0) {
1650
- const firstLink = linkPreview.links[0];
1654
+ const firstLink = selectLinkPreview(linkPreview?.links, textMessage.getText());
1655
+ if (firstLink) {
1651
1656
  const thumbnailUrl = firstLink.image || firstLink.favicon;
1652
1657
 
1653
1658
  if (thumbnailUrl) {
@@ -2011,7 +2016,7 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
2011
2016
  initialNumToRender={10}
2012
2017
  maxToRenderPerBatch={10}
2013
2018
  windowSize={10}
2014
- removeClippedSubviews={true}
2019
+ removeClippedSubviews={Platform.OS !== 'android'} // ENG-40210: clipping crashes Fabric on Android
2015
2020
  updateCellsBatchingPeriod={100}
2016
2021
  onEndReached={() => {
2017
2022
  // Load more messages if we're at the end and messages section is visible
@@ -1,6 +1,7 @@
1
1
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
2
  import React, { useEffect, useRef, useState } from "react";
3
- import { ActivityIndicator, View } from "react-native";
3
+ import { ActivityIndicator, LayoutChangeEvent, View } from "react-native";
4
+ import { SafeAreaView } from "react-native-safe-area-context";
4
5
  import { CallingPackage } from "../CallingPackage";
5
6
  import { useTheme } from "../../theme";
6
7
  import { JSX } from "react";
@@ -9,6 +10,9 @@ const { Proximity } = NativeModules;
9
10
 
10
11
  const CometChatCalls = CallingPackage.CometChatCalls;
11
12
 
13
+ /** How long the call area must keep the same size before the Calls SDK is mounted into it. */
14
+ const CALL_AREA_SETTLE_MS = 150;
15
+
12
16
  /**
13
17
  * Props for the CometChatOngoingCall component.
14
18
  *
@@ -88,22 +92,57 @@ export const CometChatOngoingCall = (props: CometChatOngoingCallInterface): JSX.
88
92
  };
89
93
  }, [callToken]);
90
94
 
95
+ // Size of the area the Calls SDK draws into, once it has stopped changing.
96
+ const [callArea, setCallArea] = useState<{ width: number; height: number } | null>(null);
97
+ const settleTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
98
+
99
+ useEffect(() => () => clearTimeout(settleTimer.current), []);
100
+
101
+ // The Calls SDK saves the size of its FIRST layout in a module-level variable and reuses it
102
+ // for every later call in the app session. Mount it only after this area has settled — the
103
+ // SafeAreaView below applies its padding a frame after the first layout — and hand it a box
104
+ // of exactly that size, so the size it saves is the real one.
105
+ const onCallAreaLayout = (e: LayoutChangeEvent) => {
106
+ const { width, height } = e.nativeEvent.layout;
107
+ clearTimeout(settleTimer.current);
108
+ settleTimer.current = setTimeout(() => {
109
+ setCallArea((prev) =>
110
+ prev && prev.width === width && prev.height === height ? prev : { width, height }
111
+ );
112
+ }, CALL_AREA_SETTLE_MS);
113
+ };
114
+
115
+ // Keep the call inside the safe area: on RN 0.87 Android is edge-to-edge, and a full-screen
116
+ // parent (the accepted CometChatIncomingCall, or the Modal of CometChatOutgoingCall) reaches
117
+ // under the system bars. The native SafeAreaView pads only for the insets it overlaps.
91
118
  return (
92
- <View style={[{ height: "100%", width: "100%", position: "relative" }]}>
93
- {(callSettings.current && callToken && (
94
- <CometChatCalls.Component callSettings={callSettings.current} callToken={callToken} />
95
- )) || (
96
- <View
97
- style={{
98
- justifyContent: "center",
99
- alignItems: "center",
100
- height: "100%",
101
- backgroundColor: "transparent",
102
- }}
103
- >
104
- <ActivityIndicator size={"large"} color={theme.color.primary} />
105
- </View>
106
- )}
107
- </View>
119
+ <SafeAreaView
120
+ edges={["top", "bottom"]}
121
+ style={{
122
+ height: "100%",
123
+ width: "100%",
124
+ position: "relative",
125
+ backgroundColor: theme.color.background1,
126
+ }}
127
+ >
128
+ <View style={{ flex: 1 }} onLayout={onCallAreaLayout}>
129
+ {(callSettings.current && callToken && callArea && (
130
+ <View style={{ width: callArea.width, height: callArea.height }}>
131
+ <CometChatCalls.Component callSettings={callSettings.current} callToken={callToken} />
132
+ </View>
133
+ )) || (
134
+ <View
135
+ style={{
136
+ justifyContent: "center",
137
+ alignItems: "center",
138
+ height: "100%",
139
+ backgroundColor: "transparent",
140
+ }}
141
+ >
142
+ <ActivityIndicator size={"large"} color={theme.color.primary} />
143
+ </View>
144
+ )}
145
+ </View>
146
+ </SafeAreaView>
108
147
  );
109
148
  };
@@ -281,13 +281,16 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
281
281
  visible={isModalVisible}
282
282
  onRequestClose={handleModalClose}
283
283
  >
284
- <SafeAreaView style={{ flex: 1 }}>
285
- {isCallConnected ? (
286
- <CometChatOngoingCall
287
- sessionID={callSessionId.current!}
288
- callSettingsBuilder={callSettings.current!}
289
- />
290
- ) : (
284
+ {/* The connected call handles its own safe area. Rendered outside the SafeAreaView below
285
+ so it gets the same geometry as an accepted incoming call: the Calls SDK keeps the size
286
+ of the first call in the session, so both directions must lay out the same way. */}
287
+ {isCallConnected ? (
288
+ <CometChatOngoingCall
289
+ sessionID={callSessionId.current!}
290
+ callSettingsBuilder={callSettings.current!}
291
+ />
292
+ ) : (
293
+ <SafeAreaView style={{ flex: 1 }}>
291
294
  <View style={outgoingCallStyle.containerStyle}>
292
295
  {TitleView ? (
293
296
  TitleView(call)
@@ -331,8 +334,8 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
331
334
  </TouchableOpacity>
332
335
  )}
333
336
  </View>
334
- )}
335
- </SafeAreaView>
337
+ </SafeAreaView>
338
+ )}
336
339
  </Modal>
337
340
  );
338
341
  };
@@ -109,7 +109,7 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
109
109
  if (onPress) {
110
110
  onPress();
111
111
  } else {
112
- const opened = await Linking.openURL(link);
112
+ const opened: unknown = await Linking.openURL(link);
113
113
  if (!opened) {
114
114
  Alert.alert(t("SOMETHING_WRONG"));
115
115
  }
@@ -212,15 +212,18 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
212
212
  </Text>
213
213
  </View>
214
214
  </View>
215
- <View
216
- style={{
217
- paddingVertical: theme.spacing.padding.p3,
218
- paddingHorizontal: style?.bodyStyle?.containerStyle.padding,
219
- flexShrink: 0,
220
- }}
221
- >
222
- {ChildView && <ChildView />}
223
- </View>
215
+ {/* Only the card that carries the message text gets this padded row; the others would show an empty band. */}
216
+ {ChildView && (
217
+ <View
218
+ style={{
219
+ paddingVertical: theme.spacing.padding.p3,
220
+ paddingHorizontal: style?.bodyStyle?.containerStyle.padding,
221
+ flexShrink: 0,
222
+ }}
223
+ >
224
+ <ChildView />
225
+ </View>
226
+ )}
224
227
  </View>
225
228
  );
226
229
  };