@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
|
@@ -1,15 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* CometChatConversations.tsx
|
|
3
|
+
* ---------------------------------------------------------------------------
|
|
4
|
+
* CometChatConversations is a React Native component that displays a list of conversations
|
|
5
|
+
* It provides features such as message receipt visibility, custom sound notifications,
|
|
6
|
+
* date formatting, and selection modes (none, single, multiple).
|
|
7
|
+
* It also allows for custom rendering of conversation items, error handling, and loading states.
|
|
8
|
+
* The component supports user and group events, message events, and call events.
|
|
9
|
+
* It also provides options for customizing the appearance of the conversation list.
|
|
10
|
+
* ---------------------------------------------------------------------------
|
|
11
|
+
*/
|
|
1
12
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
13
|
import React, { useCallback, useMemo } from "react";
|
|
3
|
-
import {
|
|
14
|
+
import { Text, View, GestureResponderEvent } from "react-native";
|
|
4
15
|
import {
|
|
5
16
|
ChatConfigurator,
|
|
17
|
+
CometChatAvatar,
|
|
6
18
|
CometChatConversationEvents,
|
|
7
|
-
CometChatConversationUtils,
|
|
8
19
|
CometChatList,
|
|
9
20
|
CometChatListActionsInterface,
|
|
10
|
-
CometChatListItem,
|
|
11
21
|
CometChatMentionsFormatter,
|
|
12
22
|
CometChatSoundManager,
|
|
23
|
+
CometChatStatusIndicator,
|
|
13
24
|
CometChatTextFormatter,
|
|
14
25
|
CometChatUIKit,
|
|
15
26
|
CometChatUiKitConstants,
|
|
@@ -34,7 +45,7 @@ import { CometChatBadge } from "../shared/views/CometChatBadge";
|
|
|
34
45
|
import { CometChatConfirmDialog } from "../shared/views/CometChatConfirmDialog";
|
|
35
46
|
import { CometChatDate } from "../shared/views/CometChatDate";
|
|
36
47
|
import { CometChatReceipt } from "../shared/views/CometChatReceipt";
|
|
37
|
-
import {
|
|
48
|
+
import { CometChatTooltipMenu } from "../shared/views/CometChatTooltipMenu";
|
|
38
49
|
import { ErrorEmptyView } from "../shared/views/ErrorEmptyView/ErrorEmptyView";
|
|
39
50
|
import { useTheme } from "../theme";
|
|
40
51
|
import { Skeleton } from "./Skeleton";
|
|
@@ -43,6 +54,7 @@ import { deepMerge } from "../shared/helper/helperFunctions";
|
|
|
43
54
|
import Delete from "../shared/icons/components/delete";
|
|
44
55
|
import { DeepPartial } from "../shared/helper/types";
|
|
45
56
|
import { CometChatTheme } from "../theme/type";
|
|
57
|
+
import { MenuItemInterface } from "../shared/views/CometChatTooltipMenu/CometChatTooltipMenu";
|
|
46
58
|
|
|
47
59
|
// Unique listener IDs for conversation, user, group, message and call events.
|
|
48
60
|
const conversationListenerId = "chatlist_" + new Date().getTime();
|
|
@@ -60,9 +72,10 @@ export interface ConversationInterface {
|
|
|
60
72
|
*/
|
|
61
73
|
hideSubmitButton?: boolean;
|
|
62
74
|
/**
|
|
63
|
-
*
|
|
75
|
+
* Toggles message receipts (single/double‑tick) inside the subtitle. When
|
|
76
|
+
* `false`, ticks are not rendered for the last outgoing message.
|
|
64
77
|
*/
|
|
65
|
-
|
|
78
|
+
receiptsVisibility?: boolean;
|
|
66
79
|
/**
|
|
67
80
|
* Toggle sound playback for received messages.
|
|
68
81
|
*/
|
|
@@ -78,7 +91,17 @@ export interface ConversationInterface {
|
|
|
78
91
|
*/
|
|
79
92
|
datePattern?: (conversation: CometChat.Conversation) => string;
|
|
80
93
|
/**
|
|
81
|
-
*
|
|
94
|
+
* Completely overrides the default rendering of each conversation item in the list.
|
|
95
|
+
*
|
|
96
|
+
* **Note:** When `ItemView` is provided, all internal rendering logic – including
|
|
97
|
+
* LeadingView, TitleView, SubtitleView, TrailingView – is ignored.
|
|
98
|
+
*
|
|
99
|
+
* **Important:** If you use `ItemView`, you are also responsible for handling:
|
|
100
|
+
*
|
|
101
|
+
* - **`onItemPress`** — trigger conversation open or custom action.
|
|
102
|
+
* - **`onItemLongPress`** — show tooltip or perform contextual action.
|
|
103
|
+
* - **Selection mode** (`selectionMode: "single" | "multiple"`) — you must manage
|
|
104
|
+
* selection state, checkboxes, and visual feedback yourself.
|
|
82
105
|
*/
|
|
83
106
|
ItemView?: (item: CometChat.Conversation) => JSX.Element;
|
|
84
107
|
/**
|
|
@@ -96,7 +119,11 @@ export interface ConversationInterface {
|
|
|
96
119
|
/**
|
|
97
120
|
* Callback when conversation selection is complete.
|
|
98
121
|
*/
|
|
99
|
-
onSelection?: (
|
|
122
|
+
onSelection?: (conversations: Array<CometChat.Conversation>) => void;
|
|
123
|
+
/**
|
|
124
|
+
* Callback when submit selection button is pressed.
|
|
125
|
+
*/
|
|
126
|
+
onSubmit?: (conversation: Array<CometChat.Conversation>) => void;
|
|
100
127
|
/**
|
|
101
128
|
* Custom view for the empty state.
|
|
102
129
|
*/
|
|
@@ -163,18 +190,43 @@ export interface ConversationInterface {
|
|
|
163
190
|
* Hide the header of the conversation list.
|
|
164
191
|
*/
|
|
165
192
|
hideHeader?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Callback triggered when the fetched list is empty.
|
|
195
|
+
*/
|
|
196
|
+
onEmpty?: () => void;
|
|
197
|
+
/**
|
|
198
|
+
* Callback triggered once the users have loaded and are not empty.
|
|
199
|
+
*/
|
|
200
|
+
onLoad?: (list: CometChat.Conversation[]) => void;
|
|
201
|
+
/**
|
|
202
|
+
* A function to **replace** the default menu items entirely for a users.
|
|
203
|
+
*/
|
|
204
|
+
options?: (conversation: CometChat.Conversation) => MenuItemInterface[];
|
|
205
|
+
/**
|
|
206
|
+
* A function to **append** more menu items on top of the default menu items for a users.
|
|
207
|
+
*/
|
|
208
|
+
addOptions?: (conversation: CometChat.Conversation) => MenuItemInterface[];
|
|
209
|
+
/**
|
|
210
|
+
* Toggle user status visibilty.
|
|
211
|
+
*/
|
|
212
|
+
usersStatusVisibility?: boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Toggle group type visibilty.
|
|
215
|
+
*/
|
|
216
|
+
groupTypeVisibility?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Toggle delete conversation option visibilty.
|
|
219
|
+
*/
|
|
220
|
+
deleteConversationOptionVisibility?: boolean;
|
|
166
221
|
}
|
|
167
222
|
|
|
168
223
|
/**
|
|
169
224
|
* CometChatConversations is a container component that wraps and formats the conversation list.
|
|
170
225
|
* It handles events such as new messages, typing indicators, call events, and group events.
|
|
171
|
-
*
|
|
172
|
-
* @param props - Properties defined by ConversationInterface.
|
|
173
|
-
* @returns A JSX.Element that renders the conversation list.
|
|
174
226
|
*/
|
|
175
227
|
export const CometChatConversations = (props: ConversationInterface) => {
|
|
176
228
|
const {
|
|
177
|
-
|
|
229
|
+
receiptsVisibility = true,
|
|
178
230
|
disableSoundForMessages = false,
|
|
179
231
|
hideHeader = false,
|
|
180
232
|
customSoundForMessages,
|
|
@@ -183,8 +235,9 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
183
235
|
AppBarOptions,
|
|
184
236
|
hideSubmitButton = false,
|
|
185
237
|
hideBackButton = true,
|
|
186
|
-
selectionMode = "
|
|
238
|
+
selectionMode = "none",
|
|
187
239
|
onSelection,
|
|
240
|
+
onSubmit,
|
|
188
241
|
EmptyView,
|
|
189
242
|
ErrorView,
|
|
190
243
|
LoadingView,
|
|
@@ -200,6 +253,13 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
200
253
|
onBack,
|
|
201
254
|
textFormatters,
|
|
202
255
|
style,
|
|
256
|
+
onEmpty,
|
|
257
|
+
onLoad,
|
|
258
|
+
options,
|
|
259
|
+
addOptions,
|
|
260
|
+
usersStatusVisibility = true,
|
|
261
|
+
groupTypeVisibility = true,
|
|
262
|
+
deleteConversationOptionVisibility = true,
|
|
203
263
|
} = props;
|
|
204
264
|
|
|
205
265
|
// Reference for accessing CometChatList methods
|
|
@@ -219,6 +279,8 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
219
279
|
);
|
|
220
280
|
// Reference to store long press identifier.
|
|
221
281
|
const longPressId = React.useRef<string | undefined>(undefined);
|
|
282
|
+
const longPressedConversation = React.useRef<CometChat.Conversation>(undefined);
|
|
283
|
+
|
|
222
284
|
// Reference to store tooltip position for long press events.
|
|
223
285
|
const tooltipPositon = React.useRef({
|
|
224
286
|
pageX: 0,
|
|
@@ -238,22 +300,24 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
238
300
|
const ErrorStateView = useCallback(() => {
|
|
239
301
|
return (
|
|
240
302
|
<ErrorEmptyView
|
|
241
|
-
title=
|
|
242
|
-
subTitle=
|
|
243
|
-
tertiaryTitle=
|
|
303
|
+
title={localize("OOPS")}
|
|
304
|
+
subTitle={localize("SOMETHING_WENT_WRONG")}
|
|
305
|
+
tertiaryTitle={localize("WRONG_TEXT_TRY_AGAIN")}
|
|
244
306
|
Icon={
|
|
245
307
|
<Icon
|
|
246
308
|
name='error-state'
|
|
247
309
|
size={theme.spacing.margin.m15 << 1}
|
|
248
310
|
containerStyle={{
|
|
249
311
|
marginBottom: theme.spacing.margin.m5,
|
|
312
|
+
...mergedStyles?.errorStateStyle?.iconContainerStyle,
|
|
250
313
|
}}
|
|
251
|
-
icon={mergedStyles
|
|
314
|
+
icon={mergedStyles?.errorStateStyle?.icon}
|
|
315
|
+
imageStyle={mergedStyles?.errorStateStyle?.iconStyle}
|
|
252
316
|
/>
|
|
253
317
|
}
|
|
254
|
-
containerStyle={mergedStyles
|
|
255
|
-
titleStyle={mergedStyles
|
|
256
|
-
subTitleStyle={mergedStyles
|
|
318
|
+
containerStyle={mergedStyles?.errorStateStyle?.containerStyle}
|
|
319
|
+
titleStyle={mergedStyles?.errorStateStyle?.titleStyle}
|
|
320
|
+
subTitleStyle={mergedStyles?.errorStateStyle?.subTitleStyle}
|
|
257
321
|
/>
|
|
258
322
|
);
|
|
259
323
|
}, [theme, mergedStyles]);
|
|
@@ -272,48 +336,55 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
272
336
|
size={theme.spacing.spacing.s15 << 1}
|
|
273
337
|
containerStyle={{
|
|
274
338
|
marginBottom: theme.spacing.spacing.s5,
|
|
339
|
+
...mergedStyles?.emptyStateStyle?.iconContainerStyle,
|
|
275
340
|
}}
|
|
276
|
-
icon={mergedStyles
|
|
341
|
+
icon={mergedStyles?.emptyStateStyle?.icon}
|
|
342
|
+
imageStyle={mergedStyles?.emptyStateStyle?.iconStyle}
|
|
277
343
|
/>
|
|
278
344
|
}
|
|
279
|
-
containerStyle={mergedStyles
|
|
280
|
-
titleStyle={mergedStyles
|
|
281
|
-
subTitleStyle={mergedStyles
|
|
345
|
+
containerStyle={mergedStyles?.emptyStateStyle?.containerStyle}
|
|
346
|
+
titleStyle={mergedStyles?.emptyStateStyle?.titleStyle}
|
|
347
|
+
subTitleStyle={mergedStyles?.emptyStateStyle?.subTitleStyle}
|
|
282
348
|
/>
|
|
283
349
|
);
|
|
284
350
|
}, [theme, mergedStyles]);
|
|
285
351
|
|
|
286
352
|
/**
|
|
287
353
|
* Handler for user online/offline events. Finds the corresponding conversation and updates it.
|
|
288
|
-
* @param args - Contains user details.
|
|
289
354
|
*/
|
|
290
|
-
const userEventHandler = (...args: any) => {
|
|
291
|
-
const { uid
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
355
|
+
const userEventHandler = (...args: any[]) => {
|
|
356
|
+
const { uid } = args[0];
|
|
357
|
+
let item: CometChat.Conversation | any =
|
|
358
|
+
(conversationListRef.current?.getListItem(
|
|
359
|
+
`${uid}_user_${loggedInUser.current?.getUid()}`
|
|
360
|
+
) as unknown as CometChat.Conversation) ||
|
|
361
|
+
(conversationListRef.current?.getListItem(
|
|
362
|
+
`${loggedInUser.current?.getUid()}_user_${uid}`
|
|
363
|
+
) as unknown as CometChat.Conversation);
|
|
364
|
+
const user: CometChat.User = item.getConversationWith();
|
|
365
|
+
if (user.getBlockedByMe() || user.getHasBlockedMe()) return;
|
|
366
|
+
if (item) {
|
|
367
|
+
let updatedConversation = CommonUtils.clone(item);
|
|
368
|
+
updatedConversation.setConversationWith(args[0]);
|
|
369
|
+
conversationListRef.current?.updateList(updatedConversation);
|
|
301
370
|
}
|
|
302
371
|
};
|
|
303
372
|
|
|
304
373
|
/**
|
|
305
374
|
* Returns a conversation that matches a typing indicator.
|
|
306
|
-
* @param typingIndicator - The typing indicator event.
|
|
307
|
-
* @returns The matching conversation or undefined.
|
|
308
375
|
*/
|
|
309
376
|
const getConversationRefFromTypingIndicator = (typingIndicator: CometChat.TypingIndicator) => {
|
|
310
|
-
let list = conversationListRef.current
|
|
311
|
-
return list
|
|
377
|
+
let list = conversationListRef.current?.getAllListItems();
|
|
378
|
+
return list?.find((item: CometChat.Conversation) => {
|
|
312
379
|
return (
|
|
313
380
|
(typingIndicator.getReceiverType() == ReceiverTypeConstants.user &&
|
|
314
381
|
item.getConversationType() == ReceiverTypeConstants.user &&
|
|
315
382
|
(item.getConversationWith() as CometChat.User).getUid() ==
|
|
316
|
-
typingIndicator.getSender().getUid()
|
|
383
|
+
typingIndicator.getSender().getUid() &&
|
|
384
|
+
!(
|
|
385
|
+
(item.getConversationWith() as CometChat.User)?.getBlockedByMe() ||
|
|
386
|
+
(item.getConversationWith() as CometChat.User)?.getHasBlockedMe()
|
|
387
|
+
)) ||
|
|
317
388
|
(typingIndicator.getReceiverType() == ReceiverTypeConstants.group &&
|
|
318
389
|
item.getConversationType() == ReceiverTypeConstants.group &&
|
|
319
390
|
(item.getConversationWith() as CometChat.Group).getGuid() ==
|
|
@@ -324,7 +395,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
324
395
|
|
|
325
396
|
/**
|
|
326
397
|
* Handler for typing events in conversations.
|
|
327
|
-
*
|
|
398
|
+
* Toggle the *live typing…* indicator on a conversation row.
|
|
328
399
|
*/
|
|
329
400
|
const typingEventHandler = (...args: any) => {
|
|
330
401
|
let conversation: CometChat.Conversation = CommonUtils.clone(
|
|
@@ -826,7 +897,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
826
897
|
if (lastMessage?.hasOwnProperty("readAt")) status = MessageReceipt.READ;
|
|
827
898
|
else if (lastMessage?.hasOwnProperty("deliveredAt")) status = MessageReceipt.DELIVERED;
|
|
828
899
|
else if (lastMessage?.hasOwnProperty("sentAt")) status = MessageReceipt.SENT;
|
|
829
|
-
readReceipt =
|
|
900
|
+
readReceipt = !receiptsVisibility ? null : (
|
|
830
901
|
<CometChatReceipt receipt={status} style={mergedStyles.itemStyle.receiptStyles} />
|
|
831
902
|
);
|
|
832
903
|
}
|
|
@@ -867,17 +938,24 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
867
938
|
const getTrailingView = useCallback(
|
|
868
939
|
(conversation: CometChat.Conversation) => {
|
|
869
940
|
const customPattern = () => datePattern?.(conversation);
|
|
870
|
-
const timestamp = conversation.getLastMessage()
|
|
941
|
+
const timestamp = conversation.getLastMessage()?.getSentAt();
|
|
942
|
+
if (!timestamp) return <></>;
|
|
871
943
|
return (
|
|
872
|
-
<View
|
|
944
|
+
<View
|
|
945
|
+
style={[
|
|
946
|
+
{ marginHorizontal: 6, justifyContent: "center", alignItems: "flex-end" },
|
|
947
|
+
mergedStyles.itemStyle.trailingViewContainerStyle,
|
|
948
|
+
]}
|
|
949
|
+
>
|
|
873
950
|
<CometChatDate
|
|
874
951
|
timeStamp={timestamp * 1000}
|
|
875
952
|
customDateString={customPattern && customPattern()}
|
|
876
953
|
pattern={"dayWeekDayDateTimeFormat"}
|
|
954
|
+
style={mergedStyles?.itemStyle?.dateStyle}
|
|
877
955
|
/>
|
|
878
956
|
<CometChatBadge
|
|
879
957
|
count={conversation.getUnreadMessageCount()}
|
|
880
|
-
style={mergedStyles
|
|
958
|
+
style={mergedStyles?.itemStyle?.badgeStyle}
|
|
881
959
|
/>
|
|
882
960
|
</View>
|
|
883
961
|
);
|
|
@@ -1283,13 +1361,42 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1283
1361
|
// Listen for user block events.
|
|
1284
1362
|
CometChatUIEventHandler.addUserListener(userListenerId, {
|
|
1285
1363
|
ccUserBlocked: ({ user }: { user: CometChat.User }) => {
|
|
1286
|
-
const
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
conversationListRef
|
|
1292
|
-
|
|
1364
|
+
const uid = user.getUid();
|
|
1365
|
+
let item: CometChat.Conversation | any =
|
|
1366
|
+
(conversationListRef.current?.getListItem(
|
|
1367
|
+
`${uid}_user_${loggedInUser.current?.getUid()}`
|
|
1368
|
+
) as unknown as CometChat.Conversation) ||
|
|
1369
|
+
(conversationListRef.current?.getListItem(
|
|
1370
|
+
`${loggedInUser.current?.getUid()}_user_${uid}`
|
|
1371
|
+
) as unknown as CometChat.Conversation);
|
|
1372
|
+
if (
|
|
1373
|
+
conversationsRequestBuilder &&
|
|
1374
|
+
conversationsRequestBuilder.build().isIncludeBlockedUsers()
|
|
1375
|
+
) {
|
|
1376
|
+
if (item) {
|
|
1377
|
+
let updatedConversation = CommonUtils.clone(item);
|
|
1378
|
+
updatedConversation.setConversationWith(user);
|
|
1379
|
+
conversationListRef.current?.updateList(updatedConversation);
|
|
1380
|
+
}
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
conversationListRef?.current?.removeItemFromList(item.getConversationId());
|
|
1384
|
+
removeItemFromSelectionList(item.getConversationId());
|
|
1385
|
+
},
|
|
1386
|
+
ccUserUnBlocked: ({ user }: { user: CometChat.User }) => {
|
|
1387
|
+
/**unblocked handling is required to enable user presence listener for the user**/
|
|
1388
|
+
const uid = user.getUid();
|
|
1389
|
+
let item: CometChat.Conversation | any =
|
|
1390
|
+
(conversationListRef.current?.getListItem(
|
|
1391
|
+
`${uid}_user_${loggedInUser.current?.getUid()}`
|
|
1392
|
+
) as unknown as CometChat.Conversation) ||
|
|
1393
|
+
(conversationListRef.current?.getListItem(
|
|
1394
|
+
`${loggedInUser.current?.getUid()}_user_${uid}`
|
|
1395
|
+
) as unknown as CometChat.Conversation);
|
|
1396
|
+
if (item) {
|
|
1397
|
+
let updatedConversation = CommonUtils.clone(item);
|
|
1398
|
+
updatedConversation.setConversationWith(user);
|
|
1399
|
+
conversationListRef.current?.updateList(updatedConversation);
|
|
1293
1400
|
}
|
|
1294
1401
|
},
|
|
1295
1402
|
});
|
|
@@ -1362,77 +1469,74 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1362
1469
|
};
|
|
1363
1470
|
}, []);
|
|
1364
1471
|
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1472
|
+
const getStatusIndicator = (conv: CometChat.Conversation) => {
|
|
1473
|
+
const withObj = conv.getConversationWith();
|
|
1474
|
+
|
|
1475
|
+
if (groupTypeVisibility) {
|
|
1476
|
+
if (withObj instanceof CometChat.Group) {
|
|
1477
|
+
if (withObj.getType() === GroupTypeConstants.password) return "protected";
|
|
1478
|
+
if (withObj.getType() === GroupTypeConstants.private) return "private";
|
|
1479
|
+
}
|
|
1480
|
+
} else {
|
|
1481
|
+
return undefined;
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
if (usersStatusVisibility) {
|
|
1485
|
+
if (
|
|
1486
|
+
withObj instanceof CometChat.User &&
|
|
1487
|
+
withObj.getStatus() === CometChatUiKitConstants.UserStatusConstants.online &&
|
|
1488
|
+
!withObj.getHasBlockedMe() &&
|
|
1489
|
+
!withObj.getBlockedByMe()
|
|
1490
|
+
) {
|
|
1384
1491
|
return "online";
|
|
1385
1492
|
}
|
|
1386
1493
|
return "offline";
|
|
1387
|
-
}
|
|
1494
|
+
} else {
|
|
1495
|
+
return undefined;
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1388
1498
|
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
}
|
|
1427
|
-
}}
|
|
1428
|
-
{...mergedStyles.itemStyle}
|
|
1429
|
-
/>
|
|
1430
|
-
);
|
|
1431
|
-
});
|
|
1499
|
+
const LeadingViewRaw = useCallback(
|
|
1500
|
+
(conv: CometChat.Conversation) => {
|
|
1501
|
+
const withObj = conv.getConversationWith();
|
|
1502
|
+
const avatarURL = withObj instanceof CometChat.User ? withObj.getAvatar() : withObj.getIcon();
|
|
1503
|
+
const name = withObj.getName();
|
|
1504
|
+
|
|
1505
|
+
return (
|
|
1506
|
+
<>
|
|
1507
|
+
<CometChatAvatar
|
|
1508
|
+
image={{ uri: avatarURL }}
|
|
1509
|
+
name={name}
|
|
1510
|
+
style={mergedStyles.itemStyle.avatarStyle}
|
|
1511
|
+
/>
|
|
1512
|
+
<CometChatStatusIndicator
|
|
1513
|
+
type={getStatusIndicator(conv)}
|
|
1514
|
+
style={mergedStyles?.itemStyle?.statusIndicatorStyle}
|
|
1515
|
+
/>
|
|
1516
|
+
</>
|
|
1517
|
+
);
|
|
1518
|
+
},
|
|
1519
|
+
[mergedStyles]
|
|
1520
|
+
);
|
|
1521
|
+
|
|
1522
|
+
const TitleViewRaw = useCallback(
|
|
1523
|
+
(conv: CometChat.Conversation) => (
|
|
1524
|
+
<Text numberOfLines={1} ellipsizeMode='tail' style={mergedStyles.itemStyle.titleStyle}>
|
|
1525
|
+
{conv.getConversationWith().getName()}
|
|
1526
|
+
</Text>
|
|
1527
|
+
),
|
|
1528
|
+
[mergedStyles]
|
|
1529
|
+
);
|
|
1530
|
+
|
|
1531
|
+
const SubtitleViewRaw = (conv: CometChat.Conversation) => (
|
|
1532
|
+
<LastMessageView conversations={conv} typingText={conv?.["lastMessage"]?.["typing"]} />
|
|
1533
|
+
);
|
|
1534
|
+
|
|
1535
|
+
const TrailingViewRaw = useCallback((conv: CometChat.Conversation) => getTrailingView(conv), []);
|
|
1432
1536
|
|
|
1433
1537
|
return (
|
|
1434
1538
|
<View style={mergedStyles.containerStyle}>
|
|
1435
|
-
<
|
|
1539
|
+
<CometChatTooltipMenu
|
|
1436
1540
|
visible={tooltipVisible}
|
|
1437
1541
|
onClose={() => {
|
|
1438
1542
|
setTooltipVisible(false);
|
|
@@ -1440,23 +1544,34 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1440
1544
|
event={{
|
|
1441
1545
|
nativeEvent: tooltipPositon.current,
|
|
1442
1546
|
}}
|
|
1443
|
-
menuItems={
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1547
|
+
menuItems={
|
|
1548
|
+
options
|
|
1549
|
+
? options(longPressedConversation.current!)
|
|
1550
|
+
: [
|
|
1551
|
+
...[
|
|
1552
|
+
...(deleteConversationOptionVisibility
|
|
1553
|
+
? [
|
|
1554
|
+
{
|
|
1555
|
+
text: "Delete",
|
|
1556
|
+
onPress: () => {
|
|
1557
|
+
setConfirmDelete(longPressId.current);
|
|
1558
|
+
setTooltipVisible(false);
|
|
1559
|
+
},
|
|
1560
|
+
icon: (
|
|
1561
|
+
<Delete
|
|
1562
|
+
color={theme.color.error}
|
|
1563
|
+
height={theme.spacing.spacing.s6}
|
|
1564
|
+
width={theme.spacing.spacing.s6}
|
|
1565
|
+
/>
|
|
1566
|
+
),
|
|
1567
|
+
textStyle: { color: theme.color.error },
|
|
1568
|
+
},
|
|
1569
|
+
]
|
|
1570
|
+
: []),
|
|
1571
|
+
],
|
|
1572
|
+
...(addOptions ? addOptions(longPressedConversation.current!) : []),
|
|
1573
|
+
]
|
|
1574
|
+
}
|
|
1460
1575
|
/>
|
|
1461
1576
|
<CometChatConfirmDialog
|
|
1462
1577
|
titleText={localize("DELETE_THIS_CONVERSATION")}
|
|
@@ -1470,38 +1585,63 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1470
1585
|
removeConversation(confirmDelete!);
|
|
1471
1586
|
setConfirmDelete(undefined);
|
|
1472
1587
|
}}
|
|
1588
|
+
{...mergedStyles.confirmDialogStyle}
|
|
1473
1589
|
/>
|
|
1474
1590
|
<CometChatList
|
|
1475
1591
|
AppBarOptions={AppBarOptions}
|
|
1476
1592
|
onError={onError}
|
|
1477
1593
|
ref={conversationListRef}
|
|
1594
|
+
LeadingView={LeadingView ? LeadingView : LeadingViewRaw}
|
|
1595
|
+
TitleView={TitleView ? TitleView : TitleViewRaw}
|
|
1596
|
+
SubtitleView={SubtitleView ? SubtitleView : SubtitleViewRaw}
|
|
1597
|
+
TrailingView={TrailingView ? TrailingView : TrailingViewRaw}
|
|
1478
1598
|
requestBuilder={
|
|
1479
1599
|
conversationsRequestBuilder || new CometChat.ConversationsRequestBuilder().setLimit(30)
|
|
1480
1600
|
}
|
|
1601
|
+
hideStickyHeader={true}
|
|
1481
1602
|
title={localize("CHATS")}
|
|
1482
1603
|
listStyle={mergedStyles}
|
|
1483
1604
|
hideSearch={true}
|
|
1484
1605
|
hideSubmitButton={hideSubmitButton}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
ItemView={
|
|
1488
|
-
ItemView ??
|
|
1489
|
-
((item: CometChat.Conversation) => {
|
|
1490
|
-
return <ConversationItemView item={item} />;
|
|
1491
|
-
})
|
|
1606
|
+
onItemPress={(conversation) =>
|
|
1607
|
+
selectionMode === "none" ? conversationClicked(conversation) : null
|
|
1492
1608
|
}
|
|
1609
|
+
onItemLongPress={(conversation: CometChat.Conversation, e?: GestureResponderEvent) => {
|
|
1610
|
+
if (selectionMode === "none") {
|
|
1611
|
+
if (onItemLongPress) {
|
|
1612
|
+
onItemLongPress(conversation);
|
|
1613
|
+
return;
|
|
1614
|
+
}
|
|
1615
|
+
if (e && "nativeEvent" in e) {
|
|
1616
|
+
longPressId.current = conversation.getConversationId();
|
|
1617
|
+
longPressedConversation.current = conversation;
|
|
1618
|
+
tooltipPositon.current = {
|
|
1619
|
+
pageX: e.nativeEvent.pageX,
|
|
1620
|
+
pageY: e.nativeEvent.pageY,
|
|
1621
|
+
};
|
|
1622
|
+
setTooltipVisible(true);
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
}}
|
|
1626
|
+
listItemKey={"conversationId"}
|
|
1627
|
+
LoadingView={LoadingView ?? (() => <Skeleton style={mergedStyles.skeletonStyle} />)}
|
|
1628
|
+
ItemView={ItemView}
|
|
1493
1629
|
EmptyView={EmptyView ? EmptyView : () => <EmptyStateView />}
|
|
1494
1630
|
ErrorView={ErrorView ? ErrorView : () => <ErrorStateView />}
|
|
1495
1631
|
onBack={onBack}
|
|
1496
1632
|
hideBackButton={hideBackButton}
|
|
1497
|
-
onSelection={
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
setSelectedConversations([]);
|
|
1501
|
-
}}
|
|
1502
|
-
selectionMode={selecting ? selectionMode : "none"}
|
|
1633
|
+
onSelection={onSelection}
|
|
1634
|
+
onSubmit={onSubmit}
|
|
1635
|
+
selectionMode={selectionMode}
|
|
1503
1636
|
hideError={hideError}
|
|
1504
1637
|
hideHeader={hideHeader}
|
|
1638
|
+
onListFetched={(conversations: CometChat.Conversation[]) => {
|
|
1639
|
+
if (conversations.length === 0) {
|
|
1640
|
+
onEmpty?.();
|
|
1641
|
+
} else {
|
|
1642
|
+
onLoad?.(conversations);
|
|
1643
|
+
}
|
|
1644
|
+
}}
|
|
1505
1645
|
/>
|
|
1506
1646
|
</View>
|
|
1507
1647
|
);
|