@cometchat/chat-uikit-react-native 5.2.7 → 5.2.9

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 (56) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/7.4/gc.properties +0 -0
  5. package/android/.gradle/vcs-1/gc.properties +0 -0
  6. package/package.json +1 -1
  7. package/src/CometChatConversations/CometChatConversations.tsx +8 -1
  8. package/src/CometChatGroups/CometChatGroups.tsx +5 -3
  9. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +55 -8
  10. package/src/CometChatMessageList/CometChatMessageList.tsx +1169 -548
  11. package/src/CometChatMessageList/components/MessageListItem.tsx +127 -0
  12. package/src/CometChatMessageList/components/MessageModals.tsx +60 -0
  13. package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +130 -0
  14. package/src/CometChatMessageList/components/ReactionModals.tsx +70 -0
  15. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +23 -1
  16. package/src/CometChatUsers/CometChatUsers.tsx +4 -1
  17. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +27 -36
  18. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +21 -12
  19. package/src/shared/base/Types.ts +1 -0
  20. package/src/shared/constants/UIKitConstants.ts +1 -1
  21. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +4 -0
  22. package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -1
  23. package/src/shared/events/conversations.ts +1 -0
  24. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +23 -15
  25. package/src/shared/framework/MessageDataSource.tsx +79 -17
  26. package/src/shared/index.ts +2 -0
  27. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +3 -1
  28. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +3 -1
  29. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +3 -1
  30. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +3 -1
  31. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +3 -1
  32. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +3 -1
  33. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +3 -1
  34. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +3 -1
  35. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +3 -1
  36. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +3 -1
  37. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +3 -1
  38. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +3 -1
  39. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +3 -1
  40. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +3 -1
  41. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +3 -1
  42. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +3 -1
  43. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +3 -1
  44. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +3 -1
  45. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +7 -4
  46. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +20 -12
  47. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +6 -3
  48. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +2 -1
  49. package/src/shared/views/CometChatList/CometChatList.tsx +20 -1
  50. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +2 -3
  51. package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +55 -0
  52. package/src/shared/views/CometChatNewMessageIndicator/index.ts +3 -0
  53. package/src/shared/views/CometChatNewMessageIndicator/styles.ts +33 -0
  54. package/src/shared/views/CometChatRetryButton/CometChatRetryButton.tsx +54 -0
  55. package/src/shared/views/CometChatRetryButton/index.ts +3 -0
  56. package/src/shared/views/index.ts +15 -0
