@cometchat/chat-uikit-react-native 5.2.8 → 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.
- package/package.json +1 -1
- package/src/CometChatConversations/CometChatConversations.tsx +8 -1
- package/src/CometChatGroups/CometChatGroups.tsx +5 -3
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +55 -8
- package/src/CometChatMessageList/CometChatMessageList.tsx +1169 -548
- package/src/CometChatMessageList/components/MessageListItem.tsx +127 -0
- package/src/CometChatMessageList/components/MessageModals.tsx +60 -0
- package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +130 -0
- package/src/CometChatMessageList/components/ReactionModals.tsx +70 -0
- package/src/CometChatUsers/CometChatUsers.tsx +4 -1
- package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +27 -36
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +13 -9
- package/src/shared/base/Types.ts +1 -0
- package/src/shared/constants/UIKitConstants.ts +1 -0
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +4 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -1
- package/src/shared/events/conversations.ts +1 -0
- package/src/shared/framework/MessageDataSource.tsx +79 -17
- package/src/shared/index.ts +2 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +3 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +3 -1
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +7 -4
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +20 -12
- package/src/shared/views/CometChatBadge/CometChatBadge.tsx +6 -3
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +2 -1
- package/src/shared/views/CometChatList/CometChatList.tsx +20 -1
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +2 -3
- package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +55 -0
- package/src/shared/views/CometChatNewMessageIndicator/index.ts +3 -0
- package/src/shared/views/CometChatNewMessageIndicator/styles.ts +33 -0
- package/src/shared/views/CometChatRetryButton/CometChatRetryButton.tsx +54 -0
- package/src/shared/views/CometChatRetryButton/index.ts +3 -0
- 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
|
+
};
|
|
@@ -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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
458
|
-
|
|
459
|
-
|
|
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
|
)}
|
|
@@ -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
|
/**
|
|
@@ -166,15 +168,17 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
|
|
|
166
168
|
</Text>
|
|
167
169
|
</View>
|
|
168
170
|
|
|
169
|
-
|
|
170
|
-
<
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
+
)}
|
|
178
182
|
</View>
|
|
179
183
|
<View style={style?.bodyStyle?.subtitleContainerStyle}>
|
|
180
184
|
<Text style={style?.bodyStyle?.subtitleTitle} numberOfLines={2} ellipsizeMode='tail'>
|
package/src/shared/base/Types.ts
CHANGED
|
@@ -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
|
};
|
|
@@ -235,6 +235,7 @@ export const MessageOptionConstants = {
|
|
|
235
235
|
sendMessagePrivately: "sendMessagePrivately",
|
|
236
236
|
replyMessagePrivately: "replyMessagePrivately",
|
|
237
237
|
reportMessage: "reportMessage",
|
|
238
|
+
markAsUnread: "markAsUnread",
|
|
238
239
|
};
|
|
239
240
|
|
|
240
241
|
export const CometChatMessageTypes = Object.freeze({
|
|
@@ -232,6 +232,10 @@ export class CometChatUIEventHandler {
|
|
|
232
232
|
case listener._eventListener?.ccConversationDeleted?.name:
|
|
233
233
|
listener._eventListener?.ccConversationDeleted?.(param);
|
|
234
234
|
break;
|
|
235
|
+
//added for markAsUnread
|
|
236
|
+
case listener._eventListener?.ccUpdateConversation?.name:
|
|
237
|
+
listener._eventListener?.ccUpdateConversation?.(param);
|
|
238
|
+
break;
|
|
235
239
|
}
|
|
236
240
|
});
|
|
237
241
|
}
|
|
@@ -344,11 +344,14 @@ export class UserCallUIEventListener {
|
|
|
344
344
|
|
|
345
345
|
type ConversationUIEvents = {
|
|
346
346
|
ccConversationDeleted?: Function;
|
|
347
|
+
ccUpdateConversation?: Function;
|
|
347
348
|
};
|
|
348
349
|
export class ConversationUIEventListener {
|
|
349
350
|
ccConversationDeleted?: Function;
|
|
350
|
-
|
|
351
|
+
ccUpdateConversation?: Function;
|
|
352
|
+
constructor({ ccConversationDeleted, ccUpdateConversation }: ConversationUIEvents) {
|
|
351
353
|
if (!isFalsy(ccConversationDeleted)) this.ccConversationDeleted = ccConversationDeleted;
|
|
354
|
+
if (!isFalsy(ccUpdateConversation)) this.ccUpdateConversation = ccUpdateConversation;
|
|
352
355
|
}
|
|
353
356
|
}
|
|
354
357
|
|