@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
@@ -28,6 +28,7 @@ import Video from 'react-native-video';
28
28
  import { Icon } from '../../icons/Icon';
29
29
  import { useTheme } from '../../../theme';
30
30
  import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
31
+ import { ReactNativeZoomableView } from '../../libs/ImageZoom';
31
32
  import { clampIndex, isImageMime, isVideoMime, nextIndexForSwipe } from './mediaViewerUtils';
32
33
 
33
34
  /** Default: an item is previewable if it's an image or a video. A per-kind bubble (ImagesBubble /
@@ -108,7 +109,14 @@ export const CometChatMediaViewer = ({
108
109
  mediaItemsRef.current = mediaItems;
109
110
  }, [mediaItems]);
110
111
 
112
+ // While an image is zoomed in, drags pan the image instead of paging.
113
+ const zoomedRef = useRef(false);
114
+ const onZoomChange = (_e: unknown, _gs: unknown, zoom: { zoomLevel: number }) => {
115
+ zoomedRef.current = zoom.zoomLevel > 1.01;
116
+ };
117
+
111
118
  const goTo = (idx: number) => {
119
+ zoomedRef.current = false;
112
120
  const clamped = clampIndex(idx, mediaItemsRef.current.length);
113
121
  currentIndexRef.current = clamped;
114
122
  setCurrentIndex(clamped);
@@ -122,7 +130,9 @@ export const CometChatMediaViewer = ({
122
130
  PanResponder.create({
123
131
  // Swipe-to-page only on IMAGE pages. On video pages the native controls own all gestures
124
132
  // (scrubbing is horizontal too), so we don't hijack them — page via the on-screen arrows (B3).
125
- onMoveShouldSetPanResponder: (_, gs) => {
133
+ onMoveShouldSetPanResponder: (evt, gs) => {
134
+ // Never page during a pinch or while zoomed in.
135
+ if (zoomedRef.current || evt.nativeEvent.touches.length > 1) return false;
126
136
  const it = mediaItemsRef.current[currentIndexRef.current];
127
137
  const onVideo = it ? isVideoMime(it.getMimeType?.() ?? '') : false;
128
138
  return !onVideo && Math.abs(gs.dx) > 10 && Math.abs(gs.dx) > Math.abs(gs.dy);
@@ -288,13 +298,23 @@ export const CometChatMediaViewer = ({
288
298
  )}
289
299
  </View>
290
300
  ) : (
291
- <Image
292
- source={{ uri: current.getUrl() }}
293
- style={styles.fullMedia}
294
- resizeMode="contain"
295
- onLoad={() => setMediaLoaded(true)}
296
- onError={() => { setMediaError(true); setMediaLoaded(true); }}
297
- />
301
+ // Pinch / double-tap to zoom. `key` resets the zoom on every page change. At 1x the zoom view
302
+ // hands a horizontal drag to the pager's PanResponder above; zoomed in, it keeps it to pan.
303
+ <ReactNativeZoomableView
304
+ key={currentIndex}
305
+ disablePanOnInitialZoom
306
+ onZoomAfter={onZoomChange}
307
+ onTransform={(z: { zoomLevel: number }) => onZoomChange(null, null, z)}
308
+ onPanResponderTerminationRequest={() => !zoomedRef.current}
309
+ >
310
+ <Image
311
+ source={{ uri: current.getUrl() }}
312
+ style={styles.fullMedia}
313
+ resizeMode="contain"
314
+ onLoad={() => setMediaLoaded(true)}
315
+ onError={() => { setMediaError(true); setMediaLoaded(true); }}
316
+ />
317
+ </ReactNativeZoomableView>
298
318
  )}
299
319
  </View>
300
320
 
@@ -1,9 +1,8 @@
1
1
  import React, { JSX, RefObject } from "react";
2
2
  import {
3
3
  ColorValue,
4
- NativeSyntheticEvent,
5
4
  TextInput,
6
- TextInputSelectionChangeEventData,
5
+ TextInputProps,
7
6
  TextStyle,
8
7
  View,
9
8
  ViewStyle,
@@ -79,9 +78,9 @@ export interface CometChatMessageInputInterface {
79
78
  /**
80
79
  * Callback for when the text selection changes.
81
80
  *
82
- * @param {NativeSyntheticEvent<TextInputSelectionChangeEventData>} event - The selection change event.
81
+ * @param {NativeSyntheticEvent} event - The selection change event.
83
82
  */