@@ -0,0 +1,127 @@
1
+ import React, { memo } from 'react';
2
+ import { View, Animated } from 'react-native';
3
+ import { CometChat } from '@cometchat/chat-sdk-react-native';
4
+ import { CometChatDateSeparator } from '../../shared/views/CometChatDateSeperator';
5
+ import { CometChatTheme } from '../../theme/type';
6
+ import { CometChatNewMessageIndicator, NewMessageIndicatorStyle } from '../../shared/views';
7
+
8
+ const SEPARATOR_HEIGHT = 40;
9
+
10
+ interface MessageListItemProps {
11
+ item: CometChat.BaseMessage;
12
+ index: number;
13
+ showSeparator: boolean;
14
+ isHighlighted: boolean;
15
+ highlightAnimatedValue: Animated.Value;
16
+ theme: CometChatTheme;
17
+ timestamp: number;
18
+ dayHeaderString: string | undefined;
19
+ RenderMessageItem: React.ComponentType<any>;
20
+ itemSeparator: () => React.ReactNode;
21
+ staticStyles: any;
22
+ onLayout?: (event: any, messageId: string) => void;
23
+ showNewMessageIndicator?: boolean;
24
+ NewMessageIndicatorView?: React.ComponentType<any>;
25
+ newMessageIndicatorStyle?: NewMessageIndicatorStyle;
26
+ newMessageIndicatorText?: string;
27
+ }
28
+
29
+ const MessageListItemComponent: React.FC<MessageListItemProps> = ({
30
+ item,
31
+ index,
32
+ showSeparator,
33
+ isHighlighted,
34
+ highlightAnimatedValue,
35
+ theme,
36
+ timestamp,
37
+ dayHeaderString,
38
+ RenderMessageItem,
39
+ itemSeparator,
40
+ staticStyles,
41
+ onLayout,
42
+ showNewMessageIndicator,
43
+ NewMessageIndicatorView,
44
+ newMessageIndicatorStyle,
45
+ newMessageIndicatorText,
46
+ }) => {
47
+
48
+ // Handle layout event to get item position
49
+ const handleLayout = (event: any) => {
50
+ if (onLayout) {
51
+ onLayout(event, String(item.getId()));
52
+ }
53
+ };
54
+
55
+ return (
56
+ <View style={staticStyles.container} onLayout={handleLayout}>
57
+ {isHighlighted && (
58
+ <Animated.View
59
+ style={{
60
+ backgroundColor: highlightAnimatedValue.interpolate({
61
+ inputRange: [0, 1],
62
+ outputRange: ['transparent', String(theme.color.extendedPrimary200)],
63
+ }),
64
+ position: 'absolute',
65
+ left: 0,
66
+ right: 0,
67
+ top: showSeparator ? SEPARATOR_HEIGHT : 0,
68
+ bottom: 0,
69
+ zIndex: 1,
70
+ }}
71
+ />
72
+ )}
73
+ <View style={staticStyles.contentWrapper}>
74
+ {showSeparator && (
75
+ <View style={staticStyles.separatorContainer}>
76
+ <CometChatDateSeparator
77
+ timeStamp={timestamp}
78
+ pattern="dayDateFormat"
79
+ customDateString={dayHeaderString}
80
+ style={theme.messageListStyles.dateSeparatorStyle}
81
+ />
82
+ </View>
83
+ )}
84
+ {showNewMessageIndicator && (
85
+ <CometChatNewMessageIndicator
86
+ NewMessageIndicatorView={NewMessageIndicatorView}
87
+ style={newMessageIndicatorStyle}
88
+ text={newMessageIndicatorText}
89
+ />
90
+ )}
91
+ <RenderMessageItem item={item} theme={theme} idx={index} />
92
+ {itemSeparator()}
93
+ </View>
94
+ </View>
95
+ );
96
+ };
97
+
98
+ // Memoize with custom comparison
99
+ export const MessageListItem = memo(MessageListItemComponent, (prevProps, nextProps) => {
100
+ // Return true if props are equal (skip re-render)
101
+ // Return false if props changed (re-render needed)
102
+
103
+ const itemUnchanged = prevProps.item === nextProps.item;
104
+
105
+ const visualsUnchanged =
106
+ prevProps.isHighlighted === nextProps.isHighlighted &&
107
+ prevProps.showSeparator === nextProps.showSeparator &&
108
+ prevProps.timestamp === nextProps.timestamp &&
109
+ prevProps.dayHeaderString === nextProps.dayHeaderString &&
110
+ prevProps.showNewMessageIndicator === nextProps.showNewMessageIndicator &&
111
+ prevProps.newMessageIndicatorText === nextProps.newMessageIndicatorText;
112
+
113
+ const styleUnchanged =
114
+ prevProps.theme === nextProps.theme &&
115
+ prevProps.staticStyles === nextProps.staticStyles &&
116
+ prevProps.newMessageIndicatorStyle === nextProps.newMessageIndicatorStyle;
117
+
118
+ const functionsUnchanged =
119
+ prevProps.RenderMessageItem === nextProps.RenderMessageItem &&
120
+ prevProps.itemSeparator === nextProps.itemSeparator &&
121
+ prevProps.highlightAnimatedValue === nextProps.highlightAnimatedValue &&
122
+ prevProps.onLayout === nextProps.onLayout;
123
+
124
+ return itemUnchanged && visualsUnchanged && styleUnchanged && functionsUnchanged;
125
+ });
126
+
127
+ MessageListItem.displayName = 'MessageListItem';
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import { CometChat } from '@cometchat/chat-sdk-react-native';
3
+ import { Icon } from '../../shared/icons/Icon';
4
+ import { CometChatConfirmDialog, CometChatReportDialog } from '../../shared/views';
5
+ import { CometChatTheme } from '../../theme/type';
6
+
7
+ interface MessageModalsProps {
8
+ showDeleteModal: boolean;
9
+ showReportDialog: boolean;
10
+ deleteItem: React.MutableRefObject<CometChat.BaseMessage | undefined>;
11
+ reportedMessageRef: React.MutableRefObject<CometChat.BaseMessage | null>;
12
+ theme: CometChatTheme;
13
+ hideFlagRemarkField?: boolean;
14
+ t: (key: string) => string;
15
+ onDeleteCancel: () => void;
16
+ onDeleteConfirm: (message: CometChat.BaseMessage) => void;
17
+ onReportCancel: () => void;
18
+ onReportSubmit: (payload: any) => void;
19
+ }
20
+
21
+ export const MessageModals: React.FC<MessageModalsProps> = ({
22
+ showDeleteModal,
23
+ showReportDialog,
24
+ deleteItem,
25
+ reportedMessageRef,
26
+ theme,
27
+ hideFlagRemarkField,
28
+ t,
29
+ onDeleteCancel,
30
+ onDeleteConfirm,
31
+ onReportCancel,
32
+ onReportSubmit,
33
+ }) => {
34
+ return (
35
+ <>
36
+ <CometChatConfirmDialog
37
+ titleText={t('DELETE_THIS_MESSAGE')}
38
+ icon={<Icon name="delete" size={theme.spacing.spacing.s12} color={theme.color.error} />}
39
+ cancelButtonText={t('CANCEL')}
40
+ confirmButtonText={t('DELETE')}
41
+ messageText={t('DELETE_MESSAGE_CONFIRM')}
42
+ isOpen={showDeleteModal}
43
+ onCancel={onDeleteCancel}
44
+ onConfirm={() => {
45
+ if (deleteItem.current) {
46
+ onDeleteConfirm(deleteItem.current);
47
+ }
48
+ }}
49
+ />
50
+
51
+ <CometChatReportDialog
52
+ isOpen={showReportDialog}
53
+ message={reportedMessageRef.current || undefined}
54
+ onCancel={onReportCancel}
55
+ hideFlagRemarkField={hideFlagRemarkField}
56
+ onReport={onReportSubmit}
57
+ />
58
+ </>
59
+ );
60
+ };
@@ -0,0 +1,130 @@
1
+ import React from 'react';
2
+ import { View, Dimensions, Platform } from 'react-native';
3
+ import { CometChat } from '@cometchat/chat-sdk-react-native';
4
+ import { CometChatBottomSheet } from '../../shared/views';
5
+ import { CometChatMessageInformation } from '../../CometChatMessageInformation/CometChatMessageInformation';
6
+ import { CometChatQuickReactions } from '../../shared/views/CometChatQuickReactions';
7
+ import { CometChatActionSheet } from '../../shared';
8
+ import { CometChatTheme } from '../../theme/type';
9
+ import { CometChatMessageTemplate } from '../../shared/modals/CometChatMessageTemplate';
10
+ import { getModerationStatus } from '../../shared/utils/MessageUtils';
11
+
12
+ interface MessageOptionsSheetProps {
13
+ bottomSheetRef: React.RefObject<any>;
14
+ isOpen: boolean;
15
+ showMessageOptions: any[];
16
+ ExtensionsComponent: React.JSX.Element | null;
17
+ messageInfo: boolean;
18
+ infoObject: React.MutableRefObject<CometChat.BaseMessage | null | undefined>;
19
+ selectedMessage: CometChat.BaseMessage | null;
20
+ hideReactionOption: boolean;
21
+ quickReactionList?: [string, string?, string?, string?, string?];
22
+ templatesMap: Map<string, CometChatMessageTemplate>;
23
+ mergedTheme: CometChatTheme;
24
+ deleteItem: React.MutableRefObject<CometChat.BaseMessage | undefined>;
25
+ pendingReportRef: React.MutableRefObject<boolean>;
26
+ onClose: () => void;
27
+ onDismiss?: () => void;
28
+ onReactionPress: (emoji: string, message?: CometChat.BaseMessage) => void;
29
+ onAddReactionPress?: () => void;
30
+ setShowDeleteModal: (show: boolean) => void;
31
+ setShowReportDialog: (show: boolean) => void;
32
+ setShowMessageOptions: (options: any[]) => void;
33
+ setExtensionsComponent: (component: React.JSX.Element | null) => void;
34
+ setMessageInfo: (show: boolean) => void;
35
+ setShowEmojiKeyboard: (show: boolean) => void;
36
+ }
37
+
38
+ export const MessageOptionsSheet: React.FC<MessageOptionsSheetProps> = ({
39
+ bottomSheetRef,
40
+ isOpen,
41
+ showMessageOptions,
42
+ ExtensionsComponent,
43
+ messageInfo,
44
+ infoObject,
45
+ selectedMessage,
46
+ hideReactionOption,
47
+ quickReactionList,
48
+ templatesMap,
49
+ mergedTheme,
50
+ deleteItem,
51
+ pendingReportRef,
52
+ onClose,
53
+ onDismiss,
54
+ onReactionPress,
55
+ onAddReactionPress,
56
+ setShowDeleteModal,
57
+ setShowReportDialog,
58
+ setShowMessageOptions,
59
+ setMessageInfo,
60
+ setShowEmojiKeyboard,
61
+ }) => {
62
+ return (
63
+ <CometChatBottomSheet
64
+ ref={bottomSheetRef}
65
+ onClose={onClose}
66
+ onDismiss={() => {
67
+ // iOS: Open any deferred modals only after dismiss animation completes
68
+ if (Platform.OS === 'ios') {
69
+ if (deleteItem.current) {
70
+ setShowDeleteModal(true);
71
+ }
72
+ if (pendingReportRef.current) {
73
+ pendingReportRef.current = false;
74
+ setShowReportDialog(true);
75
+ }
76
+ }
77
+ onDismiss?.();
78
+ }}
79
+ isOpen={isOpen}
80
+ style={{
81
+ paddingHorizontal: 0,
82
+ maxHeight: messageInfo
83
+ ? Dimensions.get('window').height * 0.9
84
+ : Dimensions.get('window').height * 0.52,
85
+ minHeight: Dimensions.get('window').height * 0.5,
86
+ }}
87
+ >
88
+ {ExtensionsComponent ? (
89
+ ExtensionsComponent
90
+ ) : messageInfo && infoObject.current ? (
91
+ <CometChatMessageInformation
92
+ message={infoObject.current}
93
+ template={templatesMap.get(
94
+ `${infoObject.current?.getCategory()}_${infoObject.current?.getType()}`
95
+ )}
96
+ onBack={() => {
97
+ infoObject.current = null;
98
+ setMessageInfo(false);
99
+ }}
100
+ style={mergedTheme?.messageListStyles?.messageInformationStyles}
101
+ />
102
+ ) : (
103
+ <View style={{ flex: 1 }}>
104
+ {/* Show quick reactions for disapproved messages */}
105
+ {!hideReactionOption && getModerationStatus(selectedMessage) !== 'disapproved' && (
106
+ <CometChatQuickReactions
107
+ quickReactions={quickReactionList}
108
+ onReactionPress={onReactionPress}
109
+ onAddReactionPress={
110
+ onAddReactionPress ??
111
+ (() => {
112
+ setShowMessageOptions([]);
113
+ setTimeout(() => {
114
+ setShowEmojiKeyboard(true);
115
+ }, 200);
116
+ })
117
+ }
118
+ style={mergedTheme.quickReactionStyle}
119
+ />
120
+ )}
121
+
122
+ <CometChatActionSheet
123
+ actions={showMessageOptions}
124
+ style={mergedTheme.messageListStyles.messageOptionsStyles}
125
+ />
126
+ </View>
127
+ )}
128
+ </CometChatBottomSheet>
129
+ );
130
+ };
@@ -0,0 +1,70 @@
1
+ import React from 'react';
2
+ import { Dimensions } from 'react-native';
3
+ import { CometChat } from '@cometchat/chat-sdk-react-native';
4
+ import { CometChatBottomSheet } from '../../shared/views';
5
+ import { CometChatEmojiKeyboard } from '../../shared/views/CometChatEmojiKeyboard';
6
+ import { CometChatReactionList } from '../../shared/views/CometChatReactionList';
7
+
8
+ interface ReactionModalsProps {
9
+ showEmojiKeyboard: boolean;
10
+ showReactionList: boolean;
11
+ selectedMessage: CometChat.BaseMessage | null;
12
+ selectedEmoji: string | undefined;
13
+ reactionsRequestBuilder?: CometChat.ReactionsRequestBuilder;
14
+ onReactionListItemPress?: (reaction: CometChat.Reaction, message: CometChat.BaseMessage) => void;
15
+ onEmojiSelect: (emoji: string, message: CometChat.BaseMessage) => void;
16
+ onEmojiKeyboardClose: () => void;
17
+ onReactionListClose: () => void;
18
+ onReactionListEmpty: () => void;
19
+ }
20
+
21
+ export const ReactionModals: React.FC<ReactionModalsProps> = ({
22
+ showEmojiKeyboard,
23
+ showReactionList,
24
+ selectedMessage,
25
+ selectedEmoji,
26
+ reactionsRequestBuilder,
27
+ onReactionListItemPress,
28
+ onEmojiSelect,
29
+ onEmojiKeyboardClose,
30
+ onReactionListClose,
31
+ onReactionListEmpty,
32
+ }) => {
33
+ return (
34
+ <>
35
+ <CometChatBottomSheet
36
+ isOpen={showEmojiKeyboard}
37
+ onClose={onEmojiKeyboardClose}
38
+ style={{
39
+ maxHeight: Dimensions.get('window').height * 0.49,
40
+ }}
41
+ >
42
+ <CometChatEmojiKeyboard
43
+ onClick={(item) => {
44
+ onEmojiKeyboardClose();
45
+ if (selectedMessage) {
46
+ onEmojiSelect(item, selectedMessage);
47
+ }
48
+ }}
49
+ />
50
+ </CometChatBottomSheet>
51
+
52
+ <CometChatBottomSheet
53
+ isOpen={showReactionList}
54
+ onClose={onReactionListClose}
55
+ style={{
56
+ maxHeight: Dimensions.get('window').height * 0.7,
57
+ minHeight: Dimensions.get('window').height * 0.3,
58
+ }}
59
+ >
60
+ <CometChatReactionList
61
+ message={selectedMessage!}
62
+ selectedReaction={selectedEmoji}
63
+ onPress={onReactionListItemPress}
64
+ reactionsRequestBuilder={reactionsRequestBuilder}
65
+ onListEmpty={onReactionListEmpty}
66
+ />
67
+ </CometChatBottomSheet>
68
+ </>
69
+ );
70
+ };
@@ -19,6 +19,9 @@ import { deepMerge } from "../shared/helper/helperFunctions";
19
19
  import { CommonUtils } from "../shared/utils/CommonUtils";
