@cometchat/chat-uikit-react-native 5.3.10 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/reactnativecometchatuikit/CometChatClipboardModule.kt +52 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +95 -8
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +300 -7
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +2 -1
- package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +85 -47
- package/ios/CometChatClipboardModule.m +11 -0
- package/ios/CometChatClipboardModule.swift +41 -0
- package/ios/FileManager.m +201 -39
- package/ios/RichTextEditorView.swift +367 -8
- package/ios/RichTextEditorViewManager.m +1 -0
- package/ios/SoundPlayer.m +18 -6
- package/package.json +10 -7
- package/react-native-cometchat-ui-kit.podspec +1 -0
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +692 -107
- package/src/CometChatConversations/CometChatConversations.tsx +19 -6
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +649 -49
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +23 -4
- package/src/CometChatMessageList/CometChatMessageList.tsx +463 -54
- package/src/CometChatMessageList/SEARCH_NAV_SLOWNESS_FINDINGS_AND_FIX.md +313 -0
- package/src/CometChatMessageList/components/MessageListItem.tsx +30 -17
- package/src/CometChatMessageList/style.ts +33 -5
- package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +13 -0
- package/src/CometChatRichTextEditor/index.tsx +25 -0
- package/src/CometChatSearch/CometChatSearch.tsx +296 -154
- package/src/calls/CallingExtension.tsx +19 -13
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +20 -1
- package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +20 -9
- package/src/index.ts +39 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +40 -34
- package/src/shared/base/Types.ts +3 -0
- package/src/shared/constants/UIKitConstants.ts +15 -1
- package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +3 -2
- package/src/shared/framework/DataSource.ts +14 -4
- package/src/shared/framework/DataSourceDecorator.tsx +17 -8
- package/src/shared/framework/MessageDataSource.tsx +307 -60
- package/src/shared/helper/useToast.tsx +29 -0
- package/src/shared/icons/components/audio-file-type.tsx +11 -22
- package/src/shared/icons/components/document-file-type.tsx +11 -24
- package/src/shared/icons/components/image-file-type.tsx +12 -21
- package/src/shared/icons/components/link-file-type.tsx +25 -0
- package/src/shared/icons/components/pdf-file-type.tsx +11 -22
- package/src/shared/icons/components/presentation-file-type.tsx +11 -24
- package/src/shared/icons/components/spreadsheet-file-type.tsx +11 -24
- package/src/shared/icons/components/text-file-type.tsx +11 -21
- package/src/shared/icons/components/unknown-file-type.tsx +21 -25
- package/src/shared/icons/components/video-file-type.tsx +11 -24
- package/src/shared/icons/components/zip-file-type.tsx +11 -24
- package/src/shared/icons/icon-mapping.tsx +2 -0
- package/src/shared/index.ts +28 -0
- package/src/shared/modals/AttachmentPickerConfiguration.ts +13 -0
- package/src/shared/modals/SelectedAttachment.ts +65 -0
- package/src/shared/modals/UploadState.ts +10 -0
- package/src/shared/modals/index.ts +4 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +42 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +42 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +43 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +43 -2
- package/src/shared/services/UploadQueueService.ts +145 -0
- package/src/shared/services/index.ts +2 -0
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +44 -19
- package/src/shared/utils/MessageUtils.tsx +13 -4
- package/src/shared/utils/attachmentLimits.ts +156 -0
- package/src/shared/utils/audioPlaybackCoordinator.ts +28 -0
- package/src/shared/utils/batchMediaContext.tsx +30 -0
- package/src/shared/utils/conversationUtils.ts +26 -4
- package/src/shared/utils/elementType.tsx +38 -0
- package/src/shared/utils/groupAttachments.ts +93 -0
- package/src/shared/utils/index.ts +8 -0
- package/src/shared/utils/openMultiFileChooser.ts +123 -0
- package/src/shared/utils/partitionAttachmentsByKind.ts +44 -0
- package/src/shared/views/ClipboardPasteHandler/ClipboardPasteHandler.ts +28 -0
- package/src/shared/views/ClipboardPasteHandler/NativeCometChatClipboardModule.ts +16 -0
- package/src/shared/views/ClipboardPasteHandler/index.ts +2 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -0
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +32 -0
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.tsx +90 -0
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +276 -0
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +827 -0
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTray.tsx +110 -0
- package/src/shared/views/CometChatAttachmentPreview/StagedVideoDurationProbe.tsx +53 -0
- package/src/shared/views/CometChatAttachmentPreview/index.ts +8 -0
- package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +305 -0
- package/src/shared/views/CometChatAttachmentViewer/index.ts +2 -0
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +71 -74
- package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +587 -0
- package/src/shared/views/CometChatAudiosBubble/index.ts +2 -0
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +31 -20
- package/src/shared/views/CometChatCaptionText/CometChatCaptionText.tsx +182 -0
- package/src/shared/views/CometChatCaptionText/index.ts +2 -0
- package/src/shared/views/CometChatComposerErrorBanner.tsx +83 -0
- package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +141 -0
- package/src/shared/views/CometChatConversationStarter/index.ts +2 -0
- package/src/shared/views/CometChatConversationSummary/CometChatConversationSummary.tsx +155 -0
- package/src/shared/views/CometChatConversationSummary/index.ts +2 -0
- package/src/shared/views/CometChatFileBubble/style.ts +6 -4
- package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +316 -0
- package/src/shared/views/CometChatFilesBubble/index.ts +2 -0
- package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +323 -0
- package/src/shared/views/CometChatImagesBubble/index.ts +2 -0
- package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +425 -0
- package/src/shared/views/CometChatMediaViewer/index.ts +2 -0
- package/src/shared/views/CometChatMediaViewer/mediaViewerUtils.ts +30 -0
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +14 -4
- package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +1 -0
- package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +172 -0
- package/src/shared/views/CometChatSmartReplies/index.ts +2 -0
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +4 -3
- package/src/shared/views/CometChatVideoBubble/style.ts +3 -3
- package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +441 -0
- package/src/shared/views/CometChatVideosBubble/index.ts +2 -0
- package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +78 -0
- package/src/shared/views/CometChatVoiceNoteBubble/index.ts +2 -0
- package/src/shared/views/index.ts +37 -1
- package/src/theme/CometChatThemeHelper.ts +8 -0
- package/src/theme/default/color/dark.ts +9 -0
- package/src/theme/default/color/light.ts +10 -0
- package/src/theme/type.ts +73 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useReducer, useRef, useState, useMemo } from 'react';
|
|
2
|
-
import { View, TextInput, TouchableOpacity, Text, Image, ImageBackground, FlatList, ImageSourcePropType } from 'react-native';
|
|
2
|
+
import { View, TextInput, TouchableOpacity, Text, Image, ImageBackground, FlatList, ImageSourcePropType, StyleSheet } from 'react-native';
|
|
3
3
|
import { CometChat } from '@cometchat/chat-sdk-react-native';
|
|
4
4
|
import {
|
|
5
5
|
CometChatAvatar,
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
useTheme
|
|
10
10
|
} from '@cometchat/chat-uikit-react-native';
|
|
11
11
|
import { Icon } from '../shared/icons/Icon';
|
|
12
|
+
import Svg, { G, Path, Text as SvgText } from 'react-native-svg';
|
|
12
13
|
import { GroupTypeConstants, ReceiverTypeConstants, MessageCategoryConstants, MessageTypeConstants } from '@cometchat/chat-uikit-react-native/src/shared/constants/UIKitConstants';
|
|
13
14
|
import { CometChatSearchScope, CometChatSearchFilter, States } from './SearchConstants';
|
|
14
15
|
import { Skeleton } from './Skeleton';
|
|
@@ -356,6 +357,45 @@ const LinkFallbackIcon = ({ mergedStyles, theme }: { mergedStyles: any; theme: a
|
|
|
356
357
|
</View>
|
|
357
358
|
);
|
|
358
359
|
|
|
360
|
+
// Document/file leading icon used for the Documents filter results — a fanned three-sheet stack
|
|
361
|
+
// with a primary front page labelled "FILE". Scoped to search (not the global document-file-type icon).
|
|
362
|
+
const DocumentTypeIcon = ({ width = 48, height = 48 }: { width?: number; height?: number }) => (
|
|
363
|
+
<Svg width={width} height={height} viewBox='0 0 46 46' fill='none'>
|
|
364
|
+
{/* Sheet fanned left */}
|
|
365
|
+
<G transform='rotate(-11 23 38) translate(7 5) scale(0.40625 0.4125)'>
|
|
366
|
+
<Path
|
|
367
|
+
d='M4 8C4 3.58 7.58 0 12 0H52C56.42 0 60 3.58 60 8V72C60 76.42 56.42 80 52 80H12C7.58 80 4 76.42 4 72V8Z'
|
|
368
|
+
fill='#F1F1F1'
|
|
369
|
+
stroke='#E4E4E4'
|
|
370
|
+
strokeWidth={1}
|
|
371
|
+
/>
|
|
372
|
+
</G>
|
|
373
|
+
{/* Sheet fanned right */}
|
|
374
|
+
<G transform='rotate(9 23 38) translate(13 5) scale(0.40625 0.4125)'>
|
|
375
|
+
<Path
|
|
376
|
+
d='M4 8C4 3.58 7.58 0 12 0H52C56.42 0 60 3.58 60 8V72C60 76.42 56.42 80 52 80H12C7.58 80 4 76.42 4 72V8Z'
|
|
377
|
+
fill='#F7F7F7'
|
|
378
|
+
stroke='#E4E4E4'
|
|
379
|
+
strokeWidth={1}
|
|
380
|
+
/>
|
|
381
|
+
</G>
|
|
382
|
+
{/* Front document (primary) with folded corner + FILE label */}
|
|
383
|
+
<G transform='translate(3 3) scale(0.5)'>
|
|
384
|
+
<Path
|
|
385
|
+
d='M50.332 6.6665L66.999 23.3335V11.9595C66.9991 11.9728 67 11.9862 67 11.9995V67.9995C67 70.9449 64.6124 73.3333 61.667 73.3335H18.333C15.3876 73.3333 13 70.9449 13 67.9995V11.9995C13.0002 9.05425 15.3877 6.66668 18.333 6.6665H50.332Z'
|
|
386
|
+
fill='#6852D6'
|
|
387
|
+
/>
|
|
388
|
+
<Path
|
|
389
|
+
d='M55.6667 23.332L67 23.332L50.3333 6.66536L50.3333 17.9987C50.3333 20.9442 52.7212 23.332 55.6667 23.332Z'
|
|
390
|
+
fill='#ACA0E8'
|
|
391
|
+
/>
|
|
392
|
+
<SvgText x={40} y={59} textAnchor='middle' fontSize={15} fontWeight='700' fill='#FFFFFF'>
|
|
393
|
+
FILE
|
|
394
|
+
</SvgText>
|
|
395
|
+
</G>
|
|
396
|
+
</Svg>
|
|
397
|
+
);
|
|
398
|
+
|
|
359
399
|
const LinkPreviewImage: React.FC<LinkPreviewImageProps> = ({ uri, fallbackUri, mergedStyles, theme }) => {
|
|
360
400
|
const [imageError, setImageError] = useState(false);
|
|
361
401
|
const [fallbackError, setFallbackError] = useState(false);
|
|
@@ -376,47 +416,77 @@ const LinkPreviewImage: React.FC<LinkPreviewImageProps> = ({ uri, fallbackUri, m
|
|
|
376
416
|
);
|
|
377
417
|
};
|
|
378
418
|
|
|
419
|
+
// Video-cell scrim (dark fill behind a thumbnail) now comes from theme.color.mediaScrim.
|
|
420
|
+
|
|
379
421
|
// Helper function to check for extension-generated thumbnails
|
|
380
422
|
const checkThumbnail = (message: CometChat.MediaMessage): { uri: string } => {
|
|
381
423
|
let image: { uri: string } = { uri: "" };
|
|
382
424
|
const thumbnailData = getExtensionData(message, ExtensionConstants.thumbnailGeneration);
|
|
383
425
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
} else {
|
|
392
|
-
// Extension-generated thumbnail exists
|
|
393
|
-
const attachmentData = thumbnailData["attachments"];
|
|
394
|
-
if (attachmentData && attachmentData.length) {
|
|
395
|
-
const dataObj = attachmentData[0];
|
|
396
|
-
if (!dataObj["error"]) {
|
|
397
|
-
const imageLink = dataObj?.["data"]?.["thumbnails"]?.["url_small"];
|
|
398
|
-
if (imageLink) {
|
|
399
|
-
image = { uri: dataObj["data"]["thumbnails"]["url_small"] };
|
|
400
|
-
}
|
|
401
|
-
}
|
|
426
|
+
// Prefer a successfully server-generated thumbnail.
|
|
427
|
+
const attachmentData = thumbnailData?.["attachments"];
|
|
428
|
+
if (attachmentData && attachmentData.length) {
|
|
429
|
+
const dataObj = attachmentData[0];
|
|
430
|
+
if (!dataObj["error"]) {
|
|
431
|
+
const imageLink = dataObj?.["data"]?.["thumbnails"]?.["url_small"];
|
|
432
|
+
if (imageLink) image = { uri: imageLink };
|
|
402
433
|
}
|
|
403
434
|
}
|
|
404
435
|
|
|
436
|
+
// No usable generated thumbnail — whether the extension data is missing, errored (e.g. the
|
|
437
|
+
// server's ERR_FILETYPE_NOT_SUPPORTED), or has null thumbnails — fall back to the video
|
|
438
|
+
// attachment's own poster if it has one. A video URL can't render as an image, so when there
|
|
439
|
+
// is no poster the uri stays "" and VideoThumbnail shows the dark scrim + play icon.
|
|
440
|
+
if (!image.uri && message.getType() === "video") {
|
|
441
|
+
const attachment = message.getAttachment();
|
|
442
|
+
const posterUrl = attachment && (attachment as any).thumbnail;
|
|
443
|
+
if (posterUrl) image = { uri: posterUrl };
|
|
444
|
+
}
|
|
445
|
+
|
|
405
446
|
return image;
|
|
406
447
|
};
|
|
407
448
|
|
|
449
|
+
// Dark "+N" badge shown over a media thumbnail when the result is a batch of several
|
|
450
|
+
// attachments (N = total attachments; the thumbnail already shows 1, so we render +N-1).
|
|
451
|
+
// Overlay is 60% black (matches the web spec), text is white.
|
|
452
|
+
const BatchCountOverlay = ({ count }: { count: number }) => {
|
|
453
|
+
const theme = useTheme();
|
|
454
|
+
if (!count || count <= 1) return null;
|
|
455
|
+
return (
|
|
456
|
+
<View
|
|
457
|
+
pointerEvents="none"
|
|
458
|
+
style={{
|
|
459
|
+
position: "absolute",
|
|
460
|
+
top: 0,
|
|
461
|
+
left: 0,
|
|
462
|
+
right: 0,
|
|
463
|
+
bottom: 0,
|
|
464
|
+
backgroundColor: theme.color.mediaOverlay,
|
|
465
|
+
justifyContent: "center",
|
|
466
|
+
alignItems: "center",
|
|
467
|
+
}}
|
|
468
|
+
>
|
|
469
|
+
<Text style={{ color: theme.color.staticWhite, fontSize: 18, fontWeight: "700" }}>{`+${count - 1}`}</Text>
|
|
470
|
+
</View>
|
|
471
|
+
);
|
|
472
|
+
};
|
|
473
|
+
|
|
408
474
|
interface VideoThumbnailProps {
|
|
409
475
|
thumbnailUrl: ImageSourcePropType;
|
|
410
476
|
mergedStyles: any;
|
|
477
|
+
attachmentCount?: number;
|
|
411
478
|
}
|
|
412
479
|
|
|
413
|
-
const VideoThumbnail = React.memo(({ thumbnailUrl, mergedStyles, }: VideoThumbnailProps) => {
|
|
414
|
-
|
|
480
|
+
const VideoThumbnail = React.memo(({ thumbnailUrl, mergedStyles, attachmentCount }: VideoThumbnailProps) => {
|
|
481
|
+
const theme = useTheme();
|
|
415
482
|
const [imageSource, setImageSource] = useState<ImageSourcePropType>(thumbnailUrl);
|
|
416
483
|
|
|
417
484
|
useEffect(() => {
|
|
418
|
-
|
|
419
|
-
|
|
485
|
+
const uri = thumbnailUrl && typeof thumbnailUrl === "object" && "uri" in thumbnailUrl
|
|
486
|
+
? (thumbnailUrl as any).uri
|
|
487
|
+
: undefined;
|
|
488
|
+
if (uri) {
|
|
489
|
+
CommonUtils.prefetchThumbnail(uri).then((success) => {
|
|
420
490
|
if (success) {
|
|
421
491
|
// console.log("success", thumbnailUrl);
|
|
422
492
|
setImageSource(thumbnailUrl);
|
|
@@ -436,12 +506,14 @@ const VideoThumbnail = React.memo(({ thumbnailUrl, mergedStyles, }: VideoThumbna
|
|
|
436
506
|
>
|
|
437
507
|
<ImageBackground
|
|
438
508
|
source={imageSource}
|
|
439
|
-
|
|
509
|
+
// Dark scrim shows through when there is no thumbnail (empty/failed source) — matches
|
|
510
|
+
// the video message bubble so the cell reads as a video, never a blank box.
|
|
511
|
+
style={[mergedStyles.messageItemStyle?.previewVideoStyle, { backgroundColor: theme.color.mediaScrim }]}
|
|
440
512
|
resizeMode="cover"
|
|
441
513
|
progressiveRenderingEnabled={true}
|
|
442
514
|
fadeDuration={0}
|
|
443
515
|
>
|
|
444
|
-
<View style={
|
|
516
|
+
<View style={styles.centerFill}>
|
|
445
517
|
<View style={mergedStyles.messageItemStyle?.videoPlayIconStyle}>
|
|
446
518
|
<Icon
|
|
447
519
|
name='play-arrow'
|
|
@@ -453,6 +525,7 @@ const VideoThumbnail = React.memo(({ thumbnailUrl, mergedStyles, }: VideoThumbna
|
|
|
453
525
|
</View>
|
|
454
526
|
</View>
|
|
455
527
|
</ImageBackground>
|
|
528
|
+
<BatchCountOverlay count={attachmentCount ?? 0} />
|
|
456
529
|
</View>
|
|
457
530
|
);
|
|
458
531
|
},
|
|
@@ -462,10 +535,35 @@ const VideoThumbnail = React.memo(({ thumbnailUrl, mergedStyles, }: VideoThumbna
|
|
|
462
535
|
const prevUri = (prev.thumbnailUrl as any)?.uri;
|
|
463
536
|
const nextUri = (next.thumbnailUrl as any)?.uri;
|
|
464
537
|
|
|
465
|
-
return prevUri === nextUri;
|
|
538
|
+
return prevUri === nextUri && prev.attachmentCount === next.attachmentCount;
|
|
466
539
|
}
|
|
467
540
|
);
|
|
468
541
|
|
|
542
|
+
// Lightweight static placeholder for a video with no thumbnail — dark tile + play icon.
|
|
543
|
+
// No ImageBackground / prefetch effect / rasterization, so it stays cheap while scrolling
|
|
544
|
+
// (the same treatment the video message bubble uses for a video with no poster).
|
|
545
|
+
const VideoPlaceholder = React.memo(
|
|
546
|
+
({ mergedStyles, attachmentCount }: { mergedStyles: any; attachmentCount?: number }) => {
|
|
547
|
+
const theme = useTheme();
|
|
548
|
+
return (
|
|
549
|
+
<View style={mergedStyles.messageItemStyle?.previewContainerStyle}>
|
|
550
|
+
<View
|
|
551
|
+
style={[
|
|
552
|
+
mergedStyles.messageItemStyle?.previewVideoStyle,
|
|
553
|
+
{ backgroundColor: theme.color.mediaScrim, justifyContent: "center", alignItems: "center" },
|
|
554
|
+
]}
|
|
555
|
+
>
|
|
556
|
+
<View style={mergedStyles.messageItemStyle?.videoPlayIconStyle}>
|
|
557
|
+
<Icon name="play-arrow" size={16} height={16} width={16} color={theme.color.staticWhite as string} />
|
|
558
|
+
</View>
|
|
559
|
+
</View>
|
|
560
|
+
<BatchCountOverlay count={attachmentCount ?? 0} />
|
|
561
|
+
</View>
|
|
562
|
+
);
|
|
563
|
+
},
|
|
564
|
+
(prev, next) => prev.attachmentCount === next.attachmentCount
|
|
565
|
+
);
|
|
566
|
+
|
|
469
567
|
// Memoized Conversation Item Component
|
|
470
568
|
interface ConversationItemProps {
|
|
471
569
|
conversation: CometChat.Conversation;
|
|
@@ -500,17 +598,13 @@ const ConversationItem = React.memo<ConversationItemProps>((
|
|
|
500
598
|
const name = withObj.getName();
|
|
501
599
|
|
|
502
600
|
return (
|
|
503
|
-
<View style={
|
|
504
|
-
<View style={
|
|
601
|
+
<View style={styles.avatarWrap}>
|
|
602
|
+
<View style={styles.avatar}>
|
|
505
603
|
<CometChatAvatar
|
|
506
604
|
image={{ uri: avatarURL }}
|
|
507
605
|
name={name}
|
|
508
606
|
/>
|
|
509
|
-
<View style={
|
|
510
|
-
position: 'absolute',
|
|
511
|
-
bottom: 0,
|
|
512
|
-
right: 0,
|
|
513
|
-
}}>
|
|
607
|
+
<View style={styles.statusBadge}>
|
|
514
608
|
<CometChatStatusIndicator
|
|
515
609
|
type={getStatusIndicator()}
|
|
516
610
|
/>
|
|
@@ -1310,17 +1404,13 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
1310
1404
|
const name = withObj.getName();
|
|
1311
1405
|
|
|
1312
1406
|
return (
|
|
1313
|
-
<View style={
|
|
1314
|
-
<View style={
|
|
1407
|
+
<View style={styles.avatarWrap}>
|
|
1408
|
+
<View style={styles.avatar}>
|
|
1315
1409
|
<CometChatAvatar
|
|
1316
1410
|
image={{ uri: avatarURL }}
|
|
1317
1411
|
name={name}
|
|
1318
1412
|
/>
|
|
1319
|
-
<View style={
|
|
1320
|
-
position: 'absolute',
|
|
1321
|
-
bottom: 0,
|
|
1322
|
-
right: 0,
|
|
1323
|
-
}}>
|
|
1413
|
+
<View style={styles.statusBadge}>
|
|
1324
1414
|
<CometChatStatusIndicator
|
|
1325
1415
|
type={getStatusIndicator(conversation)}
|
|
1326
1416
|
/>
|
|
@@ -1426,6 +1516,128 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
1426
1516
|
return text;
|
|
1427
1517
|
};
|
|
1428
1518
|
|
|
1519
|
+
// Subtitle text for a media/file search result. Shows the message CAPTION when there is one,
|
|
1520
|
+
// otherwise a count summary ("N Videos" / "12 Files"). Photos/videos put their +N on the
|
|
1521
|
+
// thumbnail, so they show caption-or-count; files/audio have no thumbnail, so a caption is
|
|
1522
|
+
// shown alongside the count ("the signed copy · 6 Files"). Falls back to the file name for a
|
|
1523
|
+
// single, caption-less attachment.
|
|
1524
|
+
const getMediaSearchSubtitle = (message: CometChat.MediaMessage): string => {
|
|
1525
|
+
const type = message.getType();
|
|
1526
|
+
const atts =
|
|
1527
|
+
(typeof message.getAttachments === "function" ? message.getAttachments() : null) || [];
|
|
1528
|
+
const count = atts.length || 1;
|
|
1529
|
+
const caption =
|
|
1530
|
+
(typeof (message as any).getCaption === "function" ? (message as any).getCaption() : "") || "";
|
|
1531
|
+
const firstName =
|
|
1532
|
+
atts[0]?.getName?.() || (message.getAttachment?.() as any)?.getName?.() || "";
|
|
1533
|
+
|
|
1534
|
+
// Title-case labels (no localization keys exist for these — t() would echo the UPPERCASE
|
|
1535
|
+
// key back, which is why the counts rendered as "1 IMAGE"/"7 IMAGES").
|
|
1536
|
+
const plural =
|
|
1537
|
+
type === "video" ? "Videos"
|
|
1538
|
+
: type === "image" ? "Images"
|
|
1539
|
+
: type === "audio" ? "Audios"
|
|
1540
|
+
: "Files";
|
|
1541
|
+
const singular =
|
|
1542
|
+
type === "video" ? "Video"
|
|
1543
|
+
: type === "image" ? "Image"
|
|
1544
|
+
: type === "audio" ? "Audio"
|
|
1545
|
+
: "File";
|
|
1546
|
+
const countLabel = `${count} ${count === 1 ? singular : plural}`;
|
|
1547
|
+
|
|
1548
|
+
const hasThumbnail = type === "image" || type === "video"; // +N lives on the thumbnail
|
|
1549
|
+
const result = hasThumbnail
|
|
1550
|
+
? caption || countLabel
|
|
1551
|
+
: caption
|
|
1552
|
+
? (count > 1 ? `${caption} · ${countLabel}` : caption)
|
|
1553
|
+
: (count > 1 ? countLabel : firstName || countLabel);
|
|
1554
|
+
|
|
1555
|
+
return result;
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1558
|
+
// Title of a message search result = the CHAT it belongs to (group name, or the other user
|
|
1559
|
+
// for a 1:1), not the sender — the sender goes in the subtitle prefix ("You:" / "<name>:").
|
|
1560
|
+
const getMessageChatTitle = (message: CometChat.BaseMessage): string => {
|
|
1561
|
+
const receiver: any = message.getReceiver?.();
|
|
1562
|
+
if (message.getReceiverType?.() === ReceiverTypeConstants.group) {
|
|
1563
|
+
return receiver?.getName?.() || message.getSender()?.getName?.() || "";
|
|
1564
|
+
}
|
|
1565
|
+
const sentByMe = message.getSender?.()?.getUid?.() === loggedInUser?.getUid?.();
|
|
1566
|
+
return (sentByMe ? receiver?.getName?.() : message.getSender()?.getName?.()) || "";
|
|
1567
|
+
};
|
|
1568
|
+
|
|
1569
|
+
// Plain-string subtitle text for any message type (attachments delegate to the caption/count
|
|
1570
|
+
// helper above; everything else keeps the existing text/card/custom handling).
|
|
1571
|
+
const getMessageSubtitleText = (message: CometChat.BaseMessage): string => {
|
|
1572
|
+
const messageType = message.getType();
|
|
1573
|
+
if (["image", "video", "file", "audio"].includes(messageType)) {
|
|
1574
|
+
return getMediaSearchSubtitle(message as CometChat.MediaMessage);
|
|
1575
|
+
}
|
|
1576
|
+
if (messageType === "text") {
|
|
1577
|
+
const raw = (message as CometChat.TextMessage).getText?.();
|
|
1578
|
+
return formatMentionsInText(raw, message) || messageType || "Message";
|
|
1579
|
+
}
|
|
1580
|
+
if (message.getCategory() === MessageCategoryConstants.card) {
|
|
1581
|
+
const cardText =
|
|
1582
|
+
(typeof (message as any).getText === "function" && (message as any).getText()) || "";
|
|
1583
|
+
return cardText || t("CARD_MESSAGE") || "Card Message";
|
|
1584
|
+
}
|
|
1585
|
+
const customTypeKey = `CUSTOM_MESSAGE_${messageType.toUpperCase()}`;
|
|
1586
|
+
const localizedType = t(customTypeKey);
|
|
1587
|
+
if (localizedType && localizedType !== customTypeKey) return localizedType;
|
|
1588
|
+
if (messageType === "extension_poll") return t("CUSTOM_MESSAGE_POLL") || "Poll";
|
|
1589
|
+
if (messageType === "extension_sticker") return t("CUSTOM_MESSAGE_STICKER") || "Sticker";
|
|
1590
|
+
if (messageType === "extension_whiteboard") return t("CUSTOM_MESSAGE_WHITEBOARD") || "Whiteboard";
|
|
1591
|
+
if (messageType === "extension_document") return t("CUSTOM_MESSAGE_DOCUMENT") || "Document";
|
|
1592
|
+
if (messageType === "meeting") return t("meeting") || "Meeting";
|
|
1593
|
+
return messageType || "Message";
|
|
1594
|
+
};
|
|
1595
|
+
|
|
1596
|
+
// Subtitle row: "<You|sender>: <type-icon> <caption|count>". The small inline icon appears
|
|
1597
|
+
// for attachment messages (image/video/audio/file); text messages have none.
|
|
1598
|
+
const attachmentSubtitleIcon: Record<string, string> = {
|
|
1599
|
+
image: "photo-fill",
|
|
1600
|
+
video: "videocam-fill",
|
|
1601
|
+
audio: "mic-fill",
|
|
1602
|
+
file: "description-fill",
|
|
1603
|
+
};
|
|
1604
|
+
const renderMessageSubtitle = (message: CometChat.BaseMessage) => {
|
|
1605
|
+
const sentByMe = message.getSender?.()?.getUid?.() === loggedInUser?.getUid?.();
|
|
1606
|
+
const senderLabel = sentByMe ? t("YOU") || "You" : message.getSender()?.getName?.() || "";
|
|
1607
|
+
const iconName = attachmentSubtitleIcon[message.getType()];
|
|
1608
|
+
return (
|
|
1609
|
+
<View style={styles.row}>
|
|
1610
|
+
{/* subtitleStyle carries width:'90%' (for the plain single-line subtitle). It MUST be
|
|
1611
|
+
overridden here — otherwise the short sender name sits inside a 90%-wide box, leaving a
|
|
1612
|
+
big gap before the icon and shoving the caption off-screen. Sender hugs its own text
|
|
1613
|
+
(flexGrow:0) and only ellipsizes (flexShrink:2) when a name is genuinely long. */}
|
|
1614
|
+
<Text
|
|
1615
|
+
style={[mergedStyles.messageItemStyle?.subtitleStyle, { width: undefined, flexGrow: 0, flexShrink: 2 }]}
|
|
1616
|
+
numberOfLines={1}
|
|
1617
|
+
>{`${senderLabel}: `}</Text>
|
|
1618
|
+
{iconName ? (
|
|
1619
|
+
<Icon
|
|
1620
|
+
name={iconName as any}
|
|
1621
|
+
size={16}
|
|
1622
|
+
height={16}
|
|
1623
|
+
width={16}
|
|
1624
|
+
color={theme.color.iconSecondary}
|
|
1625
|
+
/>
|
|
1626
|
+
) : null}
|
|
1627
|
+
<Text
|
|
1628
|
+
style={[
|
|
1629
|
+
mergedStyles.messageItemStyle?.subtitleStyle,
|
|
1630
|
+
{ marginLeft: iconName ? 4 : 0, width: undefined, flex: 1 },
|
|
1631
|
+
]}
|
|
1632
|
+
numberOfLines={1}
|
|
1633
|
+
ellipsizeMode="tail"
|
|
1634
|
+
>
|
|
1635
|
+
{getMessageSubtitleText(message)}
|
|
1636
|
+
</Text>
|
|
1637
|
+
</View>
|
|
1638
|
+
);
|
|
1639
|
+
};
|
|
1640
|
+
|
|
1429
1641
|
// Render message leading view (for audio/file icons)
|
|
1430
1642
|
const renderMessageLeadingView = (message: CometChat.BaseMessage) => {
|
|
1431
1643
|
const messageType = message.getType();
|
|
@@ -1455,20 +1667,10 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
1455
1667
|
}
|
|
1456
1668
|
|
|
1457
1669
|
case 'file': {
|
|
1458
|
-
|
|
1459
|
-
const attachment = fileMessage.getAttachment();
|
|
1460
|
-
const fileName = attachment?.getName?.() || '';
|
|
1461
|
-
const fileTypeIcon = getFileTypeIcon(fileName);
|
|
1462
|
-
|
|
1670
|
+
// Documents filter results use the fanned "FILE" document icon (search-only).
|
|
1463
1671
|
return (
|
|
1464
1672
|
<View style={mergedStyles.messageItemStyle?.iconContainerStyle}>
|
|
1465
|
-
<
|
|
1466
|
-
name={fileTypeIcon}
|
|
1467
|
-
size={48}
|
|
1468
|
-
height={48}
|
|
1469
|
-
width={48}
|
|
1470
|
-
color={theme.color.iconSecondary}
|
|
1471
|
-
/>
|
|
1673
|
+
<DocumentTypeIcon width={48} height={48} />
|
|
1472
1674
|
</View>
|
|
1473
1675
|
);
|
|
1474
1676
|
}
|
|
@@ -1525,6 +1727,7 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
1525
1727
|
const attachment = imageMessage.getAttachment();
|
|
1526
1728
|
const imageUrl = attachment && (attachment as any).url;
|
|
1527
1729
|
if (imageUrl) {
|
|
1730
|
+
const count = imageMessage.getAttachments?.()?.length || 1;
|
|
1528
1731
|
return (
|
|
1529
1732
|
<View style={mergedStyles.messageItemStyle?.previewContainerStyle}>
|
|
1530
1733
|
<Image
|
|
@@ -1534,6 +1737,7 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
1534
1737
|
progressiveRenderingEnabled={true}
|
|
1535
1738
|
fadeDuration={0}
|
|
1536
1739
|
/>
|
|
1740
|
+
<BatchCountOverlay count={count} />
|
|
1537
1741
|
</View>
|
|
1538
1742
|
);
|
|
1539
1743
|
}
|
|
@@ -1543,16 +1747,18 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
1543
1747
|
case 'video': {
|
|
1544
1748
|
const videoMessage = message as CometChat.MediaMessage;
|
|
1545
1749
|
const thumbnailImage = checkThumbnail(videoMessage);
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1750
|
+
const attachmentCount = videoMessage.getAttachments?.()?.length || 1;
|
|
1751
|
+
// Real poster → the (heavier) image-backed thumbnail. No poster → a cheap static dark
|
|
1752
|
+
// tile + play icon, so no-thumbnail rows don't add ImageBackground/prefetch cost to scroll.
|
|
1753
|
+
return thumbnailImage.uri ? (
|
|
1754
|
+
<VideoThumbnail
|
|
1755
|
+
thumbnailUrl={thumbnailImage}
|
|
1756
|
+
mergedStyles={mergedStyles}
|
|
1757
|
+
attachmentCount={attachmentCount}
|
|
1758
|
+
/>
|
|
1759
|
+
) : (
|
|
1760
|
+
<VideoPlaceholder mergedStyles={mergedStyles} attachmentCount={attachmentCount} />
|
|
1761
|
+
);
|
|
1556
1762
|
}
|
|
1557
1763
|
|
|
1558
1764
|
|
|
@@ -1813,53 +2019,9 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
1813
2019
|
(message.getType() === 'image' || message.getType() === 'video') && mergedStyles.messageItemStyle?.textContainerStyle
|
|
1814
2020
|
]}>
|
|
1815
2021
|
<Text style={mergedStyles.messageItemStyle?.titleStyle} numberOfLines={1}>
|
|
1816
|
-
{message
|
|
1817
|
-
</Text>
|
|
1818
|
-
<Text style={mergedStyles.messageItemStyle?.subtitleStyle} numberOfLines={2}>
|
|
1819
|
-
{(() => {
|
|
1820
|
-
const messageType = message.getType();
|
|
1821
|
-
|
|
1822
|
-
// For media messages (image, video, file, audio), show file name
|
|
1823
|
-
if (['image', 'video', 'file', 'audio'].includes(messageType)) {
|
|
1824
|
-
const mediaMessage = message as CometChat.MediaMessage;
|
|
1825
|
-
const attachment = mediaMessage.getAttachment?.();
|
|
1826
|
-
return attachment?.getName?.() || messageType;
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
|
-
// For text messages, show the text content
|
|
1830
|
-
if (messageType === 'text') {
|
|
1831
|
-
const raw = (message as CometChat.TextMessage).getText?.();
|
|
1832
|
-
const formatted = formatMentionsInText(raw, message);
|
|
1833
|
-
return formatted || messageType || 'Message';
|
|
1834
|
-
}
|
|
1835
|
-
|
|
1836
|
-
// For developer card messages, show the card's text content
|
|
1837
|
-
// (detected by category — the card `type` is arbitrary).
|
|
1838
|
-
if (message.getCategory() === MessageCategoryConstants.card) {
|
|
1839
|
-
const cardText =
|
|
1840
|
-
(typeof (message as any).getText === 'function' && (message as any).getText()) || '';
|
|
1841
|
-
return cardText || t('CARD_MESSAGE') || 'Card Message';
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
|
-
// For custom messages, try to localize the type
|
|
1845
|
-
const customTypeKey = `CUSTOM_MESSAGE_${messageType.toUpperCase()}`;
|
|
1846
|
-
const localizedType = t(customTypeKey);
|
|
1847
|
-
|
|
1848
|
-
// If localization exists and is different from key, use it
|
|
1849
|
-
if (localizedType && localizedType !== customTypeKey) {
|
|
1850
|
-
return localizedType;
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
|
-
// Handle specific extension types mapping to existing keys
|
|
1854
|
-
if (messageType === 'extension_poll') return t("CUSTOM_MESSAGE_POLL") || "Poll";
|
|
1855
|
-
if (messageType === 'extension_sticker') return t("CUSTOM_MESSAGE_STICKER") || "Sticker";
|
|
1856
|
-
if (messageType === 'extension_whiteboard') return t("CUSTOM_MESSAGE_WHITEBOARD") || "Whiteboard";
|
|
1857
|
-
if (messageType === 'extension_document') return t("CUSTOM_MESSAGE_DOCUMENT") || "Document";
|
|
1858
|
-
if (messageType === 'meeting') return t("meeting") || "Meeting";
|
|
1859
|
-
|
|
1860
|
-
return messageType || 'Message';
|
|
1861
|
-
})()}
|
|
2022
|
+
{getMessageChatTitle(message)}
|
|
1862
2023
|
</Text>
|
|
2024
|
+
{renderMessageSubtitle(message)}
|
|
1863
2025
|
</View>
|
|
1864
2026
|
<MemoizedTrailingView message={message} />
|
|
1865
2027
|
</TouchableOpacity>
|
|
@@ -2093,53 +2255,9 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
2093
2255
|
(message.getType() === 'image' || message.getType() === 'video') && mergedStyles.messageItemStyle?.textContainerStyle
|
|
2094
2256
|
]}>
|
|
2095
2257
|
<Text style={mergedStyles.messageItemStyle?.titleStyle} numberOfLines={1}>
|
|
2096
|
-
{message
|
|
2097
|
-
</Text>
|
|
2098
|
-
<Text style={mergedStyles.messageItemStyle?.subtitleStyle} numberOfLines={2}>
|
|
2099
|
-
{(() => {
|
|
2100
|
-
const msgType = message.getType();
|
|
2101
|
-
|
|
2102
|
-
// For media messages (image, video, file, audio), show file name
|
|
2103
|
-
if (['image', 'video', 'file', 'audio'].includes(msgType)) {
|
|
2104
|
-
const mediaMessage = message as CometChat.MediaMessage;
|
|
2105
|
-
const attachment = mediaMessage.getAttachment?.();
|
|
2106
|
-
return attachment?.getName?.() || msgType;
|
|
2107
|
-
}
|
|
2108
|
-
|
|
2109
|
-
// For text messages, show the text content
|
|
2110
|
-
if (msgType === 'text') {
|
|
2111
|
-
const raw = (message as CometChat.TextMessage).getText?.();
|
|
2112
|
-
const formatted = formatMentionsInText(raw, message);
|
|
2113
|
-
return formatted || msgType || 'Message';
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
// For developer card messages, show the card's text content
|
|
2117
|
-
// (detected by category — the card `type` is arbitrary).
|
|
2118
|
-
if (message.getCategory() === MessageCategoryConstants.card) {
|
|
2119
|
-
const cardText =
|
|
2120
|
-
(typeof (message as any).getText === 'function' && (message as any).getText()) || '';
|
|
2121
|
-
return cardText || t('CARD_MESSAGE') || 'Card Message';
|
|
2122
|
-
}
|
|
2123
|
-
|
|
2124
|
-
// For custom messages, try to localize the type
|
|
2125
|
-
const customTypeKey = `CUSTOM_MESSAGE_${msgType.toUpperCase()}`;
|
|
2126
|
-
const localizedType = t(customTypeKey);
|
|
2127
|
-
|
|
2128
|
-
// If localization exists and is different from key, use it
|
|
2129
|
-
if (localizedType && localizedType !== customTypeKey) {
|
|
2130
|
-
return localizedType;
|
|
2131
|
-
}
|
|
2132
|
-
|
|
2133
|
-
// Handle specific extension types mapping to existing keys
|
|
2134
|
-
if (msgType === 'extension_poll') return t("CUSTOM_MESSAGE_POLL") || "Poll";
|
|
2135
|
-
if (msgType === 'extension_sticker') return t("CUSTOM_MESSAGE_STICKER") || "Sticker";
|
|
2136
|
-
if (msgType === 'extension_whiteboard') return t("CUSTOM_MESSAGE_WHITEBOARD") || "Whiteboard";
|
|
2137
|
-
if (msgType === 'extension_document') return t("CUSTOM_MESSAGE_DOCUMENT") || "Document";
|
|
2138
|
-
if (msgType === 'meeting') return t("meeting") || "Meeting";
|
|
2139
|
-
|
|
2140
|
-
return msgType || 'Message';
|
|
2141
|
-
})()}
|
|
2258
|
+
{getMessageChatTitle(message)}
|
|
2142
2259
|
</Text>
|
|
2260
|
+
{renderMessageSubtitle(message)}
|
|
2143
2261
|
</View>
|
|
2144
2262
|
<MemoizedTrailingView message={message} />
|
|
2145
2263
|
</TouchableOpacity>
|
|
@@ -2185,4 +2303,28 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
2185
2303
|
);
|
|
2186
2304
|
};
|
|
2187
2305
|
|
|
2306
|
+
const styles = StyleSheet.create({
|
|
2307
|
+
avatarWrap: {
|
|
2308
|
+
position: 'relative',
|
|
2309
|
+
},
|
|
2310
|
+
avatar: {
|
|
2311
|
+
height: 48,
|
|
2312
|
+
width: 48,
|
|
2313
|
+
},
|
|
2314
|
+
statusBadge: {
|
|
2315
|
+
position: 'absolute',
|
|
2316
|
+
bottom: 0,
|
|
2317
|
+
right: 0,
|
|
2318
|
+
},
|
|
2319
|
+
centerFill: {
|
|
2320
|
+
flex: 1,
|
|
2321
|
+
justifyContent: 'center',
|
|
2322
|
+
alignItems: 'center',
|
|
2323
|
+
},
|
|
2324
|
+
row: {
|
|
2325
|
+
flexDirection: 'row',
|
|
2326
|
+
alignItems: 'center',
|
|
2327
|
+
},
|
|
2328
|
+
});
|
|
2329
|
+
|
|
2188
2330
|
export default CometChatSearch;
|
|
@@ -25,19 +25,25 @@ export class CallingExtension extends ExtensionsDataSource {
|
|
|
25
25
|
|
|
26
26
|
override addExtension(): void {
|
|
27
27
|
ChatConfigurator.enable((dataSource) => {
|
|
28
|
-
const
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
const onInit = () =>
|
|
29
|
+
console.log("CometChatCalls initialization completed successfully");
|
|
30
|
+
const onError = (error: CometChat.CometChatException) =>
|
|
31
|
+
console.log("CometChatCalls initialization failed with error:", error);
|
|
32
|
+
|
|
33
|
+
const callsInitSettings = CometChatUIKit.callsInitSettings;
|
|
34
|
+
if (callsInitSettings && typeof CometChatCalls.initFromSettings === "function") {
|
|
35
|
+
// ai-agent path: initFromSettings writes integrationSource = "ai-agent".
|
|
36
|
+
// typeof guard degrades to plain init() for Calls SDKs without it (RN calls SDK < the release that adds initFromSettings).
|
|
37
|
+
CometChatCalls.initFromSettings(callsInitSettings).then(onInit, onError);
|
|
38
|
+
} else {
|
|
39
|
+
// Plain init() path — unchanged for developers.
|
|
40
|
+
const callAppSettings = new CometChatCalls.CallAppSettingsBuilder()
|
|
41
|
+
.setAppId(CometChatUIKit.uiKitSettings.appId)
|
|
42
|
+
.setRegion(CometChatUIKit.uiKitSettings.region)
|
|
43
|
+
.build();
|
|
44
|
+
CometChatCalls.init(callAppSettings).then(onInit, onError);
|
|
45
|
+
}
|
|
46
|
+
|
|
41
47
|
return new CallingExtensionDecorator({
|
|
42
48
|
dataSource,
|
|
43
49
|
configuration: this.configuration,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { JSX, useCallback, useRef, useState } from "react";
|
|
1
|
+
import React, { JSX, useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import {
|
|
3
3
|
Alert,
|
|
4
4
|
DimensionValue,
|
|
@@ -71,6 +71,25 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
|
|
|
71
71
|
|
|
72
72
|
const [faviconError, setFaviconError] = useState(false);
|
|
73
73
|
|
|
74
|
+
// Sync imageSource when image prop changes (e.g., after message edit)
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
setImageSource(
|
|
77
|
+
image
|
|
78
|
+
? { uri: image.startsWith("https:") ? image : `https:${image.split("http:")[1]}` }
|
|
79
|
+
: undefined
|
|
80
|
+
);
|
|
81
|
+
setImageHeight(undefined);
|
|
82
|
+
setImageWidth(undefined);
|
|
83
|
+
}, [image]);
|
|
84
|
+
|
|
85
|
+
// Sync faviconSource when favicon prop changes (e.g., after message edit)
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
setFaviconSource({
|
|
88
|
+
uri: favicon.startsWith("https:") ? favicon : `https:${favicon.split("http:")[1]}`,
|
|
89
|
+
});
|
|
90
|
+
setFaviconError(false);
|
|
91
|
+
}, [favicon]);
|
|
92
|
+
|
|
74
93
|
const pressTime = useRef<number | null>(0);
|
|
75
94
|
|
|
76
95
|
/**
|