84
- onSelectionChange?: (e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => void;
83
+ onSelectionChange?: TextInputProps["onSelectionChange"];
85
84
  /**
86
85
  * Reference for the TextInput component.
87
86
  *
@@ -9,6 +9,7 @@ import {
9
9
  LayoutChangeEvent,
10
10
  TextLayoutEvent,
11
11
  Platform,
12
+ StyleSheet,
12
13
  } from "react-native";
13
14
  import {
14
15
  CometChatMentionsFormatter,
@@ -48,6 +49,32 @@ export const CometChatTextBubble = (props: CometChatTextBubbleInterface) => {
48
49
  );
49
50
  };
50
51
 
52
+ const FONT_METRIC_KEYS = ["fontWeight", "fontStyle", "fontFamily", "fontSize"] as const;
53
+
54
+ /** True when some element in the tree sets its own font (bold, italic, code, a mention chip…). */
55
+ function hasNestedFontStyle(node: React.ReactNode): boolean {
56
+ if (Array.isArray(node)) return node.some(hasNestedFontStyle);
57
+ if (!React.isValidElement(node)) return false;
58
+ const props: any = node.props;
59
+ const style = StyleSheet.flatten(props.style) as TextStyle | undefined;
60
+ if (style && FONT_METRIC_KEYS.some((key) => style[key] != null)) return true;
61
+ return hasNestedFontStyle(props.children);
62
+ }
63
+
64
+ /**
65
+ * On Android a lineHeight makes the text a wrapping (non-boring) layout, and with nested font
66
+ * styles React Native sizes the Text a fraction narrower than the styled text draws: the last
67
+ * word of `**Tom & Jerry**` wraps onto a line the bubble has no room for and "Jerry" disappears.
68
+ * Such content uses the font's own line spacing instead; plain text keeps the theme's lineHeight.
69
+ */
70
+ function withMeasurableLineHeight(
71
+ textStyle: StyleProp<TextStyle> | undefined,
72
+ content: React.ReactNode
73
+ ): StyleProp<TextStyle> | undefined {
74
+ if (Platform.OS !== "android" || !hasNestedFontStyle(content)) return textStyle;
75
+ return [textStyle, { lineHeight: undefined }];
76
+ }
77
+
51
78
  /**
52
79
  * Recursively apply textStyle to all Text elements within a tree.
53
80
  * Needed for View-based content (blockquotes, lists) where Text nodes
@@ -112,6 +139,11 @@ export const CometChatTextBubbleText = (
112
139
  return finalText as string | JSX.Element;
113
140
  }, [text, textFormatters]);
114
141
 
142
+ const contentTextStyle = useMemo(
143
+ () => withMeasurableLineHeight(textStyle, formattedText),
144
+ [textStyle, formattedText]
145
+ );
146
+
115
147
  // Reset state only when text actually changes
116
148
  useLayoutEffect(() => {
117
149
  if (lastTextRef.current !== text) {
@@ -192,9 +224,9 @@ export const CometChatTextBubbleText = (
192
224
  if (!viewChildren) return null;
193
225
  return viewChildren.map((child) => {
194
226
  if (!React.isValidElement(child)) return child;
195
- return applyTextStyleDeep(child as React.ReactElement<any>, textStyle);
227
+ return applyTextStyleDeep(child as React.ReactElement<any>, contentTextStyle);
196
228
  });
197
- }, [viewChildren, textStyle]);
229
+ }, [viewChildren, contentTextStyle]);
198
230
 
199
231
  // Only measure string content via onTextLayout — View-based uses child count instead
200
232
  const needsMeasurement = containerWidth !== null && !isViewBased && !measuredCacheRef.current[hiddenTextKey];
@@ -207,7 +239,7 @@ export const CometChatTextBubbleText = (
207
239
  key={hiddenTextKey}
208
240
  style={[
209
241
  { position: "absolute", left: 0, top: -10000, width: containerWidth!, opacity: 0 },
210
- textStyle as any,
242
+ contentTextStyle as any,
211
243
  ]}
212
244
  onTextLayout={onMeasuredTextLayout}
213
245
  accessible={false}
@@ -224,7 +256,7 @@ export const CometChatTextBubbleText = (
224
256
  </View>
225
257
  ) : (
226
258
  <Text
227
- style={textStyle}
259
+ style={contentTextStyle}
228
260
  numberOfLines={isExpanded ? undefined : collapseLines}
229
261
  ellipsizeMode='tail'
230
262
  >
@@ -115,7 +115,8 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => {
115
115
  };
116
116
 
117
117
  useEffect(() => {
118
- statusListener = eventEmitter.addListener("status", (data) => {
118
+ statusListener = eventEmitter.addListener("status", (event) => {
119
+ const data = event as { url?: string; state?: string };
119
120
  if (data["url"] == videoUrl && data["state"] == "downloading") {
120
121
  setOpening(true);
121
122
  }
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useMemo, useState } from 'react';
1
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { Image, ImageStyle, StyleProp, StyleSheet, Text, TextStyle, TouchableOpacity, View, ViewStyle } from 'react-native';
3
3
  import { CometChat } from '@cometchat/chat-sdk-react-native';
4
4
  import { CometChatTheme } from '../../../theme/type';
@@ -8,10 +8,10 @@ import { deepMerge } from '../../helper/helperFunctions';
8
8
  import { Icon } from '../../icons/Icon';
9
9
  import { getExtensionData } from '../../../extensions/ExtensionModerator';
10
10
  import { CometChatUIKit } from '../../CometChatUiKit';
11
- import { CometChatMessageEvents } from '../../events/CometChatMessageEvents';
12
11
  import { CometChatMediaViewer } from '../CometChatMediaViewer';
13
12
  import { CometChatCaptionText } from '../CometChatCaptionText';
14
13
  import { isVideoMime } from '../CometChatMediaViewer/mediaViewerUtils';
14
+ import { useLocalVideoThumbnail } from '../../utils/videoThumbnail';
15
15
  import { AdditionalParams } from "../../base/Types";
16
16
 
17
17
  // ---------------------------------------------------------------------------
@@ -54,6 +54,8 @@ interface VideoCellProps {
54
54
  testID?: string;
55
55
  overflowCount?: number;
56
56
  thumbnailUrl?: string;
57
+ /** Retry a failed server thumbnail — only for a just-sent message, whose thumbnail may not exist yet. */
58
+ retryThumbnail?: boolean;
57
59
  cellStyle?: StyleProp<ViewStyle>;
58
60
  playButtonStyle?: StyleProp<ViewStyle>;
59
61
  playIconStyle?: ImageStyle;
@@ -63,6 +65,14 @@ interface VideoCellProps {
63
65
  overflowTextStyle?: TextStyle;
64
66
  }
65
67
 
68
+ // The thumbnail-generation extension puts the thumbnail URL on the message at send time but creates the
69
+ // image a few seconds later, so an early load of it fails. The sender's own device shows its local
70
+ // first-frame thumbnail meanwhile — only when that URL exists, so the dashboard setting still decides.
71
+ // Anyone else (another of the sender's devices, a very fast receiver) re-checks the URL with back-off.
72
+ // Older messages never retry — their thumbnail exists or never will.
73
+ const THUMBNAIL_RETRY_DELAYS_MS = [1000, 2000, 4000, 8000, 15000];
74
+ const THUMBNAIL_RETRY_WINDOW_SECS = 120;
75
+
66
76
  const VideoCell = ({
67
77
  attachment,
68
78
  aspectRatio = 1,
@@ -71,6 +81,7 @@ const VideoCell = ({
71
81
  testID,
72
82
  overflowCount,
73
83
  thumbnailUrl,
84
+ retryThumbnail,
74
85
  cellStyle,
75
86
  playButtonStyle,
76
87
  playIconStyle,
@@ -81,6 +92,29 @@ const VideoCell = ({
81
92
  }: VideoCellProps) => {
82
93
  const theme = useTheme();
83
94
  const duration = getDuration(attachment);
95
+ // Only stand in for a server thumbnail that is on its way: no `thumbnailUrl` means the Thumbnail
96
+ // Generation extension is off in the dashboard (or failed for this file), and then no thumbnail shows.
97
+ const localThumbnail = useLocalVideoThumbnail({ remoteUrl: thumbnailUrl ? attachment.getUrl?.() : undefined });
98
+ // Bumped once a retried thumbnail is fetched, to remount the <Image> onto the now-cached file.
99
+ const [thumbnailKey, setThumbnailKey] = useState(0);
100
+ const retry = useRef<{ attempt: number; timer?: ReturnType<typeof setTimeout> }>({ attempt: 0 });
101
+ useEffect(() => {
102
+ retry.current = { attempt: 0 };
103
+ return () => clearTimeout(retry.current.timer);
104
+ }, [thumbnailUrl]);
105
+ const onThumbnailError = () => {
106
+ if (!retryThumbnail || localThumbnail || !thumbnailUrl) return;
107
+ const check = () => {
108
+ Image.prefetch(thumbnailUrl)
109
+ .then((ok) => (ok ? setThumbnailKey((k) => k + 1) : scheduleNext()))
110
+ .catch(scheduleNext);
111
+ };
112
+ const scheduleNext = () => {
113
+ const delay = THUMBNAIL_RETRY_DELAYS_MS[retry.current.attempt++];
114
+ if (delay != null) retry.current.timer = setTimeout(check, delay);
115
+ };
116
+ scheduleNext();
117
+ };
84
118
  // A VIDEO bubble previews videos only. Anything else (image / audio / file) is unsupported here →
85
119
  // a "no preview" placeholder cell (tapping it opens the "No preview available" fullscreen). Gate on a
86
120
  // KNOWN non-video kind (a proper "type/subtype" mime that isn't video/*): an empty / bare-extension
@@ -108,7 +142,7 @@ const VideoCell = ({
108
142
  >
109
143
  <View
110
144
  testID="grid-cell-nopreview"
111
- style={[StyleSheet.absoluteFillObject, borderStyle, { backgroundColor: theme.color.neutral200, justifyContent: 'center', alignItems: 'center' }]}
145
+ style={[StyleSheet.absoluteFill, borderStyle, { backgroundColor: theme.color.neutral200, justifyContent: 'center', alignItems: 'center' }]}
112
146
  >
113
147
  <Icon name="unknown-file-type" size={theme.spacing.spacing.s12} />
114
148
  </View>
@@ -116,7 +150,7 @@ const VideoCell = ({
116
150
  <View
117
151
  testID="grid-overflow"
118
152
  pointerEvents="none"
119
- style={[StyleSheet.absoluteFillObject, { backgroundColor: theme.color.mediaOverlay, justifyContent: 'center', alignItems: 'center' }, overflowOverlayStyle]}
153
+ style={[StyleSheet.absoluteFill, { backgroundColor: theme.color.mediaOverlay, justifyContent: 'center', alignItems: 'center' }, overflowOverlayStyle]}
120
154
  >
121
155
  <Text style={[{ ...theme.typography.heading1.bold, color: theme.color.staticWhite, letterSpacing: -0.5 }, overflowTextStyle]}>{`+${overflowCount}`}</Text>
122
156
  </View>
@@ -134,13 +168,24 @@ const VideoCell = ({
134
168
  accessibilityRole="button"
135
169
  accessibilityLabel={attachment.getName()}
136
170
  >
137
- <View style={[StyleSheet.absoluteFillObject, { backgroundColor: theme.color.mediaScrim }, borderStyle]} />
171
+ <View style={[StyleSheet.absoluteFill, { backgroundColor: theme.color.mediaScrim }, borderStyle]} />
172
+ {localThumbnail ? (
173
+ <Image source={{ uri: localThumbnail }} style={[StyleSheet.absoluteFill, borderStyle]} resizeMode="cover" />
174
+ ) : null}
175
+ {/* The server thumbnail draws over the local one once it loads; until then (or if it fails)
176
+ the local thumbnail shows through. */}
138
177
  {thumbnailUrl ? (
139
- <Image source={{ uri: thumbnailUrl }} style={[StyleSheet.absoluteFillObject, borderStyle]} resizeMode="cover" />
178
+ <Image
179
+ key={thumbnailKey}
180
+ source={{ uri: thumbnailUrl }}
181
+ style={[StyleSheet.absoluteFill, borderStyle]}
182
+ resizeMode="cover"
183
+ onError={onThumbnailError}
184
+ />
140
185
  ) : null}
141
186
 
142
187
  {!overflowCount && (
143
- <View pointerEvents="none" style={StyleSheet.absoluteFillObject}>
188
+ <View pointerEvents="none" style={StyleSheet.absoluteFill}>
144
189
  <View style={styles.centerFill}>
145
190
  <View
146
191
  style={[{
@@ -182,7 +227,7 @@ const VideoCell = ({
182
227
  <View
183
228
  testID="grid-overflow"
184
229
  pointerEvents="none"
185
- style={[StyleSheet.absoluteFillObject, { backgroundColor: theme.color.mediaOverlay, justifyContent: 'center', alignItems: 'center' }, overflowOverlayStyle]}
230
+ style={[StyleSheet.absoluteFill, { backgroundColor: theme.color.mediaOverlay, justifyContent: 'center', alignItems: 'center' }, overflowOverlayStyle]}
186
231
  >
187
232
  <Text style={[{ ...theme.typography.heading1.bold, color: theme.color.staticWhite, letterSpacing: -0.5 }, overflowTextStyle]}>{`+${overflowCount}`}</Text>
188
233
  </View>
@@ -196,6 +241,7 @@ const VideoCell = ({
196
241
  const VideoGrid = ({
197
242
  attachments,
198
243
  thumbnailUrls,
244
+ retryThumbnail,
199
245
  onAttachmentPress,
200
246
  containerStyle,
201
247
  cellStyle,
@@ -208,6 +254,7 @@ const VideoGrid = ({
208
254
  }: {
209
255
  attachments: CometChat.Attachment[];
210
256
  thumbnailUrls?: string[];
257
+ retryThumbnail?: boolean;
211
258
  onAttachmentPress: (attachment: CometChat.Attachment, index: number) => void;
212
259
  containerStyle?: StyleProp<ViewStyle>;
213
260
  cellStyle?: StyleProp<ViewStyle>;
@@ -232,6 +279,7 @@ const VideoGrid = ({
232
279
  radii={radii}
233
280
  overflowCount={overflowCount}
234
281
  thumbnailUrl={thumbnailUrls?.[i]}
282
+ retryThumbnail={retryThumbnail}
235
283
  onPress={() => onAttachmentPress(attachments[i], i)}
236
284
  cellStyle={cellStyle}
237
285
  playButtonStyle={playButtonStyle}
@@ -354,28 +402,6 @@ export function CometChatVideosBubble({
354
402
  });
355
403
  }, [message, allAttachments]);
356
404
 
357
- // §8.7 — refresh the local copy when the server edits the message in (async thumbnails).
358
- useEffect(() => {
359
- const listenerId = `VideosBubble_${message.getId?.() ?? message.getMuid?.() ?? Date.now()}`;
360
- CometChatMessageEvents.addListener(
361
- CometChatMessageEvents.messageEdited,
362
- listenerId,
363
- (edited: CometChat.BaseMessage) => {
364
- const editedId = edited.getId?.();
365
- const editedMuid = edited.getMuid?.();
366
- const myId = message.getId?.();
367
- const myMuid = message.getMuid?.();
368
- if (
369
- edited instanceof CometChat.MediaMessage &&
370
- ((myId && editedId && myId === editedId) || (myMuid && editedMuid && myMuid === editedMuid))
371
- ) {
372
- setMessage(edited);
373
- }
374
- }
375
- );
376
- return () => CometChatMessageEvents.removeListener(CometChatMessageEvents.messageEdited, listenerId);
377
- }, []);
378
-
379
405
  useEffect(() => {
380
406
  setMessage(initialMessage);
381
407
  }, [initialMessage]);
@@ -387,6 +413,7 @@ export function CometChatVideosBubble({
387
413
  <VideoGrid
388
414
  attachments={allAttachments}
389
415
  thumbnailUrls={thumbnailUrls}
416
+ retryThumbnail={Date.now() / 1000 - (message.getSentAt?.() ?? 0) < THUMBNAIL_RETRY_WINDOW_SECS}
390
417
  containerStyle={s.containerStyle}
391
418
  cellStyle={s.cellStyle}
392
419
  playButtonStyle={s.playButtonStyle}