@cometchat/chat-uikit-react-native 5.0.0-beta.1 → 5.0.0
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/README.md +2 -3
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +29 -44
- package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +12 -0
- package/ios/FileManager.m +26 -9
- package/package.json +11 -36
- package/src/CometChatConversations/CometChatConversations.tsx +287 -147
- package/src/CometChatConversations/Skeleton.tsx +116 -73
- package/src/CometChatConversations/style.ts +17 -22
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +439 -227
- package/src/CometChatGroupMembers/style.ts +2 -4
- package/src/CometChatGroups/CometChatGroups.tsx +239 -135
- package/src/CometChatGroups/GroupsStyle.ts +20 -17
- package/src/CometChatGroups/Skeleton.tsx +198 -288
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +208 -73
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +97 -43
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +4 -2
- package/src/CometChatMessageList/CometChatMessageList.tsx +200 -76
- package/src/CometChatMessageList/style.ts +4 -4
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +77 -11
- package/src/CometChatThreadHeader/style.ts +2 -2
- package/src/CometChatUsers/CometChatUsers.tsx +203 -51
- package/src/CometChatUsers/Skeleton.tsx +174 -159
- package/src/CometChatUsers/style.ts +21 -18
- package/src/calls/CallingConfiguration.ts +4 -3
- package/src/calls/CallingExtensionDecorator.tsx +5 -3
- package/src/calls/CometChatCallButtons/CometChatCallButtonConfiguration.ts +4 -2
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +10 -8
- package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +240 -97
- package/src/calls/CometChatCallLogs/Skeleton.tsx +175 -91
- package/src/calls/CometChatCallLogs/index.ts +1 -0
- package/src/calls/CometChatCallLogs/style.ts +85 -43
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +42 -29
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +36 -10
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +39 -12
- package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +5 -4
- package/src/extensions/Polls/PollsDecorator.tsx +30 -9
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +34 -16
- package/src/index.ts +3 -1
- package/src/shared/base/Types.ts +31 -1
- package/src/shared/framework/DataSource.ts +64 -20
- package/src/shared/framework/DataSourceDecorator.tsx +46 -37
- package/src/shared/framework/MessageDataSource.tsx +518 -316
- package/src/shared/index.ts +3 -1
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +3 -2
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +3 -2
- package/src/shared/utils/MessageUtils.tsx +41 -20
- package/src/shared/utils/conversationUtils.ts +2 -2
- package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +22 -1
- package/src/shared/views/CometChatBadge/CometChatBadge.tsx +20 -8
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +177 -123
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +76 -10
- package/src/shared/views/CometChatConfirmDialog/style.ts +2 -2
- package/src/shared/views/CometChatDate/CometChatDate.tsx +26 -18
- package/src/shared/views/CometChatDateSeperator/CometChatDateSeparator.tsx +22 -16
- package/src/shared/views/CometChatDeletedBubble/CometChatDeletedBubble.tsx +17 -5
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +65 -35
- package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +22 -11
- package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +47 -18
- package/src/shared/views/CometChatList/CometChatList.tsx +70 -46
- package/src/shared/views/CometChatList/Header.tsx +122 -37
- package/src/shared/views/CometChatList/styles.ts +1 -0
- package/src/shared/views/CometChatListItem/CometChatListItem.tsx +116 -30
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +52 -30
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +36 -22
- package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +41 -13
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +132 -17
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +30 -2
- package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +10 -6
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +20 -13
- package/src/shared/views/CometChatStatusIndicator/styles.ts +26 -13
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +25 -2
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +94 -14
- package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +52 -16
- package/src/shared/views/CometChatTooltipMenu/index.ts +2 -1
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +29 -9
- package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +20 -2
- package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +29 -14
- package/src/shared/views/index.ts +2 -0
- package/src/theme/default/index.ts +5 -5
- package/src/theme/type.ts +2 -2
- package/src/shared/views/CometChatPanel/CometChatPanel.tsx +0 -57
- package/src/shared/views/CometChatPanel/PanelStyle.tsx +0 -43
- package/src/shared/views/CometChatPanel/resources/CloseIcon.png +0 -0
- package/src/shared/views/CometChatPanel/resources/index.ts +0 -3
|
@@ -3,11 +3,11 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
|
|
3
3
|
import {
|
|
4
4
|
FlatList,
|
|
5
5
|
Image,
|
|
6
|
-
ImageSourcePropType,
|
|
7
|
-
RefreshControl,
|
|
8
6
|
Text,
|
|
9
7
|
TouchableOpacity,
|
|
10
8
|
View,
|
|
9
|
+
GestureResponderEvent,
|
|
10
|
+
ActivityIndicator,
|
|
11
11
|
} from "react-native";
|
|
12
12
|
import { CometChatAvatar, localize } from "../../shared";
|
|
13
13
|
import { CallTypeConstants } from "../../shared/constants/UIKitConstants";
|
|
@@ -26,6 +26,7 @@ import { Skeleton } from "./Skeleton";
|
|
|
26
26
|
import { CometChatTheme } from "../../theme/type";
|
|
27
27
|
import { deepMerge } from "../../shared/helper/helperFunctions";
|
|
28
28
|
import { DeepPartial, ValueOf } from "../../shared/helper/types";
|
|
29
|
+
import { CometChatTooltipMenu, MenuItemInterface } from "../../shared/views/CometChatTooltipMenu";
|
|
29
30
|
|
|
30
31
|
const listenerId = "callEventListener_" + new Date().getTime();
|
|
31
32
|
const CometChatCalls = CallingPackage.CometChatCalls;
|
|
@@ -53,7 +54,7 @@ export interface CometChatCallLogsConfigurationInterface {
|
|
|
53
54
|
/** Date format pattern for call logs */
|
|
54
55
|
datePattern?: ValueOf<typeof DateHelper.patterns>;
|
|
55
56
|
/** Flag to hide the back button in the header */
|
|
56
|
-
|
|
57
|
+
showBackButton?: boolean;
|
|
57
58
|
/** Custom component to render when the call log list is empty */
|
|
58
59
|
EmptyView?: () => JSX.Element;
|
|
59
60
|
/** Custom component to render in case of an error */
|
|
@@ -68,12 +69,33 @@ export interface CometChatCallLogsConfigurationInterface {
|
|
|
68
69
|
onError?: (e: CometChat.CometChatException) => void;
|
|
69
70
|
/** Callback for when the back button is pressed */
|
|
70
71
|
onBack?: () => void;
|
|
71
|
-
/**
|
|
72
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Callback for when a call log item is pressed.
|
|
74
|
+
* Receives the raw call log object.
|
|
75
|
+
*/
|
|
76
|
+
onItemPress?: (call: any) => void;
|
|
73
77
|
/** Custom style overrides for the call logs */
|
|
74
78
|
style?: DeepPartial<CometChatTheme["callLogsStyles"]>;
|
|
75
79
|
/** Configuration for outgoing calls */
|
|
76
80
|
outgoingCallConfiguration?: CometChatOutgoingCallInterface;
|
|
81
|
+
/** Callback when the list is fetched and loaded */
|
|
82
|
+
onLoad?: (list: any[]) => void;
|
|
83
|
+
/** Callback when the list is empty (no items) */
|
|
84
|
+
onEmpty?: () => void;
|
|
85
|
+
/** Called on a long press of the default list item view */
|
|
86
|
+
onItemLongPress?: (prop: { call: any }) => void;
|
|
87
|
+
/** Hide the toolbar header */
|
|
88
|
+
hideHeader?: boolean;
|
|
89
|
+
/** Hide the loading state */
|
|
90
|
+
hideLoadingState?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* A function to **append** more menu items on top of the default menu items for a call log.
|
|
93
|
+
*/
|
|
94
|
+
addOptions?: (call: any) => MenuItemInterface[];
|
|
95
|
+
/**
|
|
96
|
+
* A function to **replace** the default menu items entirely for a call log.
|
|
97
|
+
*/
|
|
98
|
+
options?: (call: any) => MenuItemInterface[];
|
|
77
99
|
}
|
|
78
100
|
|
|
79
101
|
/**
|
|
@@ -94,7 +116,7 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
94
116
|
TrailingView,
|
|
95
117
|
AppBarOptions,
|
|
96
118
|
callLogRequestBuilder,
|
|
97
|
-
|
|
119
|
+
showBackButton = false,
|
|
98
120
|
EmptyView,
|
|
99
121
|
ErrorView,
|
|
100
122
|
LoadingView,
|
|
@@ -106,31 +128,90 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
106
128
|
style,
|
|
107
129
|
outgoingCallConfiguration,
|
|
108
130
|
datePattern,
|
|
131
|
+
onLoad,
|
|
132
|
+
onEmpty,
|
|
133
|
+
onItemLongPress,
|
|
134
|
+
hideHeader,
|
|
135
|
+
hideLoadingState,
|
|
136
|
+
addOptions,
|
|
137
|
+
options,
|
|
109
138
|
} = props;
|
|
110
139
|
|
|
111
140
|
const [list, setList] = useState<any[]>([]);
|
|
112
141
|
const [listState, setListState] = useState<"loading" | "error" | "done">("loading");
|
|
113
142
|
const [showOutgoingCallScreen, setShowOutgoingCallScreen] = useState(false);
|
|
114
|
-
|
|
143
|
+
|
|
144
|
+
const theme = useTheme();
|
|
115
145
|
const mergedCallLogsStyle = useMemo(() => {
|
|
116
|
-
return deepMerge(
|
|
117
|
-
}, [
|
|
146
|
+
return deepMerge(theme.callLogsStyles, style ?? {});
|
|
147
|
+
}, [theme, style]);
|
|
118
148
|
|
|
119
149
|
const loggedInUser = useRef<CometChat.User>();
|
|
120
150
|
const callLogRequestBuilderRef = useRef<any>();
|
|
121
151
|
const outGoingCall = useRef<CometChat.Call | CometChat.CustomMessage>();
|
|
122
152
|
|
|
153
|
+
// State for tooltip functionality
|
|
154
|
+
const [tooltipVisible, setTooltipVisible] = useState<boolean>(false);
|
|
155
|
+
const [selectedCall, setSelectedCall] = useState<any>(null);
|
|
156
|
+
const tooltipPosition = useRef<{ pageX: number; pageY: number }>({
|
|
157
|
+
pageX: 0,
|
|
158
|
+
pageY: 0,
|
|
159
|
+
});
|
|
160
|
+
const [hasMoreData, setHasMoreData] = useState(true);
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Function to build the list of menu items for the tooltip:
|
|
164
|
+
* - `options(call)` completely replaces defaults
|
|
165
|
+
* - `addOptions(call)` appends to the default
|
|
166
|
+
* - No default menu items in this snippet; so defaults is an empty array
|
|
167
|
+
*/
|
|
168
|
+
const buildMenuItems = (call: any): MenuItemInterface[] => {
|
|
169
|
+
if (options) {
|
|
170
|
+
return options(call);
|
|
171
|
+
}
|
|
172
|
+
let defaultMenuItems: MenuItemInterface[] = []; // no default items here
|
|
173
|
+
if (addOptions) {
|
|
174
|
+
return [...defaultMenuItems, ...addOptions(call)];
|
|
175
|
+
}
|
|
176
|
+
return defaultMenuItems;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Show tooltip if user hasn't provided a custom onItemLongPress.
|
|
181
|
+
*/
|
|
182
|
+
const handleItemLongPress = (call: any, e?: GestureResponderEvent) => {
|
|
183
|
+
if (onItemLongPress) {
|
|
184
|
+
// If the developer has provided a custom long-press handler, call that and return.
|
|
185
|
+
onItemLongPress({ call });
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
// Otherwise, show the tooltip if there are menu items
|
|
189
|
+
const items = buildMenuItems(call);
|
|
190
|
+
if (items.length === 0) return;
|
|
191
|
+
|
|
192
|
+
if (e && e.nativeEvent) {
|
|
193
|
+
tooltipPosition.current = {
|
|
194
|
+
pageX: e.nativeEvent.pageX,
|
|
195
|
+
pageY: e.nativeEvent.pageY,
|
|
196
|
+
};
|
|
197
|
+
} else {
|
|
198
|
+
tooltipPosition.current = { pageX: 200, pageY: 100 };
|
|
199
|
+
}
|
|
200
|
+
setSelectedCall(call);
|
|
201
|
+
setTooltipVisible(true);
|
|
202
|
+
};
|
|
203
|
+
|
|
123
204
|
/**
|
|
124
205
|
* Initializes the call log request builder.
|
|
125
206
|
*/
|
|
126
207
|
function setRequestBuilder() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
new CometChatCalls.CallLogRequestBuilder()
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
208
|
+
const reqBuilder = callLogRequestBuilder
|
|
209
|
+
? callLogRequestBuilder.setAuthToken(loggedInUser.current!.getAuthToken())
|
|
210
|
+
: new CometChatCalls.CallLogRequestBuilder()
|
|
211
|
+
.setLimit(30)
|
|
212
|
+
.setAuthToken(loggedInUser.current!.getAuthToken() || "")
|
|
213
|
+
.setCallCategory("call");
|
|
214
|
+
callLogRequestBuilderRef.current = reqBuilder.build();
|
|
134
215
|
}
|
|
135
216
|
|
|
136
217
|
/**
|
|
@@ -141,8 +222,18 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
141
222
|
callLogRequestBuilderRef
|
|
142
223
|
.current!.fetchNext()
|
|
143
224
|
.then((callLogs: any) => {
|
|
225
|
+
if (callLogRequestBuilderRef.current!.limit > callLogs.length) {
|
|
226
|
+
setHasMoreData(false);
|
|
227
|
+
}
|
|
144
228
|
if (callLogs.length > 0) {
|
|
145
|
-
|
|
229
|
+
const updatedList = [...list, ...callLogs];
|
|
230
|
+
setList(updatedList);
|
|
231
|
+
onLoad && onLoad(updatedList);
|
|
232
|
+
} else {
|
|
233
|
+
// If no new logs are returned and the current list is empty, trigger onEmpty
|
|
234
|
+
if (list.length === 0) {
|
|
235
|
+
onEmpty && onEmpty();
|
|
236
|
+
}
|
|
146
237
|
}
|
|
147
238
|
setListState("done");
|
|
148
239
|
})
|
|
@@ -186,6 +277,12 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
186
277
|
setShowOutgoingCallScreen(false);
|
|
187
278
|
},
|
|
188
279
|
});
|
|
280
|
+
|
|
281
|
+
return () => {
|
|
282
|
+
// Cleanup call listeners when component unmounts
|
|
283
|
+
CometChat.removeCallListener(listenerId);
|
|
284
|
+
CometChatUIEventHandler.removeCallListener(listenerId);
|
|
285
|
+
};
|
|
189
286
|
}, []);
|
|
190
287
|
|
|
191
288
|
/**
|
|
@@ -196,7 +293,6 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
196
293
|
*/
|
|
197
294
|
const makeCall = (call: any, type: any) => {
|
|
198
295
|
if (type == CallTypeConstants.audio || type == CallTypeConstants.video) {
|
|
199
|
-
// Determine the user or group to call based on the call log item.
|
|
200
296
|
let user =
|
|
201
297
|
call?.getReceiverType() == "user"
|
|
202
298
|
? loggedInUser.current?.getUid() === call?.getInitiator()?.getUid()
|
|
@@ -215,8 +311,8 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
215
311
|
var receiverType = user
|
|
216
312
|
? CometChat.RECEIVER_TYPE.USER
|
|
217
313
|
: group
|
|
218
|
-
|
|
219
|
-
|
|
314
|
+
? CometChat.RECEIVER_TYPE.GROUP
|
|
315
|
+
: undefined;
|
|
220
316
|
if (!receiverID || !receiverType) return;
|
|
221
317
|
|
|
222
318
|
var callObject = new CometChat.Call(
|
|
@@ -241,20 +337,13 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
241
337
|
}
|
|
242
338
|
);
|
|
243
339
|
} else {
|
|
244
|
-
console.log(
|
|
245
|
-
"Invalid call type.",
|
|
246
|
-
type,
|
|
247
|
-
CallTypeConstants.audio,
|
|
248
|
-
type != CallTypeConstants.audio || type != CallTypeConstants.video
|
|
249
|
-
);
|
|
340
|
+
console.log("Invalid call type.", type);
|
|
250
341
|
return;
|
|
251
342
|
}
|
|
252
343
|
};
|
|
253
344
|
|
|
254
345
|
/**
|
|
255
346
|
* Handles the press event on the call icon.
|
|
256
|
-
*
|
|
257
|
-
* @param {any} item - The call log item.
|
|
258
347
|
*/
|
|
259
348
|
const onPress = (item: any) => {
|
|
260
349
|
if (onCallIconPress) {
|
|
@@ -268,9 +357,6 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
268
357
|
|
|
269
358
|
/**
|
|
270
359
|
* Extracts and returns call details for display.
|
|
271
|
-
*
|
|
272
|
-
* @param {any} call - The call log item.
|
|
273
|
-
* @returns {object} An object containing the title and avatar URL.
|
|
274
360
|
*/
|
|
275
361
|
const getCallDetails = (call: any) => {
|
|
276
362
|
const { mode, initiator, receiver, receiverType } = call;
|
|
@@ -286,14 +372,14 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
286
372
|
receiverType === "group"
|
|
287
373
|
? receiver["name"]
|
|
288
374
|
: loggedInUser.current?.getUid() == initiator?.getUid()
|
|
289
|
-
|
|
290
|
-
|
|
375
|
+
? receiver["name"]
|
|
376
|
+
: initiator["name"],
|
|
291
377
|
avatarUrl:
|
|
292
378
|
receiverType === "group"
|
|
293
379
|
? receiver["avatar"]
|
|
294
380
|
: loggedInUser.current?.getUid() == initiator?.getUid()
|
|
295
|
-
|
|
296
|
-
|
|
381
|
+
? receiver["avatar"]
|
|
382
|
+
: initiator["avatar"],
|
|
297
383
|
};
|
|
298
384
|
}
|
|
299
385
|
return { title: "", avatarUrl: undefined };
|
|
@@ -301,18 +387,19 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
301
387
|
|
|
302
388
|
/**
|
|
303
389
|
* Renders each call log item.
|
|
304
|
-
*
|
|
305
|
-
* @param {object} param0 - Object containing the item and index.
|
|
306
|
-
* @returns {JSX.Element} The rendered call log item.
|
|
307
390
|
*/
|
|
308
391
|
const _render = ({ item, index }: any) => {
|
|
392
|
+
// If user provides a custom item view, use that
|
|
309
393
|
if (ItemView) return ItemView(item);
|
|
310
394
|
|
|
311
395
|
const { title, avatarUrl } = getCallDetails(item);
|
|
312
396
|
const callStatus = CallUtils.getCallStatusForCallLogs(item, loggedInUser.current!);
|
|
313
397
|
|
|
314
398
|
return (
|
|
315
|
-
<TouchableOpacity
|
|
399
|
+
<TouchableOpacity
|
|
400
|
+
onPress={() => onItemPress?.(item)}
|
|
401
|
+
onLongPress={(e) => handleItemLongPress(item, e)}
|
|
402
|
+
>
|
|
316
403
|
<View style={mergedCallLogsStyle.itemStyle.containerStyle}>
|
|
317
404
|
{LeadingView ? (
|
|
318
405
|
LeadingView(item)
|
|
@@ -346,16 +433,16 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
346
433
|
callStatus === "missed"
|
|
347
434
|
? "call-missed-outgoing"
|
|
348
435
|
: callStatus === "incoming"
|
|
349
|
-
|
|
350
|
-
|
|
436
|
+
? "call-received"
|
|
437
|
+
: "call-made"
|
|
351
438
|
}
|
|
352
439
|
size={16}
|
|
353
440
|
color={
|
|
354
441
|
callStatus === "missed"
|
|
355
442
|
? mergedCallLogsStyle.itemStyle.missedCallStatusIconStyle.tintColor
|
|
356
443
|
: callStatus === "incoming"
|
|
357
|
-
|
|
358
|
-
|
|
444
|
+
? mergedCallLogsStyle.itemStyle.incomingCallStatusIconStyle.tintColor
|
|
445
|
+
: mergedCallLogsStyle.itemStyle.outgoingCallStatusIconStyle.tintColor
|
|
359
446
|
}
|
|
360
447
|
containerStyle={{ marginTop: 2 }}
|
|
361
448
|
/>
|
|
@@ -395,8 +482,6 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
395
482
|
|
|
396
483
|
/**
|
|
397
484
|
* Renders the error view for the call logs.
|
|
398
|
-
*
|
|
399
|
-
* @returns {JSX.Element | null} The error state view.
|
|
400
485
|
*/
|
|
401
486
|
const ErrorStateView = useCallback(() => {
|
|
402
487
|
if (hideError) return null;
|
|
@@ -404,14 +489,14 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
404
489
|
return (
|
|
405
490
|
<ErrorEmptyView
|
|
406
491
|
title='Oops!'
|
|
407
|
-
subTitle=
|
|
408
|
-
tertiaryTitle=
|
|
492
|
+
subTitle={localize("SOMETHING_WENT_WRONG")}
|
|
493
|
+
tertiaryTitle={localize("WRONG_TEXT_TRY_AGAIN")}
|
|
409
494
|
Icon={
|
|
410
495
|
<Icon
|
|
411
496
|
name='error-state'
|
|
412
|
-
size={
|
|
497
|
+
size={theme.spacing.margin.m15 << 1}
|
|
413
498
|
containerStyle={{
|
|
414
|
-
marginBottom:
|
|
499
|
+
marginBottom: theme.spacing.margin.m5,
|
|
415
500
|
}}
|
|
416
501
|
/>
|
|
417
502
|
}
|
|
@@ -422,17 +507,17 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
422
507
|
<TouchableOpacity
|
|
423
508
|
onPress={fetchCallLogs}
|
|
424
509
|
style={{
|
|
425
|
-
backgroundColor:
|
|
426
|
-
paddingVertical:
|
|
427
|
-
paddingHorizontal:
|
|
428
|
-
borderRadius:
|
|
429
|
-
marginTop:
|
|
510
|
+
backgroundColor: theme.color.primary,
|
|
511
|
+
paddingVertical: theme.spacing.spacing.s3,
|
|
512
|
+
paddingHorizontal: theme.spacing.spacing.s10,
|
|
513
|
+
borderRadius: theme.spacing.radius.r2,
|
|
514
|
+
marginTop: theme.spacing.spacing.s5,
|
|
430
515
|
}}
|
|
431
516
|
>
|
|
432
517
|
<Text
|
|
433
518
|
style={{
|
|
434
|
-
color:
|
|
435
|
-
...
|
|
519
|
+
color: theme.color.primaryButtonIcon,
|
|
520
|
+
...theme.typography.button.medium,
|
|
436
521
|
}}
|
|
437
522
|
>
|
|
438
523
|
{localize("RETRY")}
|
|
@@ -441,12 +526,10 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
441
526
|
}
|
|
442
527
|
/>
|
|
443
528
|
);
|
|
444
|
-
}, [
|
|
529
|
+
}, [theme]);
|
|
445
530
|
|
|
446
531
|
/**
|
|
447
532
|
* Renders the empty state view for call logs.
|
|
448
|
-
*
|
|
449
|
-
* @returns {JSX.Element} The empty state view.
|
|
450
533
|
*/
|
|
451
534
|
const EmptyStateView = useCallback(() => {
|
|
452
535
|
if (EmptyView) return <EmptyView />;
|
|
@@ -457,10 +540,10 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
457
540
|
Icon={
|
|
458
541
|
<Icon
|
|
459
542
|
name='call-fill'
|
|
460
|
-
size={
|
|
461
|
-
color={
|
|
543
|
+
size={theme.spacing.spacing.s15 << 1}
|
|
544
|
+
color={theme.color.neutral300}
|
|
462
545
|
containerStyle={{
|
|
463
|
-
marginBottom:
|
|
546
|
+
marginBottom: theme.spacing.spacing.s5,
|
|
464
547
|
}}
|
|
465
548
|
/>
|
|
466
549
|
}
|
|
@@ -469,57 +552,85 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
469
552
|
subTitleStyle={mergedCallLogsStyle.emptyStateStyle?.subTitleStyle}
|
|
470
553
|
/>
|
|
471
554
|
);
|
|
472
|
-
}, [
|
|
555
|
+
}, [theme]);
|
|
556
|
+
|
|
557
|
+
const renderFooter = useCallback(() => {
|
|
558
|
+
if (listState !== "loading" || !hasMoreData) return null;
|
|
559
|
+
return (
|
|
560
|
+
<View
|
|
561
|
+
style={{
|
|
562
|
+
paddingVertical: 20,
|
|
563
|
+
flex: 1,
|
|
564
|
+
alignItems: "center",
|
|
565
|
+
justifyContent: "center",
|
|
566
|
+
}}
|
|
567
|
+
>
|
|
568
|
+
<ActivityIndicator size='small' color={theme.color.primary} />
|
|
569
|
+
</View>
|
|
570
|
+
);
|
|
571
|
+
}, [theme, listState]);
|
|
473
572
|
|
|
474
573
|
return (
|
|
475
|
-
<View
|
|
574
|
+
<View
|
|
575
|
+
style={{
|
|
576
|
+
backgroundColor: theme.color.background1,
|
|
577
|
+
height: "100%",
|
|
578
|
+
width: "100%",
|
|
579
|
+
}}
|
|
580
|
+
>
|
|
476
581
|
<>
|
|
477
582
|
{/* Header with optional back button and app bar options */}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
{
|
|
492
|
-
|
|
493
|
-
<
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
583
|
+
{!hideHeader && (
|
|
584
|
+
<View
|
|
585
|
+
style={[
|
|
586
|
+
Style.row,
|
|
587
|
+
Style.headerStyle,
|
|
588
|
+
{
|
|
589
|
+
padding: theme.spacing.spacing.s4,
|
|
590
|
+
borderBottomWidth: 1,
|
|
591
|
+
borderBottomColor: theme.color.borderLight,
|
|
592
|
+
...mergedCallLogsStyle.titleSeparatorStyle,
|
|
593
|
+
},
|
|
594
|
+
]}
|
|
595
|
+
>
|
|
596
|
+
<View style={Style.row}>
|
|
597
|
+
{showBackButton ? (
|
|
598
|
+
<TouchableOpacity style={Style.imageStyle} onPress={onBack}>
|
|
599
|
+
<Image
|
|
600
|
+
source={BackIcon}
|
|
601
|
+
style={[Style.imageStyle, { tintColor: theme.color.iconPrimary }]}
|
|
602
|
+
/>
|
|
603
|
+
</TouchableOpacity>
|
|
604
|
+
) : null}
|
|
605
|
+
<Text style={mergedCallLogsStyle.titleTextStyle}>{localize("CALLS")}</Text>
|
|
606
|
+
</View>
|
|
607
|
+
<View style={Style.row}>{AppBarOptions && <AppBarOptions />}</View>
|
|
500
608
|
</View>
|
|
501
|
-
|
|
502
|
-
|
|
609
|
+
)}
|
|
610
|
+
|
|
503
611
|
{/* Render call logs based on state */}
|
|
504
|
-
{listState
|
|
505
|
-
|
|
506
|
-
|
|
612
|
+
{listState === "loading" && list.length === 0 ? (
|
|
613
|
+
!hideLoadingState ? (
|
|
614
|
+
LoadingView ? (
|
|
615
|
+
<LoadingView />
|
|
616
|
+
) : (
|
|
617
|
+
<Skeleton style={mergedCallLogsStyle.skeletonStyle} />
|
|
618
|
+
)
|
|
507
619
|
) : (
|
|
508
|
-
<
|
|
620
|
+
<View />
|
|
509
621
|
)
|
|
510
|
-
) : listState
|
|
622
|
+
) : listState === "error" && list.length === 0 ? (
|
|
511
623
|
<ErrorStateView />
|
|
512
|
-
) : list.length
|
|
624
|
+
) : list.length === 0 ? (
|
|
513
625
|
<EmptyStateView />
|
|
514
626
|
) : (
|
|
515
627
|
<FlatList
|
|
516
628
|
data={list}
|
|
517
629
|
keyExtractor={(item, index) => item.sessionId + "_" + index}
|
|
630
|
+
extraData={{ list, listState }}
|
|
518
631
|
renderItem={_render}
|
|
519
632
|
onEndReached={fetchCallLogs}
|
|
520
|
-
|
|
521
|
-
<RefreshControl refreshing={listState === "loading"} onRefresh={fetchCallLogs} />
|
|
522
|
-
}
|
|
633
|
+
ListFooterComponent={renderFooter}
|
|
523
634
|
/>
|
|
524
635
|
)}
|
|
525
636
|
</>
|
|
@@ -542,6 +653,38 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
|
|
|
542
653
|
{...outgoingCallConfiguration}
|
|
543
654
|
/>
|
|
544
655
|
)}
|
|
656
|
+
|
|
657
|
+
{/* Tooltip menu for calls (on default long-press) */}
|
|
658
|
+
{selectedCall && tooltipVisible && (
|
|
659
|
+
<View
|
|
660
|
+
style={{
|
|
661
|
+
position: "absolute",
|
|
662
|
+
top: tooltipPosition.current.pageY,
|
|
663
|
+
left: tooltipPosition.current.pageX,
|
|
664
|
+
zIndex: 9999,
|
|
665
|
+
}}
|
|
666
|
+
>
|
|
667
|
+
<CometChatTooltipMenu
|
|
668
|
+
visible={tooltipVisible}
|
|
669
|
+
onClose={() => setTooltipVisible(false)}
|
|
670
|
+
onDismiss={() => setTooltipVisible(false)}
|
|
671
|
+
event={{
|
|
672
|
+
nativeEvent: tooltipPosition.current,
|
|
673
|
+
}}
|
|
674
|
+
menuItems={buildMenuItems(selectedCall).map((menuItem) => ({
|
|
675
|
+
text: menuItem.text,
|
|
676
|
+
onPress: () => {
|
|
677
|
+
menuItem.onPress();
|
|
678
|
+
setTooltipVisible(false);
|
|
679
|
+
},
|
|
680
|
+
textColor: menuItem.textStyle?.color,
|
|
681
|
+
iconColor: menuItem.iconStyle?.tintColor,
|
|
682
|
+
disabled: menuItem.disabled,
|
|
683
|
+
}))}
|
|
684
|
+
/>
|
|
685
|
+
</View>
|
|
686
|
+
)}
|
|
687
|
+
{/* End tooltip menu */}
|
|
545
688
|
</View>
|
|
546
689
|
);
|
|
547
690
|
};
|