@cometchat/chat-uikit-react-native 4.3.17 → 4.3.19

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/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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "4.3.17",
3
+ "version": "4.3.19",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
@@ -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
- * toggle react receipt view
61
- */
62
- disableReadReceipt?: boolean,
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,
@@ -418,62 +417,92 @@ export const CometChatConversations = (props: ConversationInterface) => {
418
417
  *
419
418
  * @param newMessage message object
420
419
  */
421
- const checkAndUpdateLastMessage = (newMessage: CometChat.BaseMessage) => {
420
+ const checkAndUpdateLastMessage = (newMessage: CometChat.BaseMessage, resetUnreadCount = false) => {
422
421
  CometChat.CometChatHelper.getConversationFromMessage(newMessage)
423
422
  .then((conversation: any) => {
424
423
  let conver: any = conversationListRef.current?.getListItem(conversation.getConversationId())
425
424
  if (!conver) return;
426
425
  let lastMessageId = conver['lastMessage']['id']
427
426
  if (lastMessageId == newMessage['id']) {
428
- conversationListRef.current?.updateList(conversation)
427
+ if(resetUnreadCount) {
428
+ conver.setUnreadMessageCount(0);
429
+ }
430
+ conver.setLastMessage(newMessage)
431
+ conversationListRef.current?.updateList(conver)
429
432
  }
430
433
  })
431
434
 
432
435
  }
433
436
 
434
437
 
435
- /**
436
- * Check if last message/unread count should be updated
437
- *
438
- * @param newMessage message object
439
- */
440
- const shouldUpdateLastMessageAndUnreadCount = (message: CometChat.BaseMessage) => {
441
-
442
- /****Start: Should Threaded Messages Update Conversation? */
443
- if (message.getParentMessageId() && !CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnMessageReplies()) {
444
- return false;
445
- }
446
- /****END: Should Threaded Messages Update Conversation? */
447
-
448
- /****Start: Should Custom Message Update Conversation? */
449
- if (message.getCategory() == CometChatUiKitConstants.MessageCategoryConstants.custom) {
450
- let customMessage = message as CometChat.CustomMessage;
451
- if (!customMessage.willUpdateConversation() &&
452
- !(customMessage.getMetadata() && (customMessage.getMetadata() as any)["incrementUnreadCount"]) &&
453
- !CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCustomMessages()) {
454
- return false;
455
- }
456
- }
457
- /****End: Should Custom Message Update Conversation? */
458
-
459
- /****Start: Should Group Actions sent update conversation? */
460
- if (message.getCategory() == CometChatUiKitConstants.MessageCategoryConstants.action
461
- && message.getReceiverType() == CometChatUiKitConstants.ReceiverTypeConstants.group
462
- ) {
463
- return CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnGroupActions();
464
- }
465
- /****End: Should Group Actions sent update conversation? */
466
-
467
- /****Start: Should Call Actions sent Update Conversation? */
468
- if (message.getCategory() == CometChatUiKitConstants.MessageCategoryConstants.call
469
- && !CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()
470
- ) {
471
- return false;
472
- }
473
- /****End: Should Call Actions sent Update Conversation */
474
-
475
- return true;
438
+ /**
439
+ * Check if last message/unread count should be updated
440
+ *
441
+ * @param newMessage message object
442
+ */
443
+ const shouldUpdateLastMessageAndUnreadCount = (
444
+ message: CometChat.BaseMessage
445
+ ) => {
446
+ const messageReceiverType = message.getReceiverType();
447
+ if (
448
+ conversationsRequestBuilder &&
449
+ conversationsRequestBuilder.build().getConversationType() &&
450
+ conversationsRequestBuilder.build().getConversationType() !=
451
+ messageReceiverType
452
+ ) {
453
+ return false;
454
+ }
455
+ /****Start: Should Threaded Messages Update Conversation? */
456
+ if (
457
+ message.getParentMessageId() &&
458
+ !CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnMessageReplies()
459
+ ) {
460
+ return false;
461
+ }
462
+ /****END: Should Threaded Messages Update Conversation? */
463
+
464
+ /****Start: Should Custom Message Update Conversation? */
465
+ if (
466
+ message.getCategory() ==
467
+ CometChatUiKitConstants.MessageCategoryConstants.custom
468
+ ) {
469
+ let customMessage = message as CometChat.CustomMessage;
470
+ if (
471
+ !customMessage.willUpdateConversation() &&
472
+ !(
473
+ customMessage.getMetadata() &&
474
+ (customMessage.getMetadata() as any)['incrementUnreadCount']
475
+ ) &&
476
+ !CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCustomMessages()
477
+ ) {
478
+ return false;
479
+ }
476
480
  }
481
+ /****End: Should Custom Message Update Conversation? */
482
+
483
+ /****Start: Should Group Actions sent update conversation? */
484
+ if (
485
+ message.getCategory() ==
486
+ CometChatUiKitConstants.MessageCategoryConstants.action &&
487
+ message.getReceiverType() ==
488
+ CometChatUiKitConstants.ReceiverTypeConstants.group
489
+ ) {
490
+ return CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnGroupActions();
491
+ }
492
+ /****End: Should Group Actions sent update conversation? */
493
+
494
+ /****Start: Should Call Actions sent Update Conversation? */
495
+ if (
496
+ message.getCategory() ==
497
+ CometChatUiKitConstants.MessageCategoryConstants.call &&
498
+ !CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()
499
+ ) {
500
+ return false;
501
+ }
502
+ /****End: Should Call Actions sent Update Conversation */
503
+
504
+ return true;
505
+ };
477
506
 
478
507
  /**
479
508
  * Find conversation from state and udpate its last message object.
@@ -582,7 +611,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
582
611
  */
583
612
  const messageEventHandler = (...args: any[]) => {
584
613
  let message = args[0];
585
- !disableReadReceipt && markMessageAsDelivered(message);
614
+ !disableReceipt && markMessageAsDelivered(message);
586
615
  updateLastMessage(message);
587
616
  }
588
617
 
@@ -591,6 +620,14 @@ export const CometChatConversations = (props: ConversationInterface) => {
591
620
  * @param {obj} message
592
621
  */
593
622
  const groupHandler = (message: any, otherDetails: {action?: string, actionOn?: CometChat.User, actionBy?: CometChat.User, group?: CometChat.Group} = {}) => {
623
+ if (
624
+ conversationsRequestBuilder &&
625
+ conversationsRequestBuilder.build().getConversationType() &&
626
+ conversationsRequestBuilder.build().getConversationType() !=
627
+ CometChatUiKitConstants.ReceiverTypeConstants.group
628
+ ) {
629
+ return;
630
+ }
594
631
  let conversation : CometChat.Conversation = (conversationListRef.current?.getListItem(message['conversationId']) as unknown as CometChat.Conversation);
595
632
  let {action, actionOn, actionBy, group} = otherDetails;
596
633
  if (conversation) {
@@ -602,7 +639,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
602
639
  return;
603
640
  }
604
641
  conversation.setLastMessage(message);
605
- conversationListRef.current?.updateList(conversation);
642
+ conversationListRef.current?.updateAndMoveToFirst(conversation);
606
643
  }
607
644
  } else {
608
645
  CometChat.CometChatHelper.getConversationFromMessage(message)
@@ -763,7 +800,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
763
800
  </View>
764
801
  }
765
802
 
766
- if (lastMessage && !disableReadReceipt && lastMessage['sender']['uid'] == loggedInUser.current?.uid && !lastMessage.getDeletedAt()) {
803
+ if (lastMessage && lastMessage['sender']['uid'] == loggedInUser.current?.uid && !lastMessage.getDeletedAt()) {
767
804
  let status: MessageReceipt = "ERROR";
768
805
  if (lastMessage?.hasOwnProperty('readAt'))
769
806
  status = "READ";
@@ -771,7 +808,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
771
808
  status = "DELIVERED";
772
809
  else if (lastMessage?.hasOwnProperty("sentAt"))
773
810
  status = "SENT";
774
- readReceipt = disableReceipt ? null : <CometChatReceipt
811
+ readReceipt = (disableReceipt || hideReceipt) ? null : <CometChatReceipt
775
812
  receipt={status}
776
813
  deliveredIcon={props.deliveredIcon}
777
814
  errorIcon={props.errorIcon}
@@ -1043,13 +1080,13 @@ export const CometChatConversations = (props: ConversationInterface) => {
1043
1080
  }
1044
1081
  },
1045
1082
  ccMessageRead: ({ message }: any) => {
1046
- checkAndUpdateLastMessage(message)
1083
+ checkAndUpdateLastMessage(message, true)
1047
1084
  },
1048
1085
  ccMessageDeleted: ({ message }: any) => {
1049
- checkAndUpdateLastMessage(message)
1086
+ checkAndUpdateLastMessage(message, true)
1050
1087
  },
1051
1088
  ccMessageEdited: ({ message }: any) => {
1052
- checkAndUpdateLastMessage(message)
1089
+ checkAndUpdateLastMessage(message, true)
1053
1090
  },
1054
1091
  onTextMessageReceived: (textMessage: any) => {
1055
1092
  if(!shouldUpdateLastMessageAndUnreadCount(textMessage)) {
@@ -1073,16 +1110,16 @@ export const CometChatConversations = (props: ConversationInterface) => {
1073
1110
  !disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
1074
1111
  },
1075
1112
  onMessageDeleted: (deletedMessage: any) => {
1076
- checkAndUpdateLastMessage(deletedMessage)
1113
+ checkAndUpdateLastMessage(deletedMessage, false)
1077
1114
  },
1078
1115
  onMessageEdited: (editedMessage: any) => {
1079
- checkAndUpdateLastMessage(editedMessage)
1116
+ checkAndUpdateLastMessage(editedMessage, false)
1080
1117
  },
1081
1118
  onMessagesRead: (messageReceipt: any) => {
1082
- messageEventHandler(messageReceipt);
1119
+ updateMessageReceipt(messageReceipt);
1083
1120
  },
1084
1121
  onMessagesDelivered: (messageReceipt: any) => {
1085
- messageEventHandler(messageReceipt);
1122
+ updateMessageReceipt(messageReceipt);
1086
1123
  },
1087
1124
  onMessagesDeliveredToAll: (messageReceipt: CometChat.MessageReceipt) => {
1088
1125
  updateMessageReceipt(messageReceipt);
@@ -1184,6 +1221,9 @@ export const CometChatConversations = (props: ConversationInterface) => {
1184
1221
  userListenerId,
1185
1222
  {
1186
1223
  ccUserBlocked: ({ user }: any) => {
1224
+ if(conversationsRequestBuilder && conversationsRequestBuilder.build().isIncludeBlockedUsers()) {
1225
+ return;
1226
+ }
1187
1227
  conversationListRef?.current?.removeItemFromList(user['conversationId']);
1188
1228
  removeItemFromSelectionList(user['conversationId']);
1189
1229
  }
@@ -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) => {
@@ -608,7 +608,7 @@ export const CometChatMessageComposer = React.forwardRef(
608
608
  const messageInputRef = React.useRef<any>(null);
609
609
  const chatRef = React.useRef<any>(chatWith);
610
610
  const inputValueRef = React.useRef<any>(null);
611
- const plainTextInput = React.useRef<string>("");
611
+ const plainTextInput = React.useRef<string>(text ?? "");
612
612
  let mentionMap = React.useRef<Map<string, SuggestionItem>>(new Map());
613
613
  let trackingCharacters = React.useRef<string[]>([])
614
614
  let allFormatters = React.useRef<Map<string, CometChatTextFormatter | CometChatMentionsFormatter>>(new Map());
@@ -1131,7 +1131,7 @@ export const CometChatMessageComposer = React.forwardRef(
1131
1131
  };
1132
1132
 
1133
1133
  const shouldShowAIOptions = () => {
1134
- return AIOptionItems.length > 0;
1134
+ return !parentMessageId && AIOptionItems.length > 0;
1135
1135
  }
1136
1136
 
1137
1137
  const AuxiliaryButtonViewElem = () => {
@@ -1316,7 +1316,11 @@ export const CometChatMessageComposer = React.forwardRef(
1316
1316
  if (typeof item.onPress == 'function')
1317
1317
  return {
1318
1318
  ...item,
1319
- onPress: () => item.onPress?.(user, group),
1319
+ onPress: () => {
1320
+ setShowActionSheet(false);
1321
+ item.onPress?.(user, group)
1322
+ }
1323
+ ,
1320
1324
  };
1321
1325
  return {
1322
1326
  ...item,
@@ -1390,6 +1394,7 @@ export const CometChatMessageComposer = React.forwardRef(
1390
1394
  bottomSheetRef.current?.togglePanel();
1391
1395
 
1392
1396
  inputValueRef.current = text?.text;
1397
+ plainTextInput.current = text?.text;
1393
1398
  setInputMessage(text?.text)
1394
1399
 
1395
1400
  },
@@ -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 { BaseStyle, BaseStyleInterface, CometChatContext, CometChatMentionsFormatter, CometChatTextFormatter, CometChatUIKit, CometChatUrlsFormatter, ImageType, SuggestionItem } from "../shared";
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);
@@ -324,8 +331,19 @@ export const CometChatMessageList = memo(forwardRef<
324
331
  const bottomSheetRef = useRef<any>(null)
325
332
  const conversationId = useRef(null)
326
333
  let lastID = useRef(0);
334
+ let isKeyBoardVisible = useRef(false);
327
335
 
328
336
  const scrollHandler = (event: any) => {
337
+ /********************************************************************************
338
+ * layoutMeasurement.height: The height of the visible area within the ScrollView.
339
+ * contentOffset.y: The current vertical scroll position (distance from the top of the content).
340
+ The y value in contentOffset indicates how far the top edge of the visible area is from the top of the scrollable content.
341
+ The x value (if applicable) indicates how far the left edge of the visible area is from the left of the scrollable content.
342
+ For example:
343
+ If contentOffset.y is 0, the top of the visible area is aligned with the top of the content.
344
+ If contentOffset.y is 50, the top of the visible area is 50 units (pixels) below the top of the content.
345
+ * contentSize.height: The total height of the scrollable content.
346
+ *********************************************************************************/
329
347
  const { layoutMeasurement, contentOffset, contentSize } = event.nativeEvent;
330
348
  const screenHeight = Dimensions.get('window').height;
331
349
 
@@ -334,6 +352,7 @@ export const CometChatMessageList = memo(forwardRef<
334
352
  const scrollEndPosition = contentSize.height - screenHeight;
335
353
 
336
354
  currentScrollPosition.current.y = contentOffset.y;
355
+ currentScrollPosition.current.contentHeight = contentSize.height;
337
356
 
338
357
  if (currentScrollPosition.current.layoutHeight != layoutMeasurement.height) {
339
358
  currentScrollPosition.current.layoutHeight = layoutMeasurement.height;
@@ -359,7 +378,7 @@ export const CometChatMessageList = memo(forwardRef<
359
378
  }
360
379
 
361
380
  const newMsgIndicatorPressed = () => {
362
- scrollToBottom();
381
+ messageListRef.current?.scrollToEnd({ animated: true });
363
382
  markUnreadMessageAsRead();
364
383
  };
365
384
 
@@ -465,9 +484,7 @@ export const CometChatMessageList = memo(forwardRef<
465
484
  .fetchNext()
466
485
  .then((newMessages: any[]) => {
467
486
  let cleanUpdatedList = [...updatedList];
468
-
469
- let finalOutput = CommonUtils.mergeArrays(cleanUpdatedList, newMessages, "muid");
470
-
487
+ let finalOutput = CommonUtils.mergeArrays(cleanUpdatedList, newMessages, "id");
471
488
  let tmpList = [...finalOutput];
472
489
  tmpList = tmpList.map((item: CometChat.BaseMessage, index) => {
473
490
  if (item.getCategory() === MessageCategoryConstants.interactive) {
@@ -478,14 +495,19 @@ export const CometChatMessageList = memo(forwardRef<
478
495
  })
479
496
  if (inProgressMessages.current.length) {
480
497
  const filteredInProgressMessages = inProgressMessages.current.filter(secondItem =>
481
- !tmpList.some(firstItem => firstItem.muid === secondItem.muid)
498
+ tmpList.some(firstItem => firstItem.muid === secondItem.muid)
482
499
  );
483
500
  const combinedArray = CommonUtils.mergeArrays(tmpList, filteredInProgressMessages, "muid");
484
501
  tmpList = combinedArray
485
502
  }
486
503
  messagesContentListRef.current = tmpList;
487
504
  setMessagesList(tmpList);
488
- bottomHandler(tmpList[tmpList.length - 1], true);
505
+ for(let i = newMessages.length - 1; i >= 0; i--) {
506
+ if(newMessages[i].getSender().getUid() !== loggedInUser.current.getUid()) {
507
+ bottomHandler(newMessages[i], true);
508
+ break;
509
+ }
510
+ }
489
511
  if (newMessages.length === 30) {
490
512
  getNewMessages(tmpList);
491
513
  }
@@ -649,7 +671,8 @@ export const CometChatMessageList = memo(forwardRef<
649
671
  group?.getGuid() == message.getReceiverId() || false);
650
672
  }
651
673
  function checkSameConversation(message: CometChat.BaseMessage): boolean {
652
- return message.getConversationId() == conversationId.current || message.getSender()?.['uid'] === user?.getUid();
674
+ return message.getConversationId() == conversationId.current ||
675
+ (message.getSender()?.['uid'] === user?.getUid() && message.getReceiverType() == CometChatUiKitConstants.ReceiverTypeConstants.user);
653
676
  }
654
677
 
655
678
  function isNearBottom() {
@@ -671,12 +694,14 @@ export const CometChatMessageList = memo(forwardRef<
671
694
  newMessage = InteractiveMessageUtils.convertInteractiveMessage(baseMessage);
672
695
  }
673
696
  if (checkSameConversation(baseMessage) || checkMessageInSameConversation(baseMessage) || messageToSameConversation(baseMessage)) {
697
+ if(!disableReceipt) {
698
+ CometChat.markAsDelivered(newMessage);
699
+ }
674
700
  //need to add
675
701
  if (newMessage.getParentMessageId()) {
676
702
  if (parentMessageId && newMessage.getParentMessageId() == parseInt(parentMessageId)) {
677
703
  // add to list
678
704
  messagesContentListRef.current = [...messagesContentListRef.current, newMessage];
679
- inProgressMessages.current = [...inProgressMessages.current, newMessage]
680
705
  setMessagesList(prev => [...prev, newMessage]);
681
706
  } else {
682
707
  //increase count
@@ -690,11 +715,10 @@ export const CometChatMessageList = memo(forwardRef<
690
715
  tmpList[index] = oldMsg;
691
716
  messagesContentListRef.current = tmpList;
692
717
  setMessagesList(tmpList);
693
- inProgressMessages.current = [...inProgressMessages.current, newMessage]
718
+ return;
694
719
  }
695
720
  } else if (parentMessageId == undefined) {
696
721
  messagesContentListRef.current = [...messagesContentListRef.current, newMessage];
697
- inProgressMessages.current = [...inProgressMessages.current, newMessage]
698
722
  setMessagesList(prev => [...prev, newMessage]);
699
723
  }
700
724
  bottomHandler(newMessage, isReceived);
@@ -703,32 +727,45 @@ export const CometChatMessageList = memo(forwardRef<
703
727
  playNotificationSound(newMessage);
704
728
  }
705
729
 
706
- const bottomHandler = (newMessage: CometChat.BaseMessage | any, isReceived?: boolean) => {
730
+ const isAtBottom = () => {
731
+ if(
732
+ [null, undefined].includes(currentScrollPosition.current.y)
733
+ || !currentScrollPosition.current.layoutHeight
734
+ || !currentScrollPosition.current.contentHeight
735
+ ) {
736
+ return true;
737
+ }
738
+ else if (currentScrollPosition.current.layoutHeight + currentScrollPosition.current.y! >= currentScrollPosition.current.contentHeight) {
739
+ return true;
740
+ }
707
741
 
708
- // if scroll is not at bottom
709
- if (!scrollToBottomOnNewMessages && currentScrollPosition.current.y && (Math.round(currentScrollPosition.current.y) <= currentScrollPosition.current.scrollViewHeight)) {
710
- if ((parentMessageId && newMessage.getParentMessageId() == parseInt(parentMessageId)) || (!parentMessageId && !newMessage.getParentMessageId() && (newMessage.getSender()?.getUid() || newMessage?.['sender']?.['uid']) == loggedInUser.current?.['uid'])) {
711
- scrollToBottom();
712
- return;
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 {
742
+ return false;
743
+ }
744
+
745
+ const bottomHandler = (newMessage: CometChat.BaseMessage | any, isReceived?: boolean) => {
746
+ if ((newMessage.getSender()?.getUid() || newMessage?.['sender']?.['uid']) == loggedInUser.current?.['uid']) {
728
747
  scrollToBottom();
729
- if (isReceived) {
748
+ return;
749
+ }
750
+ if(!isReceived) {
751
+ return;
752
+ }
753
+ if (
754
+ (!parentMessageId && newMessage.getParentMessageId())
755
+ || (parentMessageId && !newMessage.getParentMessageId())
756
+ || (parentMessageId && newMessage.getParentMessageId() && parentMessageId != newMessage.getParentMessageId())
757
+ ) {
758
+ return;
759
+ }
760
+ if (isAtBottom() || isNearBottom()) {
761
+ scrollToBottom();
762
+ markMessageAsRead(newMessage)
763
+ } else {
764
+ if(scrollToBottomOnNewMessages) {
765
+ scrollToBottom();
730
766
  markMessageAsRead(newMessage);
731
- CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageRead, { message: newMessage });
767
+ } else {
768
+ setUnreadCount(unreadCount + 1);
732
769
  }
733
770
  }
734
771
  }
@@ -752,7 +789,7 @@ export const CometChatMessageList = memo(forwardRef<
752
789
  let condition: (value: any, index: number, obj: any[]) => unknown;
753
790
  if (withMuid) {
754
791
  condition = (msg) => msg['muid'] == editedMessage['muid']
755
- inProgressMessages.current = inProgressMessages.current.filter((item: anyObject) => item.muid !== editedMessage['muid'])
792
+ //inProgressMessages.current = inProgressMessages.current.filter((item: anyObject) => item.muid !== editedMessage['muid'])
756
793
  }
757
794
  else
758
795
  condition = (msg) => msg.getId() == editedMessage.getId()
@@ -913,6 +950,7 @@ export const CometChatMessageList = memo(forwardRef<
913
950
  newMessage(message);
914
951
  },
915
952
  onGroupMemberUnbanned: (message: any) => {
953
+ newMessage(message);
916
954
  },
917
955
  onMemberAddedToGroup: (message: any) => {
918
956
  newMessage(message);
@@ -928,6 +966,7 @@ export const CometChatMessageList = memo(forwardRef<
928
966
  {
929
967
  ccMessageSent: ({ message, status }: any) => {
930
968
  if (status == MessageStatusConstants.inprogress) {
969
+ inProgressMessages.current = [...inProgressMessages.current, message]
931
970
  newMessage(message, false);
932
971
  }
933
972
 
@@ -1022,6 +1061,7 @@ export const CometChatMessageList = memo(forwardRef<
1022
1061
  message['message'] = `${loggedInUser.current?.getName()} added ${user.name}`;
1023
1062
  message['muid'] = String(getUnixTimestamp());
1024
1063
  message['sentAt'] = getUnixTimestamp();
1064
+ message['actionOn'] = user;
1025
1065
  newMessage(message, false);
1026
1066
  })
1027
1067
  },
@@ -1093,7 +1133,9 @@ export const CometChatMessageList = memo(forwardRef<
1093
1133
  connectionListenerId,
1094
1134
  new CometChat.ConnectionListener({
1095
1135
  onConnected: () => {
1096
- getUpdatedPreviousMessages();
1136
+ if(lastID.current) {
1137
+ getUpdatedPreviousMessages();
1138
+ }
1097
1139
  },
1098
1140
  inConnecting: () => {
1099
1141
  },
@@ -1155,8 +1197,20 @@ export const CometChatMessageList = memo(forwardRef<
1155
1197
  Keyboard_Height = keyboardHeight;
1156
1198
  scrollPos = (currentScrollPosition.current.y + Keyboard_Height) - ((commonVars.safeAreaInsets.top as number) / 2);
1157
1199
  messageListRef.current.scrollTo({ y: scrollPos, animated: false })
1200
+ isKeyBoardVisible.current = true;
1158
1201
  } else {
1159
- messageListRef.current.scrollTo({ y: scrollPos - Keyboard_Height + ((commonVars.safeAreaInsets.top as number) / 2), animated: false })
1202
+ isKeyBoardVisible.current = false;
1203
+ /**
1204
+ * Do not have to scroll back if the list is at the bottom because we are already adjusting
1205
+ for the change in contentSize when we are at bottom which means if the list is at the bottom
1206
+ and we open the keyboard, the following line
1207
+ (`messageListRef.current.scrollTo({ y: scrollPos, animated: false })`) in the above "if"
1208
+ condition already puts the list at the bottom again.
1209
+ Hence, running the below for isAtBottom() will scroll to a wrong position.
1210
+ */
1211
+ if(!isAtBottom()) {
1212
+ messageListRef.current.scrollTo({ y: scrollPos - Keyboard_Height + ((commonVars.safeAreaInsets.top as number) / 2), animated: false });
1213
+ }
1160
1214
  }
1161
1215
  }
1162
1216
  }
@@ -1300,7 +1354,7 @@ export const CometChatMessageList = memo(forwardRef<
1300
1354
  dateAlignment="center"
1301
1355
  />
1302
1356
  {
1303
- (!disableReceipt && alignment !== "leftAligned") && isSender ?
1357
+ (!(disableReceipt || hideReceipt) && alignment !== "leftAligned") && isSender ?
1304
1358
  <View style={{ marginLeft: 2, alignItems: "center", justifyContent: "center" }}>
1305
1359
  <CometChatReceipt
1306
1360
  receipt={messageState}
@@ -1475,8 +1529,8 @@ export const CometChatMessageList = memo(forwardRef<
1475
1529
  });
1476
1530
  };
1477
1531
 
1478
- const getStyle = useCallback((item: CometChat.BaseMessage | any): BaseStyleInterface => {
1479
- let _style = new BaseStyle({
1532
+ const getStyle = useCallback((item: CometChat.BaseMessage | any): MessageBubbleStyleInterface => {
1533
+ let _style = new MessageBubbleStyle({
1480
1534
  ..._messageBubbleStyle,
1481
1535
  backgroundColor: theme?.palette.getAccent50()
1482
1536
  });
@@ -1485,6 +1539,8 @@ export const CometChatMessageList = memo(forwardRef<
1485
1539
  if (item.getType() === MessageTypeConstants.form || item.getType() === MessageTypeConstants.card) {
1486
1540
  _style.width = "100%"
1487
1541
  }
1542
+ } else {
1543
+ _style.alignSelf = getAlignment(item) === "left" ? "flex-start" : "flex-end";
1488
1544
  }
1489
1545
 
1490
1546
  if ((item.getSender()?.getUid() || item?.['sender']?.['uid']) == loggedInUser.current?.['uid'])
@@ -1859,6 +1915,51 @@ export const CometChatMessageList = memo(forwardRef<
1859
1915
  currentScrollPosition.current.scrollViewHeight = contentHeight;
1860
1916
  }
1861
1917
  }
1918
+
1919
+ /**
1920
+ * If Keyboard is open, recalculate the scroll position when content size changes
1921
+ */
1922
+ if(isKeyBoardVisible.current == true) {
1923
+ /**
1924
+ * WITHOUT the isAtBottom() check, the following will happen:
1925
+ * 1. nearToBottom() is true (which is up to 2 messages from bottom)
1926
+ * 2. A new message is received (or any event that changes the content size)
1927
+ but the UI issue is mainly with a new message
1928
+ * 3. Since the content size has increased, we are not nearToBotom() anymore
1929
+ and so the unread banner will be displayed to click and scroll to bottom
1930
+ * 4. If there's not isAtBottomCheck() below, `onKeyboardVisibilityChange()` runs
1931
+ to adjust for the change in content size and this triggers a scroll
1932
+ messageListRef.current.scrollTo({ y: scrollPos, animated: false })
1933
+ * 5. And the nearToBottom() is true again since we have accounted for the change
1934
+ in contentSize and the banner disappears and the list scrolls to the bottom
1935
+ *
1936
+ * The above breaks the UI!
1937
+ */
1938
+
1939
+ /**
1940
+ * Why not do this for isAtBottom() || !isNearBottom()?
1941
+ * - (isAtBottom() || !isNearBottom()) means notAtBottom() and notNearBottom()
1942
+ This means there's content under the keyboard but that's not the end.
1943
+ Everytime a new message is received contentSize will change and that will
1944
+ trigger a position recalculation and a scroll and the list will keep scrolling
1945
+ till we reach bottom (that is if we keep receiving messages).
1946
+ *
1947
+ */
1948
+ if (isAtBottom()) {
1949
+ /**
1950
+ * Why is this required?
1951
+ * 1. Let's say the scroll is nearToBottom() and the keyboard is open
1952
+ * 2. User receives a new message and the content size changes.
1953
+ * 3. The Message List scrolls to the bottom since the scroll was nearToBottom()
1954
+ * 4. User closes the keyboard and the list scrolls back to the previous message
1955
+ * that was nearToBottom()
1956
+ * 5. The position to scroll back to needs to be recalculated since the contentSize
1957
+ has changed. Calling `onKeyboardVisibiltyChange()` does this.
1958
+ *
1959
+ */
1960
+ onKeyboardVisibiltyChange(true, Keyboard_Height);
1961
+ }
1962
+ }
1862
1963
  }, [])
1863
1964
 
1864
1965
  const {
@@ -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
- disableReceipt!: boolean;
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
@@ -43,7 +43,7 @@ export const MessageTranslationBubble = (props: MessageTranslationBubble) => {
43
43
 
44
44
  useEffect(() => {
45
45
  let _formattedText: string = text || '';
46
- let _formattedTranslatedText: string = text || '';
46
+ let _formattedTranslatedText: string = translatedText || '';
47
47
  if (textFormatters && textFormatters.length) {
48
48
  if (textFormatters) {
49
49
  for (let i = 0; i < textFormatters.length; i++) {
@@ -61,6 +61,10 @@ function isDeletedMessage(message: CometChat.BaseMessage): boolean {
61
61
  return message.getDeletedBy() != null;
62
62
  }
63
63
 
64
+ function isMessageSent(message: CometChat.BaseMessage): boolean {
65
+ return message.getSentAt() ? true : false;
66
+ }
67
+
64
68
  export class MessageDataSource implements DataSource {
65
69
 
66
70
  getEditOption(): CometChatMessageOption {
@@ -139,7 +143,7 @@ export class MessageDataSource implements DataSource {
139
143
  let messageOptionList: CometChatMessageOption[] = [];
140
144
 
141
145
 
142
- if (isDeletedMessage(messageObject))
146
+ if (isDeletedMessage(messageObject) || !isMessageSent(messageObject))
143
147
  return messageOptionList;
144
148
 
145
149
 
@@ -174,52 +178,52 @@ export class MessageDataSource implements DataSource {
174
178
 
175
179
  getFormMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group?: CometChat.Group): CometChatMessageOption[] {
176
180
  let optionsList: Array<CometChatMessageOption> = [];
177
- if (!isDeletedMessage(messageObject))
181
+ if (!isDeletedMessage(messageObject) && isMessageSent(messageObject))
178
182
  optionsList.push(...ChatConfigurator.dataSource.getCommonOptions(loggedInUser, messageObject, group));
179
183
  return optionsList;
180
184
  }
181
185
 
182
186
  getSchedulerMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group?: CometChat.Group): CometChatMessageOption[] {
183
187
  let optionsList: Array<CometChatMessageOption> = [];
184
- if (!isDeletedMessage(messageObject))
188
+ if (!isDeletedMessage(messageObject) && isMessageSent(messageObject))
185
189
  optionsList.push(...ChatConfigurator.dataSource.getCommonOptions(loggedInUser, messageObject, group));
186
190
  return optionsList;
187
191
  }
188
192
 
189
193
  getCardMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group?: CometChat.Group): CometChatMessageOption[] {
190
194
  let optionsList: Array<CometChatMessageOption> = [];
191
- if (!isDeletedMessage(messageObject))
195
+ if (!isDeletedMessage(messageObject) && isMessageSent(messageObject))
192
196
  optionsList.push(...ChatConfigurator.dataSource.getCommonOptions(loggedInUser, messageObject, group));
193
197
  return optionsList;
194
198
  }
195
199
 
196
200
  getAudioMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group?: CometChat.Group): CometChatMessageOption[] {
197
201
  let optionsList: Array<CometChatMessageOption> = [];
198
- if (!isDeletedMessage(messageObject))
202
+ if (!isDeletedMessage(messageObject) && isMessageSent(messageObject))
199
203
  optionsList.push(...ChatConfigurator.dataSource.getCommonOptions(loggedInUser, messageObject, group));
200
204
  return optionsList;
201
205
  }
202
206
  getVideoMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group?: CometChat.Group): CometChatMessageOption[] {
203
207
  let optionsList: Array<CometChatMessageOption> = [];
204
- if (!isDeletedMessage(messageObject))
208
+ if (!isDeletedMessage(messageObject) && isMessageSent(messageObject))
205
209
  optionsList.push(...ChatConfigurator.dataSource.getCommonOptions(loggedInUser, messageObject, group));
206
210
  return optionsList
207
211
  }
208
212
  getImageMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group?: CometChat.Group): CometChatMessageOption[] {
209
213
  let optionsList: Array<CometChatMessageOption> = [];
210
- if (!isDeletedMessage(messageObject))
214
+ if (!isDeletedMessage(messageObject) && isMessageSent(messageObject))
211
215
  optionsList.push(...ChatConfigurator.dataSource.getCommonOptions(loggedInUser, messageObject, group));
212
216
  return optionsList;
213
217
  }
214
218
  getFileMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group?: CometChat.Group): CometChatMessageOption[] {
215
219
  let optionsList: Array<CometChatMessageOption> = [];
216
- if (!isDeletedMessage(messageObject))
220
+ if (!isDeletedMessage(messageObject) && isMessageSent(messageObject))
217
221
  optionsList.push(...ChatConfigurator.dataSource.getCommonOptions(loggedInUser, messageObject, group));
218
222
  return optionsList;
219
223
  }
220
224
  getMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group?: CometChat.Group): CometChatMessageOption[] {
221
225
  let optionsList: Array<CometChatMessageOption> = [];
222
- if (isDeletedMessage(messageObject))
226
+ if (isDeletedMessage(messageObject) || !isMessageSent(messageObject))
223
227
  return optionsList;
224
228
  if (messageObject.getCategory() == MessageCategoryConstants.message) {
225
229
  let type: string = messageObject.getType();
@@ -307,7 +311,7 @@ export class MessageDataSource implements DataSource {
307
311
  getCommonOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group?: CometChat.Group): CometChatMessageOption[] {
308
312
  let messageOptionList: CometChatMessageOption[] = [];
309
313
 
310
- if (isDeletedMessage(messageObject)) return messageOptionList;
314
+ if (isDeletedMessage(messageObject) || !isMessageSent(messageObject)) return messageOptionList;
311
315
 
312
316
  if (this.validateOption(loggedInUser, messageObject, MessageOptionConstants.replyInThread, group)) {
313
317
  messageOptionList.push(this.getReplyInThreadOption());
@@ -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() + Math.random(), 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() + Math.random(), obj);
83
+ return;
84
+ }
77
85
  map.set(obj[key], obj);
78
86
  }
79
87
  });
@@ -387,7 +387,7 @@ const _allowedGroupDetailsOptions: { [key: string]: { [key: string]: boolean } }
387
387
  [GroupOptionConstants.bannedMembers]: true,
388
388
  [GroupOptionConstants.viewMembers]: true,
389
389
  [GroupOptionConstants.addMembers]: true,
390
- [GroupOptionConstants.delete]: false,
390
+ [GroupOptionConstants.delete]: true,
391
391
  },
392
392
  [GroupMemberScope.owner]: {
393
393
  [GroupOptionConstants.leave]: true,
@@ -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: BaseStyle = {};
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
 
@@ -109,7 +109,7 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
109
109
  let rowOptions = options();
110
110
  if (rowOptions) setSwipeRowOptions(rowOptions);
111
111
  }
112
- }, []);
112
+ }, [options]);
113
113
  /**
114
114
  * Component to be display the user status
115
115
  */
@@ -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?: BaseStyleInterface,
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
- ...(alignment === "left" && { alignSelf: "flex-start" }),
123
- ...(alignment === "right" && { alignSelf: "flex-end" })
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
  }