@cometchat/chat-uikit-react-native 4.3.18 → 4.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/src/main/AndroidManifest.xml +6 -0
- package/ios/FileManager.m +2 -0
- package/package.json +1 -1
- package/src/CometChatConversations/CometChatConversations.tsx +31 -33
- package/src/CometChatGroups/CometChatGroups.tsx +2 -2
- package/src/CometChatGroups/GroupsConfiguration.ts +13 -16
- package/src/CometChatGroups/resources/index.ts +0 -3
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +14 -5
- package/src/CometChatMessageInformation/MessageInformationConfiguration.tsx +31 -12
- package/src/CometChatMessageInformation/index.ts +6 -3
- package/src/CometChatMessageList/CometChatMessageList.tsx +86 -13
- package/src/CometChatMessageList/MessageListConfiguration.ts +21 -0
- package/src/CometChatTabs/CometChatTabs.tsx +8 -8
- package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +2 -1
- package/src/CometChatUsers/CometChatUsers.tsx +40 -11
- package/src/CometChatUsers/UsersConfiguration.tsx +2 -2
- package/src/CometChatUsers/UsersStyle.ts +101 -0
- package/src/CometChatUsers/index.ts +4 -1
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +1 -1
- package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +1 -1
- package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +1 -1
- package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +11 -6
- package/src/index.ts +8 -2
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +53 -53
- package/src/shared/framework/MessageDataSource.tsx +15 -11
- package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +1 -0
- package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +1 -1
- package/src/shared/libs/VideoPlayerControls/components/Control.tsx +1 -1
- package/src/shared/libs/VideoPlayerControls/components/PlayPause/PlayPause.tsx +1 -1
- package/src/shared/libs/luxon/src/impl/zoneUtil.js +0 -4
- package/src/shared/utils/CommonUtils.ts +17 -17
- package/src/shared/utils/DetailsUtils/DetailsUtils.tsx +1 -1
- package/src/shared/utils/InteractiveMessageUtils.ts +1 -1
- package/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts +10 -12
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +1 -1
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +2 -2
- package/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx +1 -1
- package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +3 -3
- package/src/shared/views/CometChatImageBubble/assets/index.ts +1 -0
- package/src/shared/views/CometChatListItem/CometChatListItem.tsx +1 -1
- package/src/shared/views/CometChatMessageBubble/MessageBubbleStyle.ts +2 -2
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +0 -1
- package/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx +5 -5
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +1 -1
- package/src/CometChatGroups/resources/search.png +0 -0
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
5
5
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
6
6
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
|
7
|
+
<queries>
|
|
8
|
+
<intent>
|
|
9
|
+
<action android:name="android.intent.action.VIEW" />
|
|
10
|
+
<data android:scheme="https" android:host="*" />
|
|
11
|
+
</intent>
|
|
12
|
+
</queries>
|
|
7
13
|
<application android:requestLegacyExternalStorage="true"
|
|
8
14
|
android:largeHeap="true" >
|
|
9
15
|
<activity
|
package/ios/FileManager.m
CHANGED
|
@@ -545,6 +545,8 @@ didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey, id>
|
|
|
545
545
|
NSString *uri = [NSString stringWithFormat:@"%@", urls[0]];
|
|
546
546
|
NSString *type = [self getMimeType:urls[0]];
|
|
547
547
|
NSString *name = [urls[0] lastPathComponent];
|
|
548
|
+
if (!name) name = @"Unknown";
|
|
549
|
+
if (!type) type = @"Unknown";
|
|
548
550
|
callback(@[@{@"name": name, @"type": type, @"uri": uri}]);
|
|
549
551
|
}
|
|
550
552
|
|
package/package.json
CHANGED
|
@@ -367,11 +367,11 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
367
367
|
const userEventHandler = (...args: any[]) => {
|
|
368
368
|
const { uid, blockedByMe, status } = args[0];
|
|
369
369
|
if (!blockedByMe) {
|
|
370
|
-
let item: CometChat.Conversation | any = conversationListRef.current?.getListItem(`${uid}_user_${loggedInUser.current?.uid}`) || conversationListRef.current?.getListItem(`${loggedInUser.current?.uid}_user_${uid}`);
|
|
370
|
+
let item: CometChat.Conversation | any = conversationListRef.current?.getListItem(`${uid}_user_${loggedInUser.current?.uid}`) as unknown as CometChat.Conversation || conversationListRef.current?.getListItem(`${loggedInUser.current?.uid}_user_${uid}`) as unknown as CometChat.Conversation;
|
|
371
371
|
if (item) {
|
|
372
372
|
let updatedConversation = CommonUtils.clone(item);
|
|
373
373
|
updatedConversation.setConversationWith(args[0]);
|
|
374
|
-
conversationListRef.current
|
|
374
|
+
conversationListRef.current?.updateList(updatedConversation);
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
}
|
|
@@ -417,14 +417,18 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
417
417
|
*
|
|
418
418
|
* @param newMessage message object
|
|
419
419
|
*/
|
|
420
|
-
const checkAndUpdateLastMessage = (newMessage: CometChat.BaseMessage) => {
|
|
420
|
+
const checkAndUpdateLastMessage = (newMessage: CometChat.BaseMessage, resetUnreadCount = false) => {
|
|
421
421
|
CometChat.CometChatHelper.getConversationFromMessage(newMessage)
|
|
422
422
|
.then((conversation: any) => {
|
|
423
423
|
let conver: any = conversationListRef.current?.getListItem(conversation.getConversationId())
|
|
424
424
|
if (!conver) return;
|
|
425
425
|
let lastMessageId = conver['lastMessage']['id']
|
|
426
426
|
if (lastMessageId == newMessage['id']) {
|
|
427
|
-
|
|
427
|
+
if(resetUnreadCount) {
|
|
428
|
+
conver.setUnreadMessageCount(0);
|
|
429
|
+
}
|
|
430
|
+
conver.setLastMessage(newMessage)
|
|
431
|
+
conversationListRef.current?.updateList(conver)
|
|
428
432
|
}
|
|
429
433
|
})
|
|
430
434
|
|
|
@@ -562,18 +566,18 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
562
566
|
}
|
|
563
567
|
|
|
564
568
|
const updateMessageReceipt = (receipt: CometChat.MessageReceipt) => {
|
|
565
|
-
const conv: CometChat.Conversation =
|
|
569
|
+
const conv: CometChat.Conversation | boolean =
|
|
566
570
|
receipt?.getReceiverType() === ReceiverTypeConstants.user
|
|
567
|
-
? conversationListRef.current
|
|
571
|
+
? conversationListRef.current?.getListItem(
|
|
568
572
|
`${receipt?.getReceiver()}_user_${receipt?.getSender().getUid()}`
|
|
569
|
-
) ||
|
|
570
|
-
conversationListRef.current
|
|
573
|
+
) as unknown as CometChat.Conversation ||
|
|
574
|
+
conversationListRef.current?.getListItem(
|
|
571
575
|
`${receipt?.getSender()?.getUid()}_user_${receipt?.getReceiver()}`
|
|
572
|
-
)
|
|
576
|
+
) as unknown as CometChat.Conversation
|
|
573
577
|
: [receipt.RECEIPT_TYPE.DELIVERED_TO_ALL_RECEIPT, receipt.RECEIPT_TYPE.READ_BY_ALL_RECEIPT].includes(receipt?.getReceiptType()) &&
|
|
574
|
-
conversationListRef.current
|
|
578
|
+
conversationListRef.current?.getListItem(
|
|
575
579
|
`group_${receipt?.getReceiver()}`
|
|
576
|
-
);
|
|
580
|
+
) as unknown as CometChat.Conversation;
|
|
577
581
|
|
|
578
582
|
if (
|
|
579
583
|
conv &&
|
|
@@ -586,17 +590,17 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
586
590
|
if (
|
|
587
591
|
conv &&
|
|
588
592
|
conv?.getLastMessage &&
|
|
589
|
-
(conv.getLastMessage().id == receipt
|
|
590
|
-
conv.getLastMessage().messageId == receipt
|
|
593
|
+
(conv.getLastMessage().id == receipt.getMessageId() ||
|
|
594
|
+
conv.getLastMessage().messageId == receipt.getMessageId())
|
|
591
595
|
) {
|
|
592
596
|
let newConversation = CommonUtils.clone(conv);
|
|
593
|
-
if (receipt
|
|
594
|
-
newConversation.getLastMessage().setReadAt(receipt
|
|
597
|
+
if (receipt.getReadAt()) {
|
|
598
|
+
newConversation.getLastMessage().setReadAt(receipt.getReadAt());
|
|
595
599
|
}
|
|
596
|
-
if (receipt
|
|
597
|
-
newConversation.getLastMessage().setDeliveredAt(receipt
|
|
600
|
+
if (receipt.getDeliveredAt()) {
|
|
601
|
+
newConversation.getLastMessage().setDeliveredAt(receipt.getDeliveredAt());
|
|
598
602
|
}
|
|
599
|
-
conversationListRef.current
|
|
603
|
+
conversationListRef.current?.updateList(newConversation);
|
|
600
604
|
}
|
|
601
605
|
};
|
|
602
606
|
|
|
@@ -635,7 +639,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
635
639
|
return;
|
|
636
640
|
}
|
|
637
641
|
conversation.setLastMessage(message);
|
|
638
|
-
conversationListRef.current?.
|
|
642
|
+
conversationListRef.current?.updateAndMoveToFirst(conversation);
|
|
639
643
|
}
|
|
640
644
|
} else {
|
|
641
645
|
CometChat.CometChatHelper.getConversationFromMessage(message)
|
|
@@ -745,7 +749,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
745
749
|
|
|
746
750
|
function getFormattedText(message: CometChat.BaseMessage, subtitle: string) {
|
|
747
751
|
let messageTextTmp = subtitle;
|
|
748
|
-
let allFormatters = [...(textFormatters
|
|
752
|
+
let allFormatters = [...(textFormatters ?? [])];
|
|
749
753
|
|
|
750
754
|
if (!disableMentions && message.getMentionedUsers().length) {
|
|
751
755
|
let mentionsFormatter = ChatConfigurator.getDataSource().getMentionsFormatter();
|
|
@@ -1053,14 +1057,8 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1053
1057
|
{
|
|
1054
1058
|
ccConversationDeleted:
|
|
1055
1059
|
({ conversation }: { conversation: CometChat.Conversation | any }) => {
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
conversationListRef.current?.removeItemFromList(conversation);
|
|
1059
|
-
removeItemFromSelectionList(conversation.getConversationId())
|
|
1060
|
-
})
|
|
1061
|
-
.catch((err: any) => {
|
|
1062
|
-
console.log("Error", err);
|
|
1063
|
-
});
|
|
1060
|
+
conversationListRef.current?.removeItemFromList(conversation.getConversationId());
|
|
1061
|
+
removeItemFromSelectionList(conversation.getConversationId())
|
|
1064
1062
|
}
|
|
1065
1063
|
}
|
|
1066
1064
|
);
|
|
@@ -1076,13 +1074,13 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1076
1074
|
}
|
|
1077
1075
|
},
|
|
1078
1076
|
ccMessageRead: ({ message }: any) => {
|
|
1079
|
-
checkAndUpdateLastMessage(message)
|
|
1077
|
+
checkAndUpdateLastMessage(message, true)
|
|
1080
1078
|
},
|
|
1081
1079
|
ccMessageDeleted: ({ message }: any) => {
|
|
1082
|
-
checkAndUpdateLastMessage(message)
|
|
1080
|
+
checkAndUpdateLastMessage(message, true)
|
|
1083
1081
|
},
|
|
1084
1082
|
ccMessageEdited: ({ message }: any) => {
|
|
1085
|
-
checkAndUpdateLastMessage(message)
|
|
1083
|
+
checkAndUpdateLastMessage(message, true)
|
|
1086
1084
|
},
|
|
1087
1085
|
onTextMessageReceived: (textMessage: any) => {
|
|
1088
1086
|
if(!shouldUpdateLastMessageAndUnreadCount(textMessage)) {
|
|
@@ -1106,10 +1104,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1106
1104
|
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
|
|
1107
1105
|
},
|
|
1108
1106
|
onMessageDeleted: (deletedMessage: any) => {
|
|
1109
|
-
checkAndUpdateLastMessage(deletedMessage)
|
|
1107
|
+
checkAndUpdateLastMessage(deletedMessage, false)
|
|
1110
1108
|
},
|
|
1111
1109
|
onMessageEdited: (editedMessage: any) => {
|
|
1112
|
-
checkAndUpdateLastMessage(editedMessage)
|
|
1110
|
+
checkAndUpdateLastMessage(editedMessage, false)
|
|
1113
1111
|
},
|
|
1114
1112
|
onMessagesRead: (messageReceipt: any) => {
|
|
1115
1113
|
updateMessageReceipt(messageReceipt);
|
|
@@ -3,7 +3,7 @@ import React, { useState, useRef } from "react";
|
|
|
3
3
|
//@ts-ignore
|
|
4
4
|
import { Text, TextStyle, View, ViewProps } from "react-native";
|
|
5
5
|
import {
|
|
6
|
-
backIcon,
|
|
6
|
+
backIcon,
|
|
7
7
|
passwordGroupIcon, privateGroupIcon,
|
|
8
8
|
checkIcon,
|
|
9
9
|
} from "./resources";
|
|
@@ -595,7 +595,7 @@ CometChatGroups.defaultProps = {
|
|
|
595
595
|
title: localize("GROUPS"),
|
|
596
596
|
searchPlaceHolderText: localize("SEARCH"),
|
|
597
597
|
showBackButton: false,
|
|
598
|
-
searchBoxIcon:
|
|
598
|
+
searchBoxIcon: undefined,
|
|
599
599
|
hideSearch: false,
|
|
600
600
|
listItemStyle: undefined,
|
|
601
601
|
avatarStyle: undefined,
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
import { GroupsStyle, GroupsStyleInterface } from './GroupsStyle';
|
|
10
10
|
import {
|
|
11
11
|
backIcon,
|
|
12
|
-
searchIcon,
|
|
13
12
|
passwordGroupIcon,
|
|
14
13
|
privateGroupIcon,
|
|
15
14
|
} from './resources';
|
|
@@ -60,23 +59,23 @@ export class GroupsConfiguration implements GroupsConfigurationInterface {
|
|
|
60
59
|
ListItemView!: (item: CometChat.Group) => JSX.Element;
|
|
61
60
|
AppBarOption!: () => JSX.Element;
|
|
62
61
|
options!: (item: CometChat.Group) => CometChatOptions[];
|
|
63
|
-
hideSeparator
|
|
64
|
-
searchPlaceholderText
|
|
65
|
-
backButton
|
|
66
|
-
showBackButton
|
|
67
|
-
selectionMode
|
|
62
|
+
hideSeparator?: boolean;
|
|
63
|
+
searchPlaceholderText?: string;
|
|
64
|
+
backButton?: ImageType;
|
|
65
|
+
showBackButton?: boolean;
|
|
66
|
+
selectionMode?: 'none' | 'single' | 'multiple';
|
|
68
67
|
onSelection!: (items: Array<CometChat.Group>) => void;
|
|
69
|
-
searchBoxIcon
|
|
70
|
-
hideSearch
|
|
71
|
-
title
|
|
68
|
+
searchBoxIcon?: ImageType;
|
|
69
|
+
hideSearch?: boolean;
|
|
70
|
+
title?: string;
|
|
72
71
|
EmptyStateView!: () => JSX.Element;
|
|
73
72
|
ErrorStateView!: () => JSX.Element;
|
|
74
73
|
LoadingStateView!: () => JSX.Element;
|
|
75
74
|
groupsRequestBuilder: CometChat.GroupsRequestBuilder | undefined;
|
|
76
|
-
searchKeyword
|
|
77
|
-
privateGroupIcon
|
|
78
|
-
passwordGroupIcon
|
|
79
|
-
hideError
|
|
75
|
+
searchKeyword?: string;
|
|
76
|
+
privateGroupIcon?: ImageType;
|
|
77
|
+
passwordGroupIcon?: ImageType;
|
|
78
|
+
hideError?: boolean;
|
|
80
79
|
onItemPress?: (item: CometChat.Group) => void;
|
|
81
80
|
onItemLongPress?: (item: CometChat.Group) => void;
|
|
82
81
|
onError?: (e: CometChat.CometChatException) => void;
|
|
@@ -89,8 +88,6 @@ export class GroupsConfiguration implements GroupsConfigurationInterface {
|
|
|
89
88
|
|
|
90
89
|
constructor(props: GroupsConfigurationInterface) {
|
|
91
90
|
if (props)
|
|
92
|
-
|
|
93
|
-
this[key] = value;
|
|
94
|
-
}
|
|
91
|
+
Object.assign(this, props);
|
|
95
92
|
}
|
|
96
93
|
}
|
|
@@ -3,8 +3,6 @@ import backIcon from "./back.png";
|
|
|
3
3
|
//@ts-ignore
|
|
4
4
|
import createIcon from "./create.png";
|
|
5
5
|
//@ts-ignore
|
|
6
|
-
import searchIcon from "./search.png";
|
|
7
|
-
//@ts-ignore
|
|
8
6
|
import passwordGroupIcon from "./password.png";
|
|
9
7
|
//@ts-ignore
|
|
10
8
|
import privateGroupIcon from "./private.png";
|
|
@@ -22,7 +20,6 @@ import checkIcon from './check.png';
|
|
|
22
20
|
export {
|
|
23
21
|
backIcon,
|
|
24
22
|
createIcon,
|
|
25
|
-
searchIcon,
|
|
26
23
|
passwordGroupIcon,
|
|
27
24
|
privateGroupIcon,
|
|
28
25
|
loadingIcon,
|
|
@@ -236,6 +236,7 @@ let recordedTime = 0, timerIntervalId = null;
|
|
|
236
236
|
export interface MessageComposerStyleInterface extends BaseStyle {
|
|
237
237
|
attachIconTint?: string;
|
|
238
238
|
sendIconTint?: string;
|
|
239
|
+
voiceRecordingIconTint?: string;
|
|
239
240
|
inputBackground?: string;
|
|
240
241
|
inputBorder?: BorderStyleInterface;
|
|
241
242
|
dividerTint?: string;
|
|
@@ -608,7 +609,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
608
609
|
const messageInputRef = React.useRef<any>(null);
|
|
609
610
|
const chatRef = React.useRef<any>(chatWith);
|
|
610
611
|
const inputValueRef = React.useRef<any>(null);
|
|
611
|
-
const plainTextInput = React.useRef<string>("");
|
|
612
|
+
const plainTextInput = React.useRef<string>(text ?? "");
|
|
612
613
|
let mentionMap = React.useRef<Map<string, SuggestionItem>>(new Map());
|
|
613
614
|
let trackingCharacters = React.useRef<string[]>([])
|
|
614
615
|
let allFormatters = React.useRef<Map<string, CometChatTextFormatter | CometChatMentionsFormatter>>(new Map());
|
|
@@ -1131,7 +1132,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1131
1132
|
};
|
|
1132
1133
|
|
|
1133
1134
|
const shouldShowAIOptions = () => {
|
|
1134
|
-
return AIOptionItems.length > 0;
|
|
1135
|
+
return !parentMessageId && AIOptionItems.length > 0;
|
|
1135
1136
|
}
|
|
1136
1137
|
|
|
1137
1138
|
const AuxiliaryButtonViewElem = () => {
|
|
@@ -1210,7 +1211,10 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1210
1211
|
const RecordAudioButtonView = () => {
|
|
1211
1212
|
return <ImageButton
|
|
1212
1213
|
image={voiceRecordingIconURL || ICONS.MICROPHONE}
|
|
1213
|
-
imageStyle={
|
|
1214
|
+
imageStyle={[
|
|
1215
|
+
Style.imageStyle,
|
|
1216
|
+
messageComposerStyle?.voiceRecordingIconTint ? { tintColor: messageComposerStyle?.voiceRecordingIconTint } : {},
|
|
1217
|
+
]}
|
|
1214
1218
|
onClick={() => setShowRecordAudio(true)}
|
|
1215
1219
|
/>
|
|
1216
1220
|
}
|
|
@@ -1228,7 +1232,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1228
1232
|
//fetch logged in user
|
|
1229
1233
|
useEffect(() => {
|
|
1230
1234
|
CometChat.getLoggedinUser().then((user: any) => (loggedInUser.current = user));
|
|
1231
|
-
let _formatter = [...(textFormatters
|
|
1235
|
+
let _formatter = [...(textFormatters ?? [])];
|
|
1232
1236
|
|
|
1233
1237
|
if (!disableMentions) {
|
|
1234
1238
|
let mentionsFormatter = ChatConfigurator.getDataSource().getMentionsFormatter();
|
|
@@ -1316,7 +1320,11 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1316
1320
|
if (typeof item.onPress == 'function')
|
|
1317
1321
|
return {
|
|
1318
1322
|
...item,
|
|
1319
|
-
onPress: () =>
|
|
1323
|
+
onPress: () => {
|
|
1324
|
+
setShowActionSheet(false);
|
|
1325
|
+
item.onPress?.(user, group)
|
|
1326
|
+
}
|
|
1327
|
+
,
|
|
1320
1328
|
};
|
|
1321
1329
|
return {
|
|
1322
1330
|
...item,
|
|
@@ -1390,6 +1398,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1390
1398
|
bottomSheetRef.current?.togglePanel();
|
|
1391
1399
|
|
|
1392
1400
|
inputValueRef.current = text?.text;
|
|
1401
|
+
plainTextInput.current = text?.text;
|
|
1393
1402
|
setInputMessage(text?.text)
|
|
1394
1403
|
|
|
1395
1404
|
},
|
|
@@ -1,13 +1,32 @@
|
|
|
1
|
-
import { CometChatMessageInformationInterface } from
|
|
1
|
+
import { CometChatMessageInformationInterface } from './CometChatMessageInformation';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
// Interface/Class merging: Class and Interface name should be the same. (below)
|
|
4
|
+
// Add a second interface for typing (if needed elsewhere)
|
|
5
|
+
// To avoid listing all properties individually in the class
|
|
6
|
+
export interface CometChatMessageInformationConfiguration
|
|
7
|
+
extends Omit<
|
|
8
|
+
CometChatMessageInformationInterface,
|
|
9
|
+
| 'title'
|
|
10
|
+
| 'message'
|
|
11
|
+
| 'template'
|
|
12
|
+
| 'BubbleView'
|
|
13
|
+
| 'receiptDatePattern'
|
|
14
|
+
| 'readIcon'
|
|
15
|
+
| 'sentIcon'
|
|
16
|
+
| 'deliveredIcon'
|
|
17
|
+
> {}
|
|
18
|
+
|
|
19
|
+
export interface CometChatMessageInformationConfigurationInterface
|
|
20
|
+
extends CometChatMessageInformationConfiguration {}
|
|
21
|
+
|
|
22
|
+
// Class name same as interface
|
|
23
|
+
export class CometChatMessageInformationConfiguration {
|
|
24
|
+
constructor(props: CometChatMessageInformationConfigurationInterface) {
|
|
25
|
+
if (props) {
|
|
26
|
+
for (const [key, value] of Object.entries(props)) {
|
|
27
|
+
//@ts-ignore - Ignore dynamic property assignment type checks
|
|
28
|
+
this[key] = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -2,12 +2,15 @@ import {
|
|
|
2
2
|
CometChatMessageInformation,
|
|
3
3
|
CometChatMessageInformationInterface,
|
|
4
4
|
} from "./CometChatMessageInformation";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
CometChatMessageInformationConfigurationInterface,
|
|
7
|
+
CometChatMessageInformationConfiguration
|
|
8
|
+
} from "./MessageInformationConfiguration";
|
|
6
9
|
import { MessageInformationStyleInterface } from "./MessageInformationStyle";
|
|
7
10
|
|
|
8
|
-
export { CometChatMessageInformation };
|
|
11
|
+
export { CometChatMessageInformation, CometChatMessageInformationConfiguration };
|
|
9
12
|
export type {
|
|
10
13
|
CometChatMessageInformationInterface,
|
|
11
|
-
|
|
14
|
+
CometChatMessageInformationConfigurationInterface,
|
|
12
15
|
MessageInformationStyleInterface,
|
|
13
16
|
};
|
|
@@ -25,7 +25,7 @@ import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandle
|
|
|
25
25
|
import { ActionSheetStylesInterface } from "../shared/views/CometChatActionSheet/ActionSheetStyle";
|
|
26
26
|
import { CometChatMessageInformation } from "../CometChatMessageInformation/CometChatMessageInformation";
|
|
27
27
|
// import { CometChatContacts, ForwardMessageConfigurationInterface } from "../CometChatContacts";
|
|
28
|
-
import {
|
|
28
|
+
import { CometChatMessageInformationConfigurationInterface } from "../CometChatMessageInformation";
|
|
29
29
|
import { InteractiveMessageUtils } from "../shared/utils/InteractiveMessageUtils";
|
|
30
30
|
import { CometChatEmojiKeyboard, EmojiKeyboardStyle } from "../shared/views/CometChatEmojiKeyboard";
|
|
31
31
|
import { CometChatReactionList, ReactionListConfigurationInterface } from "../shared/views/CometChatReactionList";
|
|
@@ -93,10 +93,15 @@ export interface CometChatMessageListProps {
|
|
|
93
93
|
onError?: (e: CometChat.CometChatException) => void,
|
|
94
94
|
onBack?: () => void,
|
|
95
95
|
// forwardMessageConfiguration?: ForwardMessageConfigurationInterface,
|
|
96
|
-
messageInformationConfiguration?:
|
|
96
|
+
messageInformationConfiguration?: CometChatMessageInformationConfigurationInterface,
|
|
97
97
|
/**
|
|
98
98
|
* Hide the header of the action sheet
|
|
99
99
|
*/
|
|
100
|
+
/**
|
|
101
|
+
* @deprecated
|
|
102
|
+
*
|
|
103
|
+
* This property is deprecated as of version 4.3.20, as it is no longer needed. It will be removed in subsequent versions.
|
|
104
|
+
*/
|
|
100
105
|
hideActionSheetHeader?: boolean,
|
|
101
106
|
/**
|
|
102
107
|
* Message Reaction Configuration @ReactionsConfigurationInterface
|
|
@@ -181,7 +186,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
181
186
|
onBack,
|
|
182
187
|
// forwardMessageConfiguration
|
|
183
188
|
messageInformationConfiguration,
|
|
184
|
-
hideActionSheetHeader,
|
|
189
|
+
hideActionSheetHeader = true,
|
|
185
190
|
reactionsConfiguration,
|
|
186
191
|
disableReactions,
|
|
187
192
|
reactionListConfiguration,
|
|
@@ -331,6 +336,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
331
336
|
const bottomSheetRef = useRef<any>(null)
|
|
332
337
|
const conversationId = useRef(null)
|
|
333
338
|
let lastID = useRef(0);
|
|
339
|
+
let isKeyBoardVisible = useRef(false);
|
|
334
340
|
|
|
335
341
|
const scrollHandler = (event: any) => {
|
|
336
342
|
/********************************************************************************
|
|
@@ -377,7 +383,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
377
383
|
}
|
|
378
384
|
|
|
379
385
|
const newMsgIndicatorPressed = () => {
|
|
380
|
-
|
|
386
|
+
messageListRef.current?.scrollToEnd({ animated: true });
|
|
381
387
|
markUnreadMessageAsRead();
|
|
382
388
|
};
|
|
383
389
|
|
|
@@ -494,7 +500,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
494
500
|
})
|
|
495
501
|
if (inProgressMessages.current.length) {
|
|
496
502
|
const filteredInProgressMessages = inProgressMessages.current.filter(secondItem =>
|
|
497
|
-
|
|
503
|
+
tmpList.some(firstItem => firstItem.muid === secondItem.muid)
|
|
498
504
|
);
|
|
499
505
|
const combinedArray = CommonUtils.mergeArrays(tmpList, filteredInProgressMessages, "muid");
|
|
500
506
|
tmpList = combinedArray
|
|
@@ -671,7 +677,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
671
677
|
}
|
|
672
678
|
function checkSameConversation(message: CometChat.BaseMessage): boolean {
|
|
673
679
|
return message.getConversationId() == conversationId.current ||
|
|
674
|
-
(message.getSender()?.
|
|
680
|
+
(message.getSender()?.getUid() === user?.getUid() && message.getReceiverType() == CometChatUiKitConstants.ReceiverTypeConstants.user);
|
|
675
681
|
}
|
|
676
682
|
|
|
677
683
|
function isNearBottom() {
|
|
@@ -788,7 +794,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
788
794
|
let condition: (value: any, index: number, obj: any[]) => unknown;
|
|
789
795
|
if (withMuid) {
|
|
790
796
|
condition = (msg) => msg['muid'] == editedMessage['muid']
|
|
791
|
-
inProgressMessages.current = inProgressMessages.current.filter((item: anyObject) => item.muid !== editedMessage['muid'])
|
|
797
|
+
//inProgressMessages.current = inProgressMessages.current.filter((item: anyObject) => item.muid !== editedMessage['muid'])
|
|
792
798
|
}
|
|
793
799
|
else
|
|
794
800
|
condition = (msg) => msg.getId() == editedMessage.getId()
|
|
@@ -864,7 +870,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
864
870
|
}
|
|
865
871
|
|
|
866
872
|
const handlePannel = (item: any) => {
|
|
867
|
-
if (item.alignment === ViewAlignment.messageListBottom && user
|
|
873
|
+
if (item.alignment === ViewAlignment.messageListBottom && (user || group) && CommonUtils.checkIdBelongsToThisComponent(item.id, user, group, parentMessageId || '')) {
|
|
868
874
|
if (item.child)
|
|
869
875
|
setCustomListHeader(() => item.child)
|
|
870
876
|
else
|
|
@@ -1196,8 +1202,20 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1196
1202
|
Keyboard_Height = keyboardHeight;
|
|
1197
1203
|
scrollPos = (currentScrollPosition.current.y + Keyboard_Height) - ((commonVars.safeAreaInsets.top as number) / 2);
|
|
1198
1204
|
messageListRef.current.scrollTo({ y: scrollPos, animated: false })
|
|
1205
|
+
isKeyBoardVisible.current = true;
|
|
1199
1206
|
} else {
|
|
1200
|
-
|
|
1207
|
+
isKeyBoardVisible.current = false;
|
|
1208
|
+
/**
|
|
1209
|
+
* Do not have to scroll back if the list is at the bottom because we are already adjusting
|
|
1210
|
+
for the change in contentSize when we are at bottom which means if the list is at the bottom
|
|
1211
|
+
and we open the keyboard, the following line
|
|
1212
|
+
(`messageListRef.current.scrollTo({ y: scrollPos, animated: false })`) in the above "if"
|
|
1213
|
+
condition already puts the list at the bottom again.
|
|
1214
|
+
Hence, running the below for isAtBottom() will scroll to a wrong position.
|
|
1215
|
+
*/
|
|
1216
|
+
if(!isAtBottom()) {
|
|
1217
|
+
messageListRef.current.scrollTo({ y: scrollPos - Keyboard_Height + ((commonVars.safeAreaInsets.top as number) / 2), animated: false });
|
|
1218
|
+
}
|
|
1201
1219
|
}
|
|
1202
1220
|
}
|
|
1203
1221
|
}
|
|
@@ -1308,9 +1326,11 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1308
1326
|
if (timeStampAlignment == "top" || item['category'] == "action" || item['deletedAt']) return null
|
|
1309
1327
|
|
|
1310
1328
|
let isSender = (item.getSender()?.getUid() || item?.['sender']?.['uid']) == loggedInUser.current?.getUid();
|
|
1311
|
-
let messageState;
|
|
1312
|
-
|
|
1313
|
-
|
|
1329
|
+
let messageState, nextItemIsRead, nextItemIsDelivered;
|
|
1330
|
+
if(currentIndex !== undefined) {
|
|
1331
|
+
nextItemIsRead = messagesContentListRef.current[currentIndex + 1] && messagesContentListRef.current[currentIndex + 1].getReadAt();
|
|
1332
|
+
nextItemIsDelivered = messagesContentListRef.current[currentIndex + 1] && messagesContentListRef.current[currentIndex + 1].getDeliveredAt();
|
|
1333
|
+
}
|
|
1314
1334
|
if (item.getReadAt() || nextItemIsRead)
|
|
1315
1335
|
messageState = "READ";
|
|
1316
1336
|
else if (item.getDeliveredAt() || nextItemIsDelivered)
|
|
@@ -1625,7 +1645,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1625
1645
|
const openOptionsForMessage = useCallback((item: CometChat.BaseMessage | any, template: CometChatMessageTemplate) => {
|
|
1626
1646
|
let options = template?.options ? loggedInUser.current ? template.options(loggedInUser.current, item, group) : [] : [];
|
|
1627
1647
|
let optionsWithPressHandling = options.map(option => {
|
|
1628
|
-
if (!option.onPress)
|
|
1648
|
+
if (!option.onPress){
|
|
1629
1649
|
switch (option.id) {
|
|
1630
1650
|
case MessageOptionConstants.messageInformation:
|
|
1631
1651
|
option.onPress = openMessageInfo.bind(this, item);
|
|
@@ -1652,6 +1672,14 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1652
1672
|
option.onPress = shareMedia.bind(this, item);
|
|
1653
1673
|
break;
|
|
1654
1674
|
}
|
|
1675
|
+
}else{
|
|
1676
|
+
// If overriding `onPress`, make sure to pass `item` explicitly
|
|
1677
|
+
const customOnPress = option.onPress;
|
|
1678
|
+
option.onPress = () =>{
|
|
1679
|
+
customOnPress(item);
|
|
1680
|
+
setShowMessageOptions([]);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1655
1683
|
if (option.id === MessageOptionConstants.reactToMessage) {
|
|
1656
1684
|
option.onPress = () => {
|
|
1657
1685
|
if (option.CustomView) {
|
|
@@ -1902,6 +1930,51 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1902
1930
|
currentScrollPosition.current.scrollViewHeight = contentHeight;
|
|
1903
1931
|
}
|
|
1904
1932
|
}
|
|
1933
|
+
|
|
1934
|
+
/**
|
|
1935
|
+
* If Keyboard is open, recalculate the scroll position when content size changes
|
|
1936
|
+
*/
|
|
1937
|
+
if(isKeyBoardVisible.current == true) {
|
|
1938
|
+
/**
|
|
1939
|
+
* WITHOUT the isAtBottom() check, the following will happen:
|
|
1940
|
+
* 1. nearToBottom() is true (which is up to 2 messages from bottom)
|
|
1941
|
+
* 2. A new message is received (or any event that changes the content size)
|
|
1942
|
+
but the UI issue is mainly with a new message
|
|
1943
|
+
* 3. Since the content size has increased, we are not nearToBotom() anymore
|
|
1944
|
+
and so the unread banner will be displayed to click and scroll to bottom
|
|
1945
|
+
* 4. If there's not isAtBottomCheck() below, `onKeyboardVisibilityChange()` runs
|
|
1946
|
+
to adjust for the change in content size and this triggers a scroll
|
|
1947
|
+
messageListRef.current.scrollTo({ y: scrollPos, animated: false })
|
|
1948
|
+
* 5. And the nearToBottom() is true again since we have accounted for the change
|
|
1949
|
+
in contentSize and the banner disappears and the list scrolls to the bottom
|
|
1950
|
+
*
|
|
1951
|
+
* The above breaks the UI!
|
|
1952
|
+
*/
|
|
1953
|
+
|
|
1954
|
+
/**
|
|
1955
|
+
* Why not do this for isAtBottom() || !isNearBottom()?
|
|
1956
|
+
* - (isAtBottom() || !isNearBottom()) means notAtBottom() and notNearBottom()
|
|
1957
|
+
This means there's content under the keyboard but that's not the end.
|
|
1958
|
+
Everytime a new message is received contentSize will change and that will
|
|
1959
|
+
trigger a position recalculation and a scroll and the list will keep scrolling
|
|
1960
|
+
till we reach bottom (that is if we keep receiving messages).
|
|
1961
|
+
*
|
|
1962
|
+
*/
|
|
1963
|
+
if (isAtBottom()) {
|
|
1964
|
+
/**
|
|
1965
|
+
* Why is this required?
|
|
1966
|
+
* 1. Let's say the scroll is nearToBottom() and the keyboard is open
|
|
1967
|
+
* 2. User receives a new message and the content size changes.
|
|
1968
|
+
* 3. The Message List scrolls to the bottom since the scroll was nearToBottom()
|
|
1969
|
+
* 4. User closes the keyboard and the list scrolls back to the previous message
|
|
1970
|
+
* that was nearToBottom()
|
|
1971
|
+
* 5. The position to scroll back to needs to be recalculated since the contentSize
|
|
1972
|
+
has changed. Calling `onKeyboardVisibiltyChange()` does this.
|
|
1973
|
+
*
|
|
1974
|
+
*/
|
|
1975
|
+
onKeyboardVisibiltyChange(true, Keyboard_Height);
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1905
1978
|
}, [])
|
|
1906
1979
|
|
|
1907
1980
|
const {
|