@cometchat/chat-uikit-react-native 4.3.17 → 4.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/CometChatAddMembers/CometChatAddMembers.tsx +2 -1
- package/src/CometChatBannedMembers/CometChatBannedMembers.tsx +3 -0
- package/src/CometChatConversations/CometChatConversations.tsx +89 -53
- package/src/CometChatConversations/ConversationsConfiguration.ts +14 -0
- package/src/CometChatConversationsWithMessages/CometChatConversationsWithMessages.tsx +1 -0
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +10 -0
- package/src/CometChatMessageList/CometChatMessageList.tsx +80 -37
- package/src/CometChatMessageList/MessageListConfiguration.ts +25 -1
- package/src/shared/utils/CommonUtils.ts +9 -1
- package/src/shared/utils/MessageUtils.tsx +5 -3
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +6 -6
- package/src/shared/views/CometChatMessageBubble/MessageBubbleStyle.ts +4 -0
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
CometChatUsersInterface,
|
|
9
9
|
CometChatUsersActionsInterface,
|
|
10
10
|
} from '../CometChatUsers';
|
|
11
|
-
import { CometChatListStylesInterface, localize } from '../shared';
|
|
11
|
+
import { CometChatListStylesInterface, CometChatUiKitConstants, localize } from '../shared';
|
|
12
12
|
import { CometChatGroupsEvents } from '../shared/events';
|
|
13
13
|
import { CometChatUIEventHandler } from '../shared/events/CometChatUIEventHandler/CometChatUIEventHandler';
|
|
14
14
|
import { MessageTypeConstants } from '../shared/constants/UIKitConstants';
|
|
@@ -54,6 +54,7 @@ export const CometChatAddMembers = (props: CometChatAddMembersInterface) => {
|
|
|
54
54
|
CometChat.RECEIVER_TYPE.GROUP,
|
|
55
55
|
CometChat.CATEGORY_ACTION as CometChat.MessageCategory
|
|
56
56
|
);
|
|
57
|
+
action.setAction(CometChatUiKitConstants.groupMemberAction.ADDED);
|
|
57
58
|
action.setConversationId((group as any)['conversationId'])
|
|
58
59
|
action.setActionBy(loggedInUser.current);
|
|
59
60
|
action.setActionFor(group);
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
CometChatListProps,
|
|
12
12
|
CometChatListStylesInterface,
|
|
13
13
|
CometChatOptions,
|
|
14
|
+
CometChatUiKitConstants,
|
|
14
15
|
} from '../shared';
|
|
15
16
|
import { localize, ImageType } from '../shared';
|
|
16
17
|
import { CometChatGroupsEvents } from '../shared/events';
|
|
@@ -69,9 +70,11 @@ export const CometChatBannedMembers = (
|
|
|
69
70
|
CometChat.RECEIVER_TYPE.GROUP,
|
|
70
71
|
CometChat.CATEGORY_ACTION as CometChat.MessageCategory
|
|
71
72
|
);
|
|
73
|
+
action.setAction(CometChatUiKitConstants.groupMemberAction.UNBANNED)
|
|
72
74
|
action.setActionBy(loggedUserRef.current);
|
|
73
75
|
action.setMessage(`${loggedUserRef.current['name']} unbanned ${user['name']}}`)
|
|
74
76
|
action.setActionFor(group);
|
|
77
|
+
action.setActionOn(user)
|
|
75
78
|
action.setSender(loggedUserRef.current);
|
|
76
79
|
|
|
77
80
|
CometChatUIEventHandler.emitGroupEvent(
|
|
@@ -57,13 +57,12 @@ export interface ConversationInterface {
|
|
|
57
57
|
*/
|
|
58
58
|
disableUsersPresence?: boolean,
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
* disable message receipts
|
|
65
|
-
*/
|
|
60
|
+
* @deprecated
|
|
61
|
+
*
|
|
62
|
+
* This property is deprecated as of version 4.3.18 due to newer property 'hideReceipt'. It will be removed in subsequent versions.
|
|
63
|
+
*/
|
|
66
64
|
disableReceipt?: boolean,
|
|
65
|
+
hideReceipt?: boolean,
|
|
67
66
|
/**
|
|
68
67
|
* toggle typing indicator
|
|
69
68
|
*/
|
|
@@ -250,8 +249,8 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
250
249
|
*/
|
|
251
250
|
const {
|
|
252
251
|
disableUsersPresence = false,
|
|
253
|
-
disableReadReceipt = false,
|
|
254
252
|
disableReceipt = false,
|
|
253
|
+
hideReceipt = false,
|
|
255
254
|
disableTyping = false,
|
|
256
255
|
disableSoundForMessages = false,
|
|
257
256
|
customSoundForMessages,
|
|
@@ -432,48 +431,74 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
432
431
|
}
|
|
433
432
|
|
|
434
433
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
return
|
|
434
|
+
/**
|
|
435
|
+
* Check if last message/unread count should be updated
|
|
436
|
+
*
|
|
437
|
+
* @param newMessage message object
|
|
438
|
+
*/
|
|
439
|
+
const shouldUpdateLastMessageAndUnreadCount = (
|
|
440
|
+
message: CometChat.BaseMessage
|
|
441
|
+
) => {
|
|
442
|
+
const messageReceiverType = message.getReceiverType();
|
|
443
|
+
if (
|
|
444
|
+
conversationsRequestBuilder &&
|
|
445
|
+
conversationsRequestBuilder.build().getConversationType() &&
|
|
446
|
+
conversationsRequestBuilder.build().getConversationType() !=
|
|
447
|
+
messageReceiverType
|
|
448
|
+
) {
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
/****Start: Should Threaded Messages Update Conversation? */
|
|
452
|
+
if (
|
|
453
|
+
message.getParentMessageId() &&
|
|
454
|
+
!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnMessageReplies()
|
|
455
|
+
) {
|
|
456
|
+
return false;
|
|
457
|
+
}
|
|
458
|
+
/****END: Should Threaded Messages Update Conversation? */
|
|
459
|
+
|
|
460
|
+
/****Start: Should Custom Message Update Conversation? */
|
|
461
|
+
if (
|
|
462
|
+
message.getCategory() ==
|
|
463
|
+
CometChatUiKitConstants.MessageCategoryConstants.custom
|
|
464
|
+
) {
|
|
465
|
+
let customMessage = message as CometChat.CustomMessage;
|
|
466
|
+
if (
|
|
467
|
+
!customMessage.willUpdateConversation() &&
|
|
468
|
+
!(
|
|
469
|
+
customMessage.getMetadata() &&
|
|
470
|
+
(customMessage.getMetadata() as any)['incrementUnreadCount']
|
|
471
|
+
) &&
|
|
472
|
+
!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCustomMessages()
|
|
473
|
+
) {
|
|
474
|
+
return false;
|
|
475
|
+
}
|
|
476
476
|
}
|
|
477
|
+
/****End: Should Custom Message Update Conversation? */
|
|
478
|
+
|
|
479
|
+
/****Start: Should Group Actions sent update conversation? */
|
|
480
|
+
if (
|
|
481
|
+
message.getCategory() ==
|
|
482
|
+
CometChatUiKitConstants.MessageCategoryConstants.action &&
|
|
483
|
+
message.getReceiverType() ==
|
|
484
|
+
CometChatUiKitConstants.ReceiverTypeConstants.group
|
|
485
|
+
) {
|
|
486
|
+
return CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnGroupActions();
|
|
487
|
+
}
|
|
488
|
+
/****End: Should Group Actions sent update conversation? */
|
|
489
|
+
|
|
490
|
+
/****Start: Should Call Actions sent Update Conversation? */
|
|
491
|
+
if (
|
|
492
|
+
message.getCategory() ==
|
|
493
|
+
CometChatUiKitConstants.MessageCategoryConstants.call &&
|
|
494
|
+
!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()
|
|
495
|
+
) {
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
/****End: Should Call Actions sent Update Conversation */
|
|
499
|
+
|
|
500
|
+
return true;
|
|
501
|
+
};
|
|
477
502
|
|
|
478
503
|
/**
|
|
479
504
|
* Find conversation from state and udpate its last message object.
|
|
@@ -582,7 +607,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
582
607
|
*/
|
|
583
608
|
const messageEventHandler = (...args: any[]) => {
|
|
584
609
|
let message = args[0];
|
|
585
|
-
!
|
|
610
|
+
!disableReceipt && markMessageAsDelivered(message);
|
|
586
611
|
updateLastMessage(message);
|
|
587
612
|
}
|
|
588
613
|
|
|
@@ -591,6 +616,14 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
591
616
|
* @param {obj} message
|
|
592
617
|
*/
|
|
593
618
|
const groupHandler = (message: any, otherDetails: {action?: string, actionOn?: CometChat.User, actionBy?: CometChat.User, group?: CometChat.Group} = {}) => {
|
|
619
|
+
if (
|
|
620
|
+
conversationsRequestBuilder &&
|
|
621
|
+
conversationsRequestBuilder.build().getConversationType() &&
|
|
622
|
+
conversationsRequestBuilder.build().getConversationType() !=
|
|
623
|
+
CometChatUiKitConstants.ReceiverTypeConstants.group
|
|
624
|
+
) {
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
594
627
|
let conversation : CometChat.Conversation = (conversationListRef.current?.getListItem(message['conversationId']) as unknown as CometChat.Conversation);
|
|
595
628
|
let {action, actionOn, actionBy, group} = otherDetails;
|
|
596
629
|
if (conversation) {
|
|
@@ -763,7 +796,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
763
796
|
</View>
|
|
764
797
|
}
|
|
765
798
|
|
|
766
|
-
if (lastMessage &&
|
|
799
|
+
if (lastMessage && lastMessage['sender']['uid'] == loggedInUser.current?.uid && !lastMessage.getDeletedAt()) {
|
|
767
800
|
let status: MessageReceipt = "ERROR";
|
|
768
801
|
if (lastMessage?.hasOwnProperty('readAt'))
|
|
769
802
|
status = "READ";
|
|
@@ -771,7 +804,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
771
804
|
status = "DELIVERED";
|
|
772
805
|
else if (lastMessage?.hasOwnProperty("sentAt"))
|
|
773
806
|
status = "SENT";
|
|
774
|
-
readReceipt = disableReceipt ? null : <CometChatReceipt
|
|
807
|
+
readReceipt = (disableReceipt || hideReceipt) ? null : <CometChatReceipt
|
|
775
808
|
receipt={status}
|
|
776
809
|
deliveredIcon={props.deliveredIcon}
|
|
777
810
|
errorIcon={props.errorIcon}
|
|
@@ -1079,10 +1112,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1079
1112
|
checkAndUpdateLastMessage(editedMessage)
|
|
1080
1113
|
},
|
|
1081
1114
|
onMessagesRead: (messageReceipt: any) => {
|
|
1082
|
-
|
|
1115
|
+
updateMessageReceipt(messageReceipt);
|
|
1083
1116
|
},
|
|
1084
1117
|
onMessagesDelivered: (messageReceipt: any) => {
|
|
1085
|
-
|
|
1118
|
+
updateMessageReceipt(messageReceipt);
|
|
1086
1119
|
},
|
|
1087
1120
|
onMessagesDeliveredToAll: (messageReceipt: CometChat.MessageReceipt) => {
|
|
1088
1121
|
updateMessageReceipt(messageReceipt);
|
|
@@ -1184,6 +1217,9 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1184
1217
|
userListenerId,
|
|
1185
1218
|
{
|
|
1186
1219
|
ccUserBlocked: ({ user }: any) => {
|
|
1220
|
+
if(conversationsRequestBuilder && conversationsRequestBuilder.build().isIncludeBlockedUsers()) {
|
|
1221
|
+
return;
|
|
1222
|
+
}
|
|
1187
1223
|
conversationListRef?.current?.removeItemFromList(user['conversationId']);
|
|
1188
1224
|
removeItemFromSelectionList(user['conversationId']);
|
|
1189
1225
|
}
|
|
@@ -12,7 +12,13 @@ import { BadgeStyleInterface } from "../shared/views/CometChatBadge";
|
|
|
12
12
|
|
|
13
13
|
export interface ConversationsConfigurationInterface {
|
|
14
14
|
disableUsersPresence?: boolean,
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated
|
|
17
|
+
*
|
|
18
|
+
* This property is deprecated as of version 4.3.18 due to newer property 'hideReceipt'. It will be removed in subsequent versions.
|
|
19
|
+
*/
|
|
15
20
|
disableReceipt?: boolean,
|
|
21
|
+
hideReceipt?: boolean,
|
|
16
22
|
disableTyping?: boolean,
|
|
17
23
|
disableSoundForMessages?: boolean,
|
|
18
24
|
customSoundForMessages?: string,
|
|
@@ -66,7 +72,13 @@ export interface ConversationsConfigurationInterface {
|
|
|
66
72
|
*/
|
|
67
73
|
export class ConversationsConfiguration implements ConversationsConfigurationInterface {
|
|
68
74
|
disableUsersPresence?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated
|
|
77
|
+
*
|
|
78
|
+
* This property is deprecated as of version 4.3.18 due to newer property 'hideReceipt'. It will be removed in subsequent versions.
|
|
79
|
+
*/
|
|
69
80
|
disableReceipt?: boolean;
|
|
81
|
+
hideReceipt?: boolean;
|
|
70
82
|
disableTyping?: boolean;
|
|
71
83
|
disableSoundForMessages?: boolean;
|
|
72
84
|
customSoundForMessages?: string;
|
|
@@ -117,6 +129,7 @@ export class ConversationsConfiguration implements ConversationsConfigurationInt
|
|
|
117
129
|
constructor({
|
|
118
130
|
disableUsersPresence = false,
|
|
119
131
|
disableReceipt = false,
|
|
132
|
+
hideReceipt=false,
|
|
120
133
|
disableTyping = false,
|
|
121
134
|
disableSoundForMessages = false,
|
|
122
135
|
customSoundForMessages = undefined,
|
|
@@ -159,6 +172,7 @@ export class ConversationsConfiguration implements ConversationsConfigurationInt
|
|
|
159
172
|
}: ConversationsConfigurationInterface) {
|
|
160
173
|
this.disableUsersPresence = disableUsersPresence;
|
|
161
174
|
this.disableReceipt = disableReceipt;
|
|
175
|
+
this.hideReceipt=hideReceipt;
|
|
162
176
|
this.disableTyping = disableTyping;
|
|
163
177
|
this.disableSoundForMessages = disableSoundForMessages;
|
|
164
178
|
this.customSoundForMessages = customSoundForMessages;
|
|
@@ -222,6 +222,7 @@ export const CometChatConversationsWithMessages = (props: CometChatConversations
|
|
|
222
222
|
undefined
|
|
223
223
|
}
|
|
224
224
|
{..._messagesConfig}
|
|
225
|
+
threadedMessagesConfiguration={_messagesConfig.threadedMessageConfiguration ? _messagesConfig.threadedMessageConfiguration : {}}
|
|
225
226
|
/>
|
|
226
227
|
</View>
|
|
227
228
|
}
|
|
@@ -246,6 +246,7 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
|
|
|
246
246
|
groupRef.current && groupRef.current?.removeItemFromList(user.uid);
|
|
247
247
|
removeMemerFromSelectionList(user['uid']);
|
|
248
248
|
let action: CometChat.Action = new CometChat.Action(group['guid'], MessageTypeConstants.groupMember, CometChat.RECEIVER_TYPE.GROUP, CometChat.CATEGORY_ACTION as CometChat.MessageCategory);
|
|
249
|
+
action.setAction(CometChatUiKitConstants.groupMemberAction.BANNED)
|
|
249
250
|
action.setActionBy(loggedInUser.current);
|
|
250
251
|
action.setActionOn(user);
|
|
251
252
|
action.setActionFor(group);
|
|
@@ -276,6 +277,7 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
|
|
|
276
277
|
group.setMembersCount(group.getMembersCount() - 1);
|
|
277
278
|
|
|
278
279
|
let action: CometChat.Action = new CometChat.Action(group['guid'], MessageTypeConstants.groupMember, CometChat.RECEIVER_TYPE.GROUP, CometChat.CATEGORY_ACTION as CometChat.MessageCategory);
|
|
280
|
+
action.setAction(CometChatUiKitConstants.groupMemberAction.KICKED)
|
|
279
281
|
action.setActionBy(loggedInUser.current);
|
|
280
282
|
action.setActionOn(user);
|
|
281
283
|
action.setActionFor(group);
|
|
@@ -416,6 +418,7 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
|
|
|
416
418
|
groupRef.current?.updateList(updatedMember);
|
|
417
419
|
setShowChangeScope(false);
|
|
418
420
|
let action: CometChat.Action = new CometChat.Action(group['guid'], "groupMember", CometChat.RECEIVER_TYPE.GROUP, CometChat.CATEGORY_ACTION as CometChat.MessageCategory);
|
|
421
|
+
action.setAction(CometChatUiKitConstants.groupMemberAction.SCOPE_CHANGE)
|
|
419
422
|
action.setActionBy(loggedInUser.current);
|
|
420
423
|
action.setActionOn(member);
|
|
421
424
|
action.setActionFor(group);
|
|
@@ -424,6 +427,13 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
|
|
|
424
427
|
action.setMuid(String(getUnixTimestampInMilliseconds()));
|
|
425
428
|
action.setSender(loggedInUser.current);
|
|
426
429
|
action.setReceiver(group);
|
|
430
|
+
action.setData({
|
|
431
|
+
extras: {
|
|
432
|
+
scope: {
|
|
433
|
+
new: newScope,
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
})
|
|
427
437
|
CometChatUIEventHandler.emitGroupEvent(CometChatGroupsEvents.ccGroupMemberScopeChanged, { action, updatedUser: updatedMember, scopeChangedTo: newScope, scopeChangedFrom: member.scope, group });
|
|
428
438
|
})
|
|
429
439
|
.catch((err: any) => {
|
|
@@ -3,7 +3,7 @@ import { View, FlatList, Text, Image, TouchableOpacity, ActivityIndicator, Modal
|
|
|
3
3
|
//@ts-ignore
|
|
4
4
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
5
5
|
import { LeftArrowCurve, RightArrowCurve } from "./resources";
|
|
6
|
-
import {
|
|
6
|
+
import { CometChatContext, CometChatMentionsFormatter, CometChatTextFormatter, CometChatUIKit, CometChatUiKitConstants, CometChatUrlsFormatter, ImageType, SuggestionItem } from "../shared";
|
|
7
7
|
import { MessageBubbleStyle, MessageBubbleStyleInterface } from "../shared/views/CometChatMessageBubble/MessageBubbleStyle";
|
|
8
8
|
import { AvatarStyle, AvatarStyleInterface } from "../shared";
|
|
9
9
|
import { CometChatAvatar, CometChatDate, CometChatReceipt, DateStyle } from "../shared";
|
|
@@ -52,7 +52,13 @@ export interface CometChatMessageListProps {
|
|
|
52
52
|
errorStateText?: String,
|
|
53
53
|
hideError?: boolean,
|
|
54
54
|
LoadingStateView?: () => JSX.Element,
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated
|
|
57
|
+
*
|
|
58
|
+
* This property is deprecated as of version 4.3.18 due to newer property 'hideReceipt'. It will be removed in subsequent versions.
|
|
59
|
+
*/
|
|
55
60
|
disableReceipt?: boolean,
|
|
61
|
+
hideReceipt?: boolean,
|
|
56
62
|
disableSoundForMessages?: boolean,
|
|
57
63
|
customSoundForMessages?: string,
|
|
58
64
|
readIcon?: ImageType,
|
|
@@ -146,6 +152,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
146
152
|
hideError,
|
|
147
153
|
LoadingStateView,
|
|
148
154
|
disableReceipt = false,
|
|
155
|
+
hideReceipt= false,
|
|
149
156
|
disableSoundForMessages,
|
|
150
157
|
customSoundForMessages,
|
|
151
158
|
readIcon,
|
|
@@ -290,7 +297,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
290
297
|
})).current;
|
|
291
298
|
|
|
292
299
|
// refs
|
|
293
|
-
const currentScrollPosition = useRef({ y: null, scrollViewHeight: 0, layoutHeight: 0 });
|
|
300
|
+
const currentScrollPosition = useRef({ y: null, scrollViewHeight: 0, layoutHeight: 0, contentHeight: 0 });
|
|
294
301
|
const previousScrollPosition = useRef({ y: 0, scrollViewHeight: 0 });
|
|
295
302
|
const messagesLength = useRef(0);
|
|
296
303
|
const prevMessagesLength = useRef(0);
|
|
@@ -326,6 +333,16 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
326
333
|
let lastID = useRef(0);
|
|
327
334
|
|
|
328
335
|
const scrollHandler = (event: any) => {
|
|
336
|
+
/********************************************************************************
|
|
337
|
+
* layoutMeasurement.height: The height of the visible area within the ScrollView.
|
|
338
|
+
* contentOffset.y: The current vertical scroll position (distance from the top of the content).
|
|
339
|
+
The y value in contentOffset indicates how far the top edge of the visible area is from the top of the scrollable content.
|
|
340
|
+
The x value (if applicable) indicates how far the left edge of the visible area is from the left of the scrollable content.
|
|
341
|
+
For example:
|
|
342
|
+
If contentOffset.y is 0, the top of the visible area is aligned with the top of the content.
|
|
343
|
+
If contentOffset.y is 50, the top of the visible area is 50 units (pixels) below the top of the content.
|
|
344
|
+
* contentSize.height: The total height of the scrollable content.
|
|
345
|
+
*********************************************************************************/
|
|
329
346
|
const { layoutMeasurement, contentOffset, contentSize } = event.nativeEvent;
|
|
330
347
|
const screenHeight = Dimensions.get('window').height;
|
|
331
348
|
|
|
@@ -334,6 +351,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
334
351
|
const scrollEndPosition = contentSize.height - screenHeight;
|
|
335
352
|
|
|
336
353
|
currentScrollPosition.current.y = contentOffset.y;
|
|
354
|
+
currentScrollPosition.current.contentHeight = contentSize.height;
|
|
337
355
|
|
|
338
356
|
if (currentScrollPosition.current.layoutHeight != layoutMeasurement.height) {
|
|
339
357
|
currentScrollPosition.current.layoutHeight = layoutMeasurement.height;
|
|
@@ -465,9 +483,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
465
483
|
.fetchNext()
|
|
466
484
|
.then((newMessages: any[]) => {
|
|
467
485
|
let cleanUpdatedList = [...updatedList];
|
|
468
|
-
|
|
469
|
-
let finalOutput = CommonUtils.mergeArrays(cleanUpdatedList, newMessages, "muid");
|
|
470
|
-
|
|
486
|
+
let finalOutput = CommonUtils.mergeArrays(cleanUpdatedList, newMessages, "id");
|
|
471
487
|
let tmpList = [...finalOutput];
|
|
472
488
|
tmpList = tmpList.map((item: CometChat.BaseMessage, index) => {
|
|
473
489
|
if (item.getCategory() === MessageCategoryConstants.interactive) {
|
|
@@ -485,7 +501,12 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
485
501
|
}
|
|
486
502
|
messagesContentListRef.current = tmpList;
|
|
487
503
|
setMessagesList(tmpList);
|
|
488
|
-
|
|
504
|
+
for(let i = newMessages.length - 1; i >= 0; i--) {
|
|
505
|
+
if(newMessages[i].getSender().getUid() !== loggedInUser.current.getUid()) {
|
|
506
|
+
bottomHandler(newMessages[i], true);
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
489
510
|
if (newMessages.length === 30) {
|
|
490
511
|
getNewMessages(tmpList);
|
|
491
512
|
}
|
|
@@ -649,7 +670,8 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
649
670
|
group?.getGuid() == message.getReceiverId() || false);
|
|
650
671
|
}
|
|
651
672
|
function checkSameConversation(message: CometChat.BaseMessage): boolean {
|
|
652
|
-
return message.getConversationId() == conversationId.current ||
|
|
673
|
+
return message.getConversationId() == conversationId.current ||
|
|
674
|
+
(message.getSender()?.['uid'] === user?.getUid() && message.getReceiverType() == CometChatUiKitConstants.ReceiverTypeConstants.user);
|
|
653
675
|
}
|
|
654
676
|
|
|
655
677
|
function isNearBottom() {
|
|
@@ -671,12 +693,14 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
671
693
|
newMessage = InteractiveMessageUtils.convertInteractiveMessage(baseMessage);
|
|
672
694
|
}
|
|
673
695
|
if (checkSameConversation(baseMessage) || checkMessageInSameConversation(baseMessage) || messageToSameConversation(baseMessage)) {
|
|
696
|
+
if(!disableReceipt) {
|
|
697
|
+
CometChat.markAsDelivered(newMessage);
|
|
698
|
+
}
|
|
674
699
|
//need to add
|
|
675
700
|
if (newMessage.getParentMessageId()) {
|
|
676
701
|
if (parentMessageId && newMessage.getParentMessageId() == parseInt(parentMessageId)) {
|
|
677
702
|
// add to list
|
|
678
703
|
messagesContentListRef.current = [...messagesContentListRef.current, newMessage];
|
|
679
|
-
inProgressMessages.current = [...inProgressMessages.current, newMessage]
|
|
680
704
|
setMessagesList(prev => [...prev, newMessage]);
|
|
681
705
|
} else {
|
|
682
706
|
//increase count
|
|
@@ -690,11 +714,10 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
690
714
|
tmpList[index] = oldMsg;
|
|
691
715
|
messagesContentListRef.current = tmpList;
|
|
692
716
|
setMessagesList(tmpList);
|
|
693
|
-
|
|
717
|
+
return;
|
|
694
718
|
}
|
|
695
719
|
} else if (parentMessageId == undefined) {
|
|
696
720
|
messagesContentListRef.current = [...messagesContentListRef.current, newMessage];
|
|
697
|
-
inProgressMessages.current = [...inProgressMessages.current, newMessage]
|
|
698
721
|
setMessagesList(prev => [...prev, newMessage]);
|
|
699
722
|
}
|
|
700
723
|
bottomHandler(newMessage, isReceived);
|
|
@@ -703,32 +726,45 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
703
726
|
playNotificationSound(newMessage);
|
|
704
727
|
}
|
|
705
728
|
|
|
706
|
-
const
|
|
729
|
+
const isAtBottom = () => {
|
|
730
|
+
if(
|
|
731
|
+
[null, undefined].includes(currentScrollPosition.current.y)
|
|
732
|
+
|| !currentScrollPosition.current.layoutHeight
|
|
733
|
+
|| !currentScrollPosition.current.contentHeight
|
|
734
|
+
) {
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
else if (currentScrollPosition.current.layoutHeight + currentScrollPosition.current.y! >= currentScrollPosition.current.contentHeight) {
|
|
738
|
+
return true;
|
|
739
|
+
}
|
|
707
740
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
}
|
|
714
|
-
CometChat.markAsDelivered(newMessage);
|
|
715
|
-
if (newMessage?.getReceiverType() == ReceiverTypeConstants.user) {
|
|
716
|
-
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageDelivered, { message: newMessage });
|
|
717
|
-
}
|
|
718
|
-
if (isNearBottom()) {
|
|
719
|
-
scrollToBottom();
|
|
720
|
-
if (isReceived) {
|
|
721
|
-
markMessageAsRead(newMessage);
|
|
722
|
-
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageRead, { message: newMessage });
|
|
723
|
-
}
|
|
724
|
-
} else if ((!parentMessageId && !(newMessage.getParentMessageId())) || (parentMessageId && newMessage.getParentMessageId() == parseInt(parentMessageId))) {
|
|
725
|
-
setUnreadCount(unreadCount + 1);
|
|
726
|
-
}
|
|
727
|
-
} else {
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
const bottomHandler = (newMessage: CometChat.BaseMessage | any, isReceived?: boolean) => {
|
|
745
|
+
if ((newMessage.getSender()?.getUid() || newMessage?.['sender']?.['uid']) == loggedInUser.current?.['uid']) {
|
|
728
746
|
scrollToBottom();
|
|
729
|
-
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
if(!isReceived) {
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
if (
|
|
753
|
+
(!parentMessageId && newMessage.getParentMessageId())
|
|
754
|
+
|| (parentMessageId && !newMessage.getParentMessageId())
|
|
755
|
+
|| (parentMessageId && newMessage.getParentMessageId() && parentMessageId != newMessage.getParentMessageId())
|
|
756
|
+
) {
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
if (isAtBottom() || isNearBottom()) {
|
|
760
|
+
scrollToBottom();
|
|
761
|
+
markMessageAsRead(newMessage)
|
|
762
|
+
} else {
|
|
763
|
+
if(scrollToBottomOnNewMessages) {
|
|
764
|
+
scrollToBottom();
|
|
730
765
|
markMessageAsRead(newMessage);
|
|
731
|
-
|
|
766
|
+
} else {
|
|
767
|
+
setUnreadCount(unreadCount + 1);
|
|
732
768
|
}
|
|
733
769
|
}
|
|
734
770
|
}
|
|
@@ -913,6 +949,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
913
949
|
newMessage(message);
|
|
914
950
|
},
|
|
915
951
|
onGroupMemberUnbanned: (message: any) => {
|
|
952
|
+
newMessage(message);
|
|
916
953
|
},
|
|
917
954
|
onMemberAddedToGroup: (message: any) => {
|
|
918
955
|
newMessage(message);
|
|
@@ -928,6 +965,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
928
965
|
{
|
|
929
966
|
ccMessageSent: ({ message, status }: any) => {
|
|
930
967
|
if (status == MessageStatusConstants.inprogress) {
|
|
968
|
+
inProgressMessages.current = [...inProgressMessages.current, message]
|
|
931
969
|
newMessage(message, false);
|
|
932
970
|
}
|
|
933
971
|
|
|
@@ -1022,6 +1060,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1022
1060
|
message['message'] = `${loggedInUser.current?.getName()} added ${user.name}`;
|
|
1023
1061
|
message['muid'] = String(getUnixTimestamp());
|
|
1024
1062
|
message['sentAt'] = getUnixTimestamp();
|
|
1063
|
+
message['actionOn'] = user;
|
|
1025
1064
|
newMessage(message, false);
|
|
1026
1065
|
})
|
|
1027
1066
|
},
|
|
@@ -1093,7 +1132,9 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1093
1132
|
connectionListenerId,
|
|
1094
1133
|
new CometChat.ConnectionListener({
|
|
1095
1134
|
onConnected: () => {
|
|
1096
|
-
|
|
1135
|
+
if(lastID.current) {
|
|
1136
|
+
getUpdatedPreviousMessages();
|
|
1137
|
+
}
|
|
1097
1138
|
},
|
|
1098
1139
|
inConnecting: () => {
|
|
1099
1140
|
},
|
|
@@ -1300,7 +1341,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1300
1341
|
dateAlignment="center"
|
|
1301
1342
|
/>
|
|
1302
1343
|
{
|
|
1303
|
-
(!disableReceipt && alignment !== "leftAligned") && isSender ?
|
|
1344
|
+
(!(disableReceipt || hideReceipt) && alignment !== "leftAligned") && isSender ?
|
|
1304
1345
|
<View style={{ marginLeft: 2, alignItems: "center", justifyContent: "center" }}>
|
|
1305
1346
|
<CometChatReceipt
|
|
1306
1347
|
receipt={messageState}
|
|
@@ -1475,8 +1516,8 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1475
1516
|
});
|
|
1476
1517
|
};
|
|
1477
1518
|
|
|
1478
|
-
const getStyle = useCallback((item: CometChat.BaseMessage | any):
|
|
1479
|
-
let _style = new
|
|
1519
|
+
const getStyle = useCallback((item: CometChat.BaseMessage | any): MessageBubbleStyleInterface => {
|
|
1520
|
+
let _style = new MessageBubbleStyle({
|
|
1480
1521
|
..._messageBubbleStyle,
|
|
1481
1522
|
backgroundColor: theme?.palette.getAccent50()
|
|
1482
1523
|
});
|
|
@@ -1485,6 +1526,8 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1485
1526
|
if (item.getType() === MessageTypeConstants.form || item.getType() === MessageTypeConstants.card) {
|
|
1486
1527
|
_style.width = "100%"
|
|
1487
1528
|
}
|
|
1529
|
+
} else {
|
|
1530
|
+
_style.alignSelf = getAlignment(item) === "left" ? "flex-start" : "flex-end";
|
|
1488
1531
|
}
|
|
1489
1532
|
|
|
1490
1533
|
if ((item.getSender()?.getUid() || item?.['sender']?.['uid']) == loggedInUser.current?.['uid'])
|
|
@@ -29,7 +29,13 @@ export interface MessageListConfigurationInterface {
|
|
|
29
29
|
EmptyStateView?: () => JSX.Element;
|
|
30
30
|
emptyStateText?: String;
|
|
31
31
|
LoadingStateView?: () => JSX.Element;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated
|
|
34
|
+
*
|
|
35
|
+
* This property is deprecated as of version 4.3.18 due to newer property 'hideReceipt'. It will be removed in subsequent versions.
|
|
36
|
+
*/
|
|
32
37
|
disableReceipt?: boolean;
|
|
38
|
+
hideReceipt?: boolean;
|
|
33
39
|
readIcon?: ImageType;
|
|
34
40
|
deliveredIcon?: ImageType;
|
|
35
41
|
sentIcon?: ImageType;
|
|
@@ -47,7 +53,13 @@ export interface MessageListConfigurationInterface {
|
|
|
47
53
|
timestampAlignment?: MessageTimeAlignmentType;
|
|
48
54
|
templates?: CometChatMessageTemplate[];
|
|
49
55
|
messageRequestBuilder?: CometChat.MessagesRequestBuilder;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated
|
|
58
|
+
*
|
|
59
|
+
* This property is deprecated as of version 4.3.18 due to newer property 'scrollToBottomOnNewMessages'. It will be removed in subsequent versions.
|
|
60
|
+
*/
|
|
50
61
|
scrollToBottomOnNewMessage?: boolean;
|
|
62
|
+
scrollToBottomOnNewMessages?: boolean;
|
|
51
63
|
onThreadRepliesPress?: (
|
|
52
64
|
messageObject: CometChat.BaseMessage,
|
|
53
65
|
messageBubbleView: () => JSX.Element | null
|
|
@@ -132,7 +144,13 @@ export class MessageListConfiguration
|
|
|
132
144
|
timestampAlignment!: MessageTimeAlignmentType;
|
|
133
145
|
templates!: CometChatMessageTemplate[];
|
|
134
146
|
messageRequestBuilder!: CometChat.MessagesRequestBuilder;
|
|
147
|
+
/**
|
|
148
|
+
* @deprecated
|
|
149
|
+
*
|
|
150
|
+
* This property is deprecated as of version 4.3.18 due to newer property 'scrollToBottomOnNewMessages'. It will be removed in subsequent versions.
|
|
151
|
+
*/
|
|
135
152
|
scrollToBottomOnNewMessage!: boolean;
|
|
153
|
+
scrollToBottomOnNewMessages!: boolean;
|
|
136
154
|
onThreadRepliesPress?: (
|
|
137
155
|
messageObject: CometChat.BaseMessage,
|
|
138
156
|
messageBubbleView: () => JSX.Element | null
|
|
@@ -160,7 +178,13 @@ export class MessageListConfiguration
|
|
|
160
178
|
wrapperMessageBubbleStyle!: MessageStyleInterface;
|
|
161
179
|
actionSheetStyle!: ActionSheetStylesInterface;
|
|
162
180
|
messageListStyle!: MessageListStyleInterface;
|
|
163
|
-
|
|
181
|
+
/**
|
|
182
|
+
* @deprecated
|
|
183
|
+
*
|
|
184
|
+
* This property is deprecated as of version 4.3.18 due to newer property 'hideReceipt'. It will be removed in subsequent versions.
|
|
185
|
+
*/
|
|
186
|
+
disableReceipt?: boolean;
|
|
187
|
+
hideReceipt?: boolean;
|
|
164
188
|
dateSeparatorPattern!: (item: number) => DatePattern;
|
|
165
189
|
/**
|
|
166
190
|
* Hides the header of the action sheet
|
|
@@ -66,14 +66,22 @@ export class CommonUtils {
|
|
|
66
66
|
let map = new Map();
|
|
67
67
|
|
|
68
68
|
arr1.forEach(obj => {
|
|
69
|
+
if(!obj[key]) {
|
|
70
|
+
map.set(Date.now(), obj);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
69
73
|
map.set(obj[key], obj);
|
|
70
74
|
});
|
|
71
75
|
|
|
72
76
|
arr2.forEach(obj => {
|
|
73
|
-
if (map.has(obj[key])) {
|
|
77
|
+
if (map.has(obj[key]) && obj[key]) {
|
|
74
78
|
let mergedObj = this.mergeObjects(map.get(obj[key]), obj);
|
|
75
79
|
map.set(obj[key], mergedObj);
|
|
76
80
|
} else {
|
|
81
|
+
if(!obj[key]) {
|
|
82
|
+
map.set(Date.now(), obj);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
77
85
|
map.set(obj[key], obj);
|
|
78
86
|
}
|
|
79
87
|
});
|
|
@@ -8,6 +8,7 @@ import { ChatConfigurator } from "../framework";
|
|
|
8
8
|
import { CometChatMessageTemplate } from "../modals";
|
|
9
9
|
import { BaseStyle, MessageBubbleAlignmentType } from "../base";
|
|
10
10
|
import { CometChatUiKitConstants } from "..";
|
|
11
|
+
import { MessageBubbleStyle } from "../views/CometChatMessageBubble/MessageBubbleStyle";
|
|
11
12
|
|
|
12
13
|
type MessageViewType = {
|
|
13
14
|
message: CometChat.BaseMessage,
|
|
@@ -49,10 +50,11 @@ export const MessageUtils = {
|
|
|
49
50
|
} = params
|
|
50
51
|
|
|
51
52
|
const getStyle = (item: CometChat.BaseMessage) => {
|
|
52
|
-
let _style:
|
|
53
|
-
|
|
53
|
+
let _style: MessageBubbleStyle = {};
|
|
54
|
+
if(!(item instanceof CometChat.InteractiveMessage)) {
|
|
55
|
+
_style.alignSelf = alignment === "left" ? "flex-start" : "flex-end";
|
|
56
|
+
}
|
|
54
57
|
_style.backgroundColor = (alignment !== "left" && (item.getType() === MessageTypeConstants.text || item.getType() === MessageTypeConstants.meeting)) ? theme?.palette.getPrimary() : theme?.palette.getAccent50();
|
|
55
|
-
|
|
56
58
|
return _style;
|
|
57
59
|
};
|
|
58
60
|
|
|
@@ -2,7 +2,7 @@ import React, { useContext } from "react";
|
|
|
2
2
|
import { View, ViewProps } from "react-native";
|
|
3
3
|
import { CometChatContext } from "../../CometChatContext";
|
|
4
4
|
import { CometChatContextType, BaseStyleInterface } from "../../base";
|
|
5
|
-
import { MessageBubbleStyle } from "./MessageBubbleStyle";
|
|
5
|
+
import { MessageBubbleStyle, MessageBubbleStyleInterface } from "./MessageBubbleStyle";
|
|
6
6
|
import { memo } from "react";
|
|
7
7
|
import { MessageBubbleAlignmentType } from "../../base/Types";
|
|
8
8
|
|
|
@@ -61,7 +61,7 @@ export interface CometChatMessageBubbleInterface {
|
|
|
61
61
|
* The style of the message bubble.
|
|
62
62
|
* @type BaseStyleInterface
|
|
63
63
|
*/
|
|
64
|
-
style?:
|
|
64
|
+
style?: MessageBubbleStyleInterface,
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export const CometChatMessageBubble = memo(({
|
|
@@ -90,7 +90,8 @@ export const CometChatMessageBubble = memo(({
|
|
|
90
90
|
border,
|
|
91
91
|
borderRadius,
|
|
92
92
|
height,
|
|
93
|
-
width
|
|
93
|
+
width,
|
|
94
|
+
alignSelf
|
|
94
95
|
} = _style;
|
|
95
96
|
|
|
96
97
|
return (
|
|
@@ -119,9 +120,8 @@ export const CometChatMessageBubble = memo(({
|
|
|
119
120
|
...border,
|
|
120
121
|
borderRadius,
|
|
121
122
|
backgroundColor,
|
|
122
|
-
...(
|
|
123
|
-
|
|
124
|
-
}}>
|
|
123
|
+
...(alignSelf && { alignSelf })
|
|
124
|
+
} as ViewProps} >
|
|
125
125
|
{
|
|
126
126
|
ContentView && <ContentView />
|
|
127
127
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { BaseStyle, BaseStyleInterface, BorderStyle } from "../../base";
|
|
2
2
|
|
|
3
3
|
export interface MessageBubbleStyleInterface extends BaseStyleInterface {
|
|
4
|
+
alignSelf?: string;
|
|
4
5
|
}
|
|
5
6
|
|
|
6
7
|
export class MessageBubbleStyle extends BaseStyle {
|
|
8
|
+
alignSelf?: string;
|
|
7
9
|
constructor({
|
|
8
10
|
backgroundColor = "rgba(20,20,20,0.4)",
|
|
9
11
|
border = new BorderStyle({}),
|
|
10
12
|
borderRadius = 8,
|
|
11
13
|
height = "auto",
|
|
12
14
|
width = "auto",
|
|
15
|
+
alignSelf = null
|
|
13
16
|
}: MessageBubbleStyleInterface) {
|
|
14
17
|
super({
|
|
15
18
|
backgroundColor,
|
|
@@ -18,5 +21,6 @@ export class MessageBubbleStyle extends BaseStyle {
|
|
|
18
21
|
height,
|
|
19
22
|
width
|
|
20
23
|
})
|
|
24
|
+
this.alignSelf = alignSelf;
|
|
21
25
|
}
|
|
22
26
|
}
|