20
20
  import { DeepPartial } from "../shared/helper/types";
21
21
  import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
22
+ import { ExtensionConstants } from "../extensions";
23
+ import { getExtensionData } from "../shared/helper/functions";
24
+ import { urlPattern } from "../shared/constants/UIKitConstants";
22
25
 
23
26
  /**
24
27
  * Unique UI event identifier for CometChatUIEventHandler.
@@ -234,10 +237,29 @@ export const CometChatThreadHeader = (props: CometChatThreadHeaderInterface): JS
234
237
  };
235
238
  }, []);
236
239
 
240
+ // Check if message has URLs (link preview or URLs in text)
241
+ const hasUrl = useMemo(() => {
242
+ // Check for link preview extension data
243
+ const linkData = getExtensionData(message, ExtensionConstants.linkPreview);
244
+ if (linkData && linkData.links && linkData.links.length > 0) {
245
+ return true;
246
+ }
247
+
248
+ // Check if text message contains URLs
249
+ if (message.getType() === "text") {
250
+ const textMessage = message as CometChat.TextMessage;
251
+ const text = textMessage.getText() || "";
252
+ const urlRegex = new RegExp(urlPattern);
253
+ return urlRegex.test(text);
254
+ }
255
+
256
+ return false;
257
+ }, [message]);
258
+
237
259
  return (
238
260
  <View style={[style?.containerStyle]}>
239
261
  <ScrollView style={style?.messageBubbleContainerStyle}>
240
- <View pointerEvents='none'>
262
+ <View pointerEvents={hasUrl ? 'auto' : 'none'}>
241
263
  {MessageUtils.getMessageView({
242
264
  message,
243
265
  templates:
@@ -5,6 +5,7 @@ import {
5
5
  CometChatList,
6
6
  CometChatListActionsInterface,
7
7
  CometChatListProps,
8
+ CometChatRetryButton,
8
9
  } from "../shared";
9
10
  import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
10
11
  import { deepMerge } from "../shared/helper/helperFunctions";
@@ -404,6 +405,7 @@ export const CometChatUsers = React.forwardRef<
404
405
  // Hide search when error view is active.
405
406
  setHideSearchError(true);
406
407
  }, []);
408
+ if (hideError) return null;
407
409
  return (
408
410
  <View style={{ flex: 1 }}>
409
411
  <ErrorEmptyView
@@ -428,10 +430,11 @@ export const CometChatUsers = React.forwardRef<
428
430
  }}
429
431
  titleStyle={mergedStyle.errorStateStyle.titleStyle}
430
432
  subTitleStyle={mergedStyle.errorStateStyle.subTitleStyle}
433
+ RetryView={<CometChatRetryButton onPress={() => userRef.current?.reload()} />}
431
434
  />
432
435
  </View>
433
436
  );
434
- }, [theme, mergedStyle]);
437
+ }, [theme, mergedStyle, hideError]);
435
438
 
436
439
  return (
437
440
  <View style={theme.userStyles.containerStyle}>
@@ -9,7 +9,7 @@ import {
9
9
  GestureResponderEvent,
10
10
  ActivityIndicator,
11
11
  } from "react-native";
12
- import { CometChatAvatar} from "../../shared";
12
+ import { CometChatAvatar, CometChatRetryButton } from "../../shared";
13
13
  import { CallTypeConstants } from "../../shared/constants/UIKitConstants";
14
14
  import { CometChatUIEventHandler } from "../../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
15
15
  import { CallUIEvents } from "../CallEvents";
@@ -48,7 +48,7 @@ export interface CometChatCallLogsConfigurationInterface {
48
48
  /** Custom component to render as the entire item view for each call log */
49
49
  ItemView?: (call?: any) => JSX.Element;
50
50
  /** Custom component to render as the trailing view for each call log item */
51
- TrailingView?: (call?: any) => JSX.Element;
51
+ TrailingView?: (call?: any, defaultOnPress?: (call: any) => void) => JSX.Element;
52
52
  /** Custom options to render in the AppBar */
53
53
  AppBarOptions?: () => JSX.Element;
54
54
  /** Builder for custom call log requests */
@@ -212,16 +212,17 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
212
212
  const reqBuilder = callLogRequestBuilder
213
213
  ? callLogRequestBuilder.setAuthToken(loggedInUser.current!.getAuthToken())
214
214
  : new CometChatCalls.CallLogRequestBuilder()
215
- .setLimit(30)
216
- .setAuthToken(loggedInUser.current!.getAuthToken() || "")
217
- .setCallCategory("call");
215
+ .setLimit(30)
216
+ .setAuthToken(loggedInUser.current!.getAuthToken() || "")
217
+ .setCallCategory("call");
218
218
  callLogRequestBuilderRef.current = reqBuilder.build();
219
219
  }
220
220
 
221
221
  /**
222
222
  * Fetches the call logs using the configured request builder.
223
+ * @param isAppending - If true, appends to existing list (for pagination). If false, replaces the list (for initial load/reload).
223
224
  */
224
- const fetchCallLogs = () => {
225
+ const fetchCallLogs = (isAppending: boolean = true) => {
225
226
  setListState("loading");
226
227
  callLogRequestBuilderRef
227
228
  .current!.fetchNext()
@@ -230,12 +231,12 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
230
231
  setHasMoreData(false);
231
232
  }
232
233
  if (callLogs.length > 0) {
233
- const updatedList = [...list, ...callLogs];
234
+ const updatedList = isAppending ? [...list, ...callLogs] : callLogs;
234
235
  setList(updatedList);
235
236
  onLoad && onLoad(updatedList);
236
237
  } else {
237
238
  // If no new logs are returned and the current list is empty, trigger onEmpty
238
- if (list.length === 0) {
239
+ if (list.length === 0 || !isAppending) {
239
240
  onEmpty && onEmpty();
240
241
  }
241
242
  }
@@ -247,6 +248,17 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
247
248
  });
248
249
  };
249
250
 
251
+ /**
252
+ * Reloads the call logs by resetting the request builder and fetching fresh data.
253
+ * This matches the behavior of other tabs (Chats, Groups, Users).
254
+ */
255
+ const reloadCallLogs = () => {
256
+ setList([]);
257
+ setHasMoreData(true);
258
+ setRequestBuilder();
259
+ fetchCallLogs(false);
260
+ };
261
+
250
262
  // Setup logged-in user and call listeners on mount.
251
263
  useEffect(() => {
252
264
  CometChat.getLoggedinUser()
@@ -454,16 +466,16 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
454
466
  SubtitleView(item)
455
467
  ) : (
456
468
  <Text style={mergedCallLogsStyle.itemStyle.subTitleTextStyle}>
457
- {formatDate(
458
- item["initiatedAt"] * 1000,
459
- datePattern ?? LocalizedDateHelper.patterns.callLogs
460
- )}
469
+ {formatDate(
470
+ item["initiatedAt"] * 1000,
471
+ datePattern ?? LocalizedDateHelper.patterns.callLogs
472
+ )}
461
473
  </Text>
462
474
  )}
463
475
  </View>
464
476
  </View>
465
477
  {TrailingView ? (
466
- TrailingView(item)
478
+ TrailingView(item,onPress)
467
479
  ) : (
468
480
  <TouchableOpacity
469
481
  onPress={() => onPress(item)}
@@ -489,7 +501,6 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
489
501
  */
490
502
  const ErrorStateView = useCallback(() => {
491
503
  if (hideError) return null;
492
- if (ErrorView) return <ErrorView />;
493
504
  return (
494
505
  <ErrorEmptyView
495
506
  title={t("OOPS")}
@@ -507,27 +518,7 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
507
518
  containerStyle={Style.errorEmptyContainer}
508
519
  titleStyle={mergedCallLogsStyle.errorStateStyle?.titleStyle}
509
520
  subTitleStyle={mergedCallLogsStyle.errorStateStyle?.subTitleStyle}
510
- RetryView={
511
- <TouchableOpacity
512
- onPress={fetchCallLogs}
513
- style={{
514
- backgroundColor: theme.color.primary,
515
- paddingVertical: theme.spacing.spacing.s3,
516
- paddingHorizontal: theme.spacing.spacing.s10,
517
- borderRadius: theme.spacing.radius.r2,
518
- marginTop: theme.spacing.spacing.s5,
519
- }}
520
- >
521
- <Text
522
- style={{
523
- color: theme.color.primaryButtonIcon,
524
- ...theme.typography.button.medium,
525
- }}
526
- >
527
- {t("RETRY")}
528
- </Text>
529
- </TouchableOpacity>
530
- }
521
+ RetryView={<CometChatRetryButton onPress={reloadCallLogs} />}
531
522
  />
532
523
  );
533
524
  }, [theme]);
@@ -633,7 +624,7 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
633
624
  keyExtractor={(item, index) => item.sessionId + "_" + index}
634
625
  extraData={{ list, listState }}
635
626
  renderItem={_render}
636
- onEndReached={fetchCallLogs}
627
+ onEndReached={() => fetchCallLogs(true)}
637
628
  ListFooterComponent={renderFooter}
638
629
  />
639
630
  )}
@@ -1,4 +1,4 @@
1
- import React, { JSX, useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
1
+ import React, { JSX, useCallback, useRef, useState } from "react";
2
2
  import {
3
3
  Alert,
4
4
  DimensionValue,
@@ -67,6 +67,8 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
67
67
  uri: favicon.startsWith("https:") ? favicon : `https:${favicon.split("http:")[1]}`,
68
68
  });
69
69
 
70
+ const [faviconError, setFaviconError] = useState(false);
71
+
70
72
  const pressTime = useRef<number | null>(0);
71
73
 
72
74
  /**
@@ -80,7 +82,6 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
80
82
  * Handles the touch end event. If the press duration is less than 500ms, it triggers the onPress callback or opens the link.
81
83
  */
82
84
  const handleTouchEnd = async () => {
83
- if (pressTime.current === null && Platform.OS === "ios") return;
84
85
  const endTime = Date.now();
85
86
  const pressDuration = endTime - (pressTime.current ?? 0);
86
87
  if (pressDuration < 500) {
@@ -138,7 +139,12 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
138
139
  );
139
140
 
140
141
  return (
141
- <View style={{ flex: 1 }} onLayout={onLayoutHandler}>
142
+ <View
143
+ onLayout={onLayoutHandler}
144
+ onTouchStart={handleTouchStart}
145
+ onTouchEnd={handleTouchEnd}
146
+ onTouchMove={onTouchMove}
147
+ >
142
148
  <View
143
149
  style={style?.headerImageContainerStyle}
144
150
  onTouchStart={handleTouchStart}
@@ -162,15 +168,17 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
162
168
  </Text>
163
169
  </View>
164
170
 
165
- <View style={style?.bodyStyle?.faviconContainerStyle}>
166
- <Image
167
- source={faviconSource}
168
- style={style?.bodyStyle?.faviconStyle}
169
- onError={(err) => {
170
- setImageSource(DefaultLinkPreview);
171
- }}
172
- />
173
- </View>
171
+ {!faviconError && (
172
+ <View style={style?.bodyStyle?.faviconContainerStyle}>
173
+ <Image
174
+ source={faviconSource}
175
+ style={style?.bodyStyle?.faviconStyle}
176
+ onError={(err) => {
177
+ setFaviconError(true);
178
+ }}
179
+ />
180
+ </View>
181
+ )}
174
182
  </View>
175
183
  <View style={style?.bodyStyle?.subtitleContainerStyle}>
176
184
  <Text style={style?.bodyStyle?.subtitleTitle} numberOfLines={2} ellipsizeMode='tail'>
@@ -185,6 +193,7 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
185
193
  style={{
186
194
  paddingVertical: theme.spacing.padding.p3,
187
195
  paddingHorizontal: style?.bodyStyle?.containerStyle.padding,
196
+ flexShrink: 0,
188
197
  }}
189
198
  >
190
199
  {ChildView && <ChildView />}
@@ -29,6 +29,7 @@ export type AdditionalParams = {
29
29
  hideCopyMessageOption?: boolean,
30
30
  hideMessageInfoOption?: boolean,
31
31
  hideReportMessageOption?: boolean,
32
+ hideMarkAsUnreadOption?: boolean,
32
33
  hideGroupActionMessages?: boolean,
33
34
  onReplyClick?: (messageId: string) => void;
34
35
  };