@cometchat/chat-uikit-react-native 4.3.9 → 4.3.11

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.
Files changed (24) hide show
  1. package/package.json +1 -1
  2. package/src/CometChatBannedMembers/CometChatBannedMembers.tsx +3 -0
  3. package/src/CometChatConversations/CometChatConversations.tsx +190 -32
  4. package/src/CometChatConversations/ConversationsConfiguration.ts +16 -6
  5. package/src/CometChatDetails/CometChatDetails.tsx +13 -9
  6. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +18 -2
  7. package/src/CometChatGroupMembers/GroupMemberConfiguration.ts +26 -2
  8. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +6 -1
  9. package/src/CometChatMessageList/CometChatMessageList.tsx +23 -9
  10. package/src/CometChatMessageList/MessageListConfiguration.ts +14 -2
  11. package/src/calls/CallEvents.ts +1 -1
  12. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +3 -1
  13. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +7 -7
  14. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +1 -1
  15. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +2 -2
  16. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -0
  17. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +1 -1
  18. package/src/shared/CometChatUiKit/CometChatUIKit.ts +32 -11
  19. package/src/shared/CometChatUiKit/UIKitSettings.ts +8 -5
  20. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +3 -0
  21. package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -4
  22. package/src/shared/utils/MessageUtils.tsx +14 -5
  23. package/src/shared/views/CometChatList/CometChatList.tsx +2 -2
  24. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "4.3.9",
3
+ "version": "4.3.11",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
@@ -27,6 +27,9 @@ export interface CometChatBannedMembersInterface
27
27
  bannedMemberStyle?: CometChatListStylesInterface;
28
28
  unbanIcon?: ImageType;
29
29
  title?: string;
30
+ onSelection?: (list: CometChat.User[]) => void;
31
+ onItemPress?: (user: CometChat.User) => void;
32
+ onItemLongPress?: (user: CometChat.User) => void;
30
33
  /**
31
34
  *
32
35
  *
@@ -14,7 +14,8 @@ import {
14
14
  MentionTextStyle,
15
15
  CometChatListActionsInterface,
16
16
  localize,
17
- CometChatUIKit
17
+ CometChatUIKit,
18
+ CometChatUiKitConstants
18
19
  } from "../shared";
19
20
  import { Style } from "./style";
20
21
  import {
@@ -259,10 +260,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
259
260
  AppBarOption,
260
261
  options,
261
262
  hideSeparator = true,
262
- hideSubmitIcon = true,
263
+ hideSubmitIcon = false,
263
264
  backButtonIcon,
264
265
  showBackButton = false,
265
- selectionMode = "multiple",
266
+ selectionMode = "single",
266
267
  onSelection,
267
268
  title = localize("CHATS"),
268
269
  emptyStateText,
@@ -289,7 +290,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
289
290
  const conversationListRef = React.useRef<CometChatListActionsInterface>(null);
290
291
  const loggedInUser = React.useRef(null);
291
292
  const [confirmDelete, setConfirmDelete] = React.useState(undefined);
292
- const [selecting, setSelecting] = React.useState(false);
293
+ const [selecting, setSelecting] = React.useState(selectionMode === 'none' ? false : true);
293
294
  const [selectedConversation, setSelectedConversations] = React.useState([]);
294
295
  const onMemberAddedToGroupDebounceTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null);
295
296
 
@@ -436,13 +437,58 @@ export const CometChatConversations = (props: ConversationInterface) => {
436
437
 
437
438
  }
438
439
 
440
+
441
+ /**
442
+ * Check if last message/unread count should be updated
443
+ *
444
+ * @param newMessage message object
445
+ */
446
+ const shouldUpdateLastMessageAndUnreadCount = (message : CometChat.BaseMessage) => {
447
+
448
+ /****Start: Should Threaded Messages Update Conversation? */
449
+ if(message.getParentMessageId() && !CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnMessageReplies()) {
450
+ return false;
451
+ }
452
+ /****END: Should Threaded Messages Update Conversation? */
453
+
454
+ /****Start: Should Custom Message Update Conversation? */
455
+ if(message.getCategory() == CometChatUiKitConstants.MessageCategoryConstants.custom) {
456
+ let customMessage = message as CometChat.CustomMessage;
457
+ if (!customMessage.willUpdateConversation() &&
458
+ !(customMessage.getMetadata() && (customMessage.getMetadata() as any)["incrementUnreadCount"]) &&
459
+ !CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCustomMessages()) {
460
+ return false;
461
+ }
462
+ }
463
+ /****End: Should Custom Message Update Conversation? */
464
+
465
+ /****Start: Should Group Actions sent update conversation? */
466
+ if(message.getCategory() == CometChatUiKitConstants.MessageCategoryConstants.action
467
+ && message.getReceiverType() == CometChatUiKitConstants.ReceiverTypeConstants.group
468
+ ) {
469
+ return CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnGroupActions();
470
+ }
471
+ /****End: Should Group Actions sent update conversation? */
472
+
473
+ /****Start: Should Call Actions sent Update Conversation? */
474
+ if(message.getCategory() == CometChatUiKitConstants.MessageCategoryConstants.call
475
+ && !CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()
476
+ ) {
477
+ return false;
478
+ }
479
+ /****End: Should Call Actions sent Update Conversation */
480
+
481
+ return true;
482
+ }
483
+
439
484
  /**
440
485
  * Find conversation from state and udpate its last message object.
441
486
  * Also remove from the current location and put it to 1st location.
442
487
  *
443
488
  * @param newMessage message object
444
489
  */
445
- const updateLastMessage = (newMessage) => {
490
+ const updateLastMessage = (newMessage: CometChat.BaseMessage) => {
491
+
446
492
  CometChat.CometChatHelper.getConversationFromMessage(newMessage)
447
493
  .then(conversation => {
448
494
  if (newMessage.getCategory() === MessageCategoryConstants.interactive) {
@@ -510,26 +556,31 @@ export const CometChatConversations = (props: ConversationInterface) => {
510
556
  * callback handler for group Add / Kicked / Banned / Scope Change
511
557
  * @param {obj} message
512
558
  */
513
- const groupHandler = (message, action?: string) => {
514
- let conversation = conversationListRef.current.getListItem(message['conversationId'])
515
-
516
- if (conversation) {
517
- conversation.setLastMessage(message);
518
- if (action === 'kicked' || action === 'banned')
559
+ const groupHandler = (message, otherDetails: {action?: string, actionOn?: CometChat.User, actionBy?: CometChat.User, group?: CometChat.Group} = {}) => {
560
+ let conversation : CometChat.Conversation = (conversationListRef.current.getListItem(message['conversationId']) as unknown as CometChat.Conversation);
561
+ let {action, actionOn, actionBy, group} = otherDetails;
562
+ if (conversation) {
563
+ if ((["kicked", "banned", "left"].includes(action)) && (actionOn.getUid() == loggedInUser.current.getUid())){
519
564
  conversationListRef.current.removeItemFromList(message.conversationId);
520
- else
565
+ return;
566
+ } else {
567
+ if(!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnGroupActions()) {
568
+ return;
569
+ }
570
+ conversation.setLastMessage(message);
521
571
  conversationListRef.current.updateList(conversation);
522
- } else {
523
- CometChat.CometChatHelper.getConversationFromMessage(message)
524
- .then(newConversation => {
525
- const conversation = conversationListRef.current.getListItem(message['conversationId']);
526
- if (conversation) {
527
- groupHandler(message);
528
- } else {
529
- conversationListRef.current.addItemToList(newConversation, 0);
530
- }
531
- });
532
- }
572
+ }
573
+ } else {
574
+ CometChat.CometChatHelper.getConversationFromMessage(message)
575
+ .then(newConversation => {
576
+ const conversation : CometChat.Conversation = (conversationListRef.current.getListItem(message['conversationId']) as unknown as CometChat.Conversation);
577
+ if (conversation) {
578
+ groupHandler(message);
579
+ } else {
580
+ conversationListRef.current.addItemToList(newConversation, 0);
581
+ }
582
+ });
583
+ }
533
584
  }
534
585
 
535
586
  const conversationClicked = (conversation) => {
@@ -768,6 +819,9 @@ export const CometChatConversations = (props: ConversationInterface) => {
768
819
  }
769
820
 
770
821
  const updateConversationLastMessage = (message) => {
822
+ if(!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnGroupActions()) {
823
+ return;
824
+ }
771
825
  try {
772
826
  let conversation: CometChat.Conversation = conversationListRef.current?.getListItem(message.conversationId)
773
827
  conversation.lastMessage = message
@@ -777,6 +831,16 @@ export const CometChatConversations = (props: ConversationInterface) => {
777
831
  }
778
832
  }
779
833
 
834
+ const updateUnreadMessageCount = (conversation: CometChat.Conversation) => {
835
+ const oldConversation: CometChat.Conversation = (conversationListRef.current.getListItem(conversation['conversationId']) as unknown as CometChat.Conversation);
836
+ if (oldConversation == undefined) {
837
+ conversation.setUnreadMessageCount(1);
838
+ return conversation;
839
+ }
840
+ oldConversation.setUnreadMessageCount(oldConversation.getUnreadMessageCount() + 1);
841
+ return oldConversation;
842
+ }
843
+
780
844
  React.useEffect(() => {
781
845
  CometChat.getLoggedinUser()
782
846
  .then(u => { loggedInUser.current = u })
@@ -802,6 +866,11 @@ export const CometChatConversations = (props: ConversationInterface) => {
802
866
  onIncomingCallReceived: (call) => {
803
867
  CometChat.CometChatHelper.getConversationFromMessage(call)
804
868
  .then((conversation) => {
869
+ if(!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()) {
870
+ return;
871
+ }
872
+ conversation = updateUnreadMessageCount(conversation);
873
+ conversation.setLastMessage(call);
805
874
  conversationListRef.current.updateList(conversation);
806
875
  })
807
876
  .catch((e) => {
@@ -811,6 +880,11 @@ export const CometChatConversations = (props: ConversationInterface) => {
811
880
  onOutgoingCallAccepted: (call) => {
812
881
  CometChat.CometChatHelper.getConversationFromMessage(call)
813
882
  .then((conversation) => {
883
+ if(!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()) {
884
+ return;
885
+ }
886
+ conversation = updateUnreadMessageCount(conversation);
887
+ conversation.setLastMessage(call);
814
888
  conversationListRef.current.updateList(conversation);
815
889
  })
816
890
  .catch((e) => {
@@ -820,6 +894,11 @@ export const CometChatConversations = (props: ConversationInterface) => {
820
894
  onOutgoingCallRejected: (call) => {
821
895
  CometChat.CometChatHelper.getConversationFromMessage(call)
822
896
  .then((conversation) => {
897
+ if(!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()) {
898
+ return;
899
+ }
900
+ conversation = updateUnreadMessageCount(conversation);
901
+ conversation.setLastMessage(call);
823
902
  conversationListRef.current.updateList(conversation);
824
903
  })
825
904
  .catch((e) => {
@@ -829,6 +908,11 @@ export const CometChatConversations = (props: ConversationInterface) => {
829
908
  onIncomingCallCancelled: (call) => {
830
909
  CometChat.CometChatHelper.getConversationFromMessage(call)
831
910
  .then((conversation) => {
911
+ if(!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()) {
912
+ return;
913
+ }
914
+ conversation = updateUnreadMessageCount(conversation);
915
+ conversation.setLastMessage(call);
832
916
  conversationListRef.current.updateList(conversation);
833
917
  })
834
918
  .catch((e) => {
@@ -846,31 +930,46 @@ export const CometChatConversations = (props: ConversationInterface) => {
846
930
  message
847
931
  );
848
932
  },
849
- onGroupMemberKicked: (message) => {
933
+ onGroupMemberKicked: (
934
+ message: CometChat.Action,
935
+ kickedUser: CometChat.User,
936
+ kickedBy: CometChat.User,
937
+ kickedFrom: CometChat.Group) => {
850
938
  groupHandler(
851
939
  message,
852
- 'kicked'
940
+ {action: 'kicked', actionOn: kickedUser, actionBy: kickedBy, group: kickedFrom}
853
941
  );
854
942
  },
855
- onGroupMemberLeft: (message) => {
856
- groupHandler(message);
943
+ onGroupMemberLeft: (message: CometChat.Action, leavingUser: CometChat.User, group: CometChat.Group) => {
944
+ groupHandler(message,
945
+ {action: 'left', actionOn: leavingUser, group}
946
+ );
857
947
  },
858
948
  onGroupMemberUnbanned: (message) => {
859
949
  groupHandler(message);
860
950
  },
861
- onGroupMemberBanned: (message) => {
951
+ onGroupMemberBanned: (
952
+ message: CometChat.Action,
953
+ bannedUser: CometChat.User,
954
+ bannedBy: CometChat.User,
955
+ bannedFrom: CometChat.Group) => {
862
956
  groupHandler(
863
957
  message,
864
- 'banned'
958
+ {action: 'banned', actionOn: bannedUser, actionBy: bannedBy, group: bannedFrom}
865
959
  );
866
960
  },
867
- onMemberAddedToGroup: (message) => {
961
+ onMemberAddedToGroup: (
962
+ message: CometChat.Action,
963
+ userAdded: CometChat.User,
964
+ userAddedBy: CometChat.User,
965
+ userAddedIn: CometChat.Group) => {
868
966
  if (onMemberAddedToGroupDebounceTimer.current) {
869
967
  clearTimeout(onMemberAddedToGroupDebounceTimer.current);
870
968
  }
871
969
  onMemberAddedToGroupDebounceTimer.current = setTimeout(() => {
872
970
  groupHandler(
873
- message
971
+ message,
972
+ {action: 'joined', actionOn: userAdded, actionBy: userAddedBy, group: userAddedIn}
874
973
  );
875
974
  }, 50)
876
975
  },
@@ -903,6 +1002,9 @@ export const CometChatConversations = (props: ConversationInterface) => {
903
1002
  {
904
1003
  ccMessageSent: ({ message, status }) => {
905
1004
  if (status == MessageStatusConstants.success) {
1005
+ if(!shouldUpdateLastMessageAndUnreadCount(message)) {
1006
+ return;
1007
+ }
906
1008
  updateLastMessage(message);
907
1009
  }
908
1010
  },
@@ -916,14 +1018,23 @@ export const CometChatConversations = (props: ConversationInterface) => {
916
1018
  checkAndUpdateLastMessage(message)
917
1019
  },
918
1020
  onTextMessageReceived: (textMessage) => {
1021
+ if(!shouldUpdateLastMessageAndUnreadCount(textMessage)) {
1022
+ return;
1023
+ }
919
1024
  messageEventHandler(textMessage);
920
1025
  !disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
921
1026
  },
922
1027
  onMediaMessageReceived: (mediaMessage) => {
1028
+ if(!shouldUpdateLastMessageAndUnreadCount(mediaMessage)) {
1029
+ return;
1030
+ }
923
1031
  messageEventHandler(mediaMessage);
924
1032
  !disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
925
1033
  },
926
1034
  onCustomMessageReceived: (customMessage) => {
1035
+ if(!shouldUpdateLastMessageAndUnreadCount(customMessage)) {
1036
+ return;
1037
+ }
927
1038
  messageEventHandler(customMessage);
928
1039
  !disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
929
1040
  },
@@ -946,18 +1057,30 @@ export const CometChatConversations = (props: ConversationInterface) => {
946
1057
  typingEventHandler(typingIndicator, false);
947
1058
  },
948
1059
  onFormMessageReceived: (formMessage) => {
1060
+ if(!shouldUpdateLastMessageAndUnreadCount(formMessage)) {
1061
+ return;
1062
+ }
949
1063
  messageEventHandler(formMessage);
950
1064
  !disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
951
1065
  },
952
1066
  onCardMessageReceived: (cardMessage) => {
1067
+ if(!shouldUpdateLastMessageAndUnreadCount(cardMessage)) {
1068
+ return;
1069
+ }
953
1070
  messageEventHandler(cardMessage);
954
1071
  !disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
955
1072
  },
956
1073
  onSchedulerMessageReceived: (schedulerMessage) => {
1074
+ if(!shouldUpdateLastMessageAndUnreadCount(schedulerMessage)) {
1075
+ return;
1076
+ }
957
1077
  messageEventHandler(schedulerMessage);
958
1078
  !disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
959
1079
  },
960
1080
  onCustomInteractiveMessageReceived: (customInteractiveMessage) => {
1081
+ if(!shouldUpdateLastMessageAndUnreadCount(customInteractiveMessage)) {
1082
+ return;
1083
+ }
961
1084
  messageEventHandler(customInteractiveMessage);
962
1085
  !disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
963
1086
  }
@@ -966,6 +1089,13 @@ export const CometChatConversations = (props: ConversationInterface) => {
966
1089
  CometChatUIEventHandler.addGroupListener(
967
1090
  groupListenerId,
968
1091
  {
1092
+ ccGroupCreated: ({ group }) => {
1093
+ CometChat.getConversation(group.getGuid(), CometChatUiKitConstants.ConversationTypeConstants.group).then(
1094
+ conversation => {
1095
+ conversationListRef.current?.addItemToList(conversation, 0);
1096
+ }
1097
+ )
1098
+ },
969
1099
  ccGroupDeleted: ({ group }) => {
970
1100
  conversationListRef.current?.removeItemFromList(group['conversationId']);
971
1101
  removeItemFromSelectionList(group['conversationId'])
@@ -975,15 +1105,27 @@ export const CometChatConversations = (props: ConversationInterface) => {
975
1105
  removeItemFromSelectionList(leftGroup['conversationId'])
976
1106
  },
977
1107
  ccGroupMemberKicked: ({ message, kickedFrom }: { message: CometChat.BaseMessage, kickedFrom: CometChat.Group }) => {
1108
+ if(!(shouldUpdateLastMessageAndUnreadCount(message))) {
1109
+ return;
1110
+ }
978
1111
  updateConversationLastMessage(message)
979
1112
  },
980
1113
  ccGroupMemberBanned: ({ message }) => {
1114
+ if(!(shouldUpdateLastMessageAndUnreadCount(message))) {
1115
+ return;
1116
+ }
981
1117
  groupHandler(message);
982
1118
  },
983
1119
  ccGroupMemberUnBanned: ({ message }) => {
1120
+ if(!(shouldUpdateLastMessageAndUnreadCount(message))) {
1121
+ return;
1122
+ }
984
1123
  groupHandler(message)
985
1124
  },
986
1125
  ccOwnershipChanged: ({ message }) => {
1126
+ if(!(shouldUpdateLastMessageAndUnreadCount(message))) {
1127
+ return;
1128
+ }
987
1129
  CometChat.CometChatHelper.getConversationFromMessage(message)
988
1130
  .then(conversation => {
989
1131
  conversationListRef.current?.updateList(conversation);
@@ -1014,6 +1156,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
1014
1156
  ccOutgoingCall: ({ call }) => {
1015
1157
  CometChat.CometChatHelper.getConversationFromMessage(call)
1016
1158
  .then((conversation) => {
1159
+ if(!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()) {
1160
+ return;
1161
+ }
1162
+ conversation = updateUnreadMessageCount(conversation);
1017
1163
  conversationListRef.current.updateList(conversation);
1018
1164
  })
1019
1165
  .catch((e) => {
@@ -1023,6 +1169,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
1023
1169
  ccCallAccepted: ({ call }) => {
1024
1170
  CometChat.CometChatHelper.getConversationFromMessage(call)
1025
1171
  .then((conversation) => {
1172
+ if(!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()) {
1173
+ return;
1174
+ }
1175
+ conversation = updateUnreadMessageCount(conversation);
1026
1176
  conversationListRef.current.updateList(conversation);
1027
1177
  })
1028
1178
  .catch((e) => {
@@ -1032,6 +1182,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
1032
1182
  ccCallRejected: ({ call }) => {
1033
1183
  CometChat.CometChatHelper.getConversationFromMessage(call)
1034
1184
  .then((conversation) => {
1185
+ if(!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()) {
1186
+ return;
1187
+ }
1188
+ conversation = updateUnreadMessageCount(conversation);
1035
1189
  conversationListRef.current.updateList(conversation);
1036
1190
  })
1037
1191
  .catch((e) => {
@@ -1041,6 +1195,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
1041
1195
  ccCallEnded: ({ call }) => {
1042
1196
  CometChat.CometChatHelper.getConversationFromMessage(call)
1043
1197
  .then((conversation) => {
1198
+ if(!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()) {
1199
+ return;
1200
+ }
1201
+ conversation = updateUnreadMessageCount(conversation);
1044
1202
  conversationListRef.current.updateList(conversation);
1045
1203
  })
1046
1204
  .catch((e) => {
@@ -1102,7 +1260,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1102
1260
  listItemStyle={_listItemStyle}
1103
1261
  TailView={() => <TailView
1104
1262
  customPattern={() => datePattern && props.datePattern(conversation)}
1105
- timestamp={lastMessage && lastMessage['updatedAt'] || conversationWith['createdAt'] || conversationWith['lastActiveAt']}
1263
+ timestamp={lastMessage && lastMessage['sentAt'] || conversationWith['createdAt']}
1106
1264
  unreadCount={conversation.unreadMessageCount}
1107
1265
  />}
1108
1266
  avatarStyle={_avatarStyle}
@@ -1,6 +1,6 @@
1
1
  import { AvatarStyleInterface, CometChatMentionsFormatter, CometChatTextFormatter, CometChatUrlsFormatter, ListItemStyleInterface, localize } from "../shared";
2
2
  import { ImageType } from "../shared";
3
- import { DatePattern,SelectionMode } from "../shared/base/Types";
3
+ import { DatePattern, SelectionMode } from "../shared/base/Types";
4
4
  import { CometChatOptions } from "../shared";
5
5
  // import { ConversationListConfiguration } from "../CometChatConversationList/ConversationListConfiguration";
6
6
  import { ConversationsStyleInterface } from "./ConversationsStyle";
@@ -176,7 +176,9 @@ export class ConversationsConfiguration implements ConversationsConfigurationInt
176
176
  this.backButtonIcon = backButtonIcon;
177
177
  this.showBackButton = showBackButton;
178
178
  this.selectionMode = selectionMode;
179
- this.onSelection = onSelection;
179
+ if (onSelection) {
180
+ this.onSelection = onSelection;
181
+ }
180
182
  this.selectedConversations = selectedConversations;
181
183
  this.searchBoxIcon = searchBoxIcon;
182
184
  this.hideSearch = hideSearch;
@@ -185,10 +187,18 @@ export class ConversationsConfiguration implements ConversationsConfigurationInt
185
187
  this.LoadingStateView = LoadingStateView;
186
188
  this.conversationsRequestBuilder = conversationsRequestBuilder;
187
189
  this.SubtitleView = SubtitleView;
188
- this.onItemPress = onItemPress;
189
- this.onItemLongPress = onItemLongPress;
190
- this.onError = onError;
191
- this.onBack = onBack;
190
+ if (onItemPress) {
191
+ this.onItemPress = onItemPress;
192
+ }
193
+ if (onItemLongPress) {
194
+ this.onItemLongPress = onItemLongPress;
195
+ }
196
+ if (onError) {
197
+ this.onError = onError;
198
+ }
199
+ if (onBack) {
200
+ this.onBack = onBack;
201
+ }
192
202
  this.statusIndicatorStyle = statusIndicatorStyle
193
203
  this.avatarStyle = avatarStyle
194
204
  this.receiptStyle = receiptStyle
@@ -747,19 +747,23 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
747
747
  };
748
748
 
749
749
  useEffect(() => {
750
- listners.addListener.userListener({
751
- userStatusListenerId,
752
- handleUserStatus,
753
- });
754
- listners.addListener.groupListener({
755
- groupListenerId,
756
- handleGroupListener,
757
- });
750
+ if(user) {
751
+ listners.addListener.userListener({
752
+ userStatusListenerId,
753
+ handleUserStatus,
754
+ });
755
+ }
756
+ if(group) {
757
+ listners.addListener.groupListener({
758
+ groupListenerId,
759
+ handleGroupListener,
760
+ });
761
+ }
758
762
  return () => {
759
763
  listners.removeListner.removeUserListener({ userStatusListenerId });
760
764
  listners.removeListner.removeGroupListener({ groupListenerId });
761
765
  };
762
- }, []);
766
+ }, [user, group]);
763
767
 
764
768
  const handleGroupMemberKicked = ({
765
769
  message,
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { View, Text, Alert, TouchableOpacity, Image, Modal } from "react-native";
3
3
  import { kickIcon, banIcon, downArrowIcon, checkIcon } from "./resources";
4
4
  import { CometChatOptions } from "../shared/modals/CometChatOptions";
5
- import { AvatarStyle, AvatarStyleInterface, CometChatContext, ListItemStyle, ListItemStyleInterface, StatusIndicatorStyle } from "../shared";
5
+ import { AvatarStyle, AvatarStyleInterface, CometChatContext, CometChatUiKitConstants, ListItemStyle, ListItemStyleInterface, StatusIndicatorStyle } from "../shared";
6
6
  import { GroupMembersStyle, GroupMembersStyleInterface } from "./GroupMemberStyle";
7
7
  //@ts-ignore
8
8
  import { CometChat } from "@cometchat/chat-sdk-react-native";
@@ -331,6 +331,22 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
331
331
  return;
332
332
  }
333
333
 
334
+ function getStatusIndicatorColor(
335
+ groupMember: CometChat.GroupMember
336
+ ): string | null {
337
+ if (
338
+ props.disableUsersPresence ||
339
+ groupMember.getStatus() === CometChatUiKitConstants.UserStatusConstants.offline
340
+ ) {
341
+ return null;
342
+ }
343
+ return (
344
+ groupMemberStyle?.onlineStatusColor ||
345
+ theme.palette.getSuccess() ||
346
+ null
347
+ );
348
+ }
349
+
334
350
  const ItemView = ({ item: member, ...props }) => {
335
351
  if (ListItemView)
336
352
  return ListItemView(member);
@@ -351,7 +367,7 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
351
367
  onLongPress={itemLongPress.bind(this, member)}
352
368
  SubtitleView={SubtitleView ? () => <SubtitleView {...member} /> : null} //Note: should return prop to SubtitleView
353
369
  statusIndicatorIcon={image}
354
- statusIndicatorColor={backgroundColor}
370
+ statusIndicatorColor={getStatusIndicatorColor(member)}
355
371
  title={member.uid == loggedInUser.current.uid ? "You" : member.name}
356
372
  avatarName={member.name}
357
373
  avatarURL={member.avatar}
@@ -5,12 +5,24 @@ import { CometChat } from "@cometchat/chat-sdk-react-native";
5
5
 
6
6
  export interface GroupMemberConfigurationInterface {
7
7
  SubtitleView?: (groupMember: CometChat.GroupMember) => JSX.Element,
8
+ /**
9
+ * @deprecated
10
+ *
11
+ * This property is deprecated as of version 4.3.10 due to newer property 'disableUsersPresence'. It will be removed in subsequent versions.
12
+ */
8
13
  disableUserPresence?: boolean,
14
+ disableUsersPresence?: boolean,
9
15
  ListItemView?: (groupMember: CometChat.GroupMember) => JSX.Element,
10
16
  AppBarOptions?: () => JSX.Element,
11
17
  options?: (groupMember: CometChat.GroupMember) => CometChatOptions[],
12
18
  hideSeperator?: boolean,
19
+ /**
20
+ * @deprecated
21
+ *
22
+ * This property is deprecated as of version 4.3.10 due to newer property 'searchPlaceholderText'. It will be removed in subsequent versions.
23
+ */
13
24
  searchPlaceHolder?: string,
25
+ searchPlaceholderText?: string,
14
26
  backButtonIcon?: ImageType,
15
27
  showBackButton?: boolean,
16
28
  selectionMode?: "none" | "single" | "multiple",
@@ -35,12 +47,24 @@ export interface GroupMemberConfigurationInterface {
35
47
 
36
48
  export class GroupMemberConfiguration implements GroupMemberConfigurationInterface {
37
49
  SubtitleView?: (groupMember: CometChat.GroupMember) => JSX.Element;
50
+ /**
51
+ * @deprecated
52
+ *
53
+ * This property is deprecated as of version 4.3.10 due to newer property 'disableUsersPresence'. It will be removed in subsequent versions.
54
+ */
38
55
  disableUserPresence?: boolean;
56
+ disableUsersPresence?: boolean;
39
57
  ListItemView?: (groupMember: CometChat.GroupMember) => JSX.Element;
40
58
  AppBarOptions?: () => JSX.Element;
41
59
  options?: (groupMember: CometChat.GroupMember) => CometChatOptions[];
42
60
  hideSeperator?: boolean;
61
+ /**
62
+ * @deprecated
63
+ *
64
+ * This property is deprecated as of version 4.3.10 due to newer property 'searchPlaceholderText'. It will be removed in subsequent versions.
65
+ */
43
66
  searchPlaceHolder?: string;
67
+ searchPlaceholderText?: string;
44
68
  backButtonIcon?: ImageType;
45
69
  showBackButton?: boolean;
46
70
  selectionMode?: "none" | "single" | "multiple";
@@ -64,12 +88,12 @@ export class GroupMemberConfiguration implements GroupMemberConfigurationInterfa
64
88
 
65
89
  constructor(params: GroupMemberConfigurationInterface) {
66
90
  this.SubtitleView = params.SubtitleView;
67
- this.disableUserPresence = params.disableUserPresence;
91
+ this.disableUsersPresence = [false, true].includes(params.disableUsersPresence) ? params.disableUsersPresence : params.disableUserPresence;
68
92
  this.ListItemView = params.ListItemView;
69
93
  this.AppBarOptions = params.AppBarOptions;
70
94
  this.options = params.options;
71
95
  this.hideSeperator = params.hideSeperator;
72
- this.searchPlaceHolder = params.searchPlaceHolder;
96
+ this.searchPlaceholderText = params.searchPlaceholderText ?? params.searchPlaceHolder;
73
97
  this.backButtonIcon = params.backButtonIcon;
74
98
  this.showBackButton = params.showBackButton;
75
99
  this.selectionMode = params.selectionMode;
@@ -875,6 +875,7 @@ export const CometChatMessageComposer = React.forwardRef(
875
875
  textMessage.setReceiver(chatWith.current);
876
876
  textMessage.setText(finalTextInput);
877
877
  textMessage.setMuid(String(getUnixTimestamp()));
878
+ textMessage.setSentAt(getUnixTimestamp());
878
879
  parentMessageId && textMessage.setParentMessageId(parentMessageId as number);
879
880
 
880
881
  allFormatters.current.forEach(item => {
@@ -985,6 +986,7 @@ export const CometChatMessageComposer = React.forwardRef(
985
986
  mediaMessage['_id'] = '_' + Math.random().toString(36).substr(2, 9);
986
987
  mediaMessage.setId(mediaMessage['_id']);
987
988
  mediaMessage.setMuid(String(getUnixTimestamp()));
989
+ mediaMessage.setSentAt(getUnixTimestamp());
988
990
  mediaMessage.setData({
989
991
  type: messageType,
990
992
  category: CometChat.CATEGORY_MESSAGE,
@@ -1009,6 +1011,7 @@ export const CometChatMessageComposer = React.forwardRef(
1009
1011
  localMessage['_id'] = '_' + Math.random().toString(36).substr(2, 9);
1010
1012
  localMessage.setId(localMessage['_id']);
1011
1013
  localMessage.setMuid(String(getUnixTimestamp()));
1014
+ localMessage.setSentAt(getUnixTimestamp());
1012
1015
  localMessage.setData({
1013
1016
  type: messageType,
1014
1017
  category: CometChat.CATEGORY_MESSAGE,
@@ -1253,11 +1256,13 @@ export const CometChatMessageComposer = React.forwardRef(
1253
1256
  mentionsFormatter.setUser(user);
1254
1257
  mentionsFormatter.setGroup(group);
1255
1258
 
1256
- _formatter.push(mentionsFormatter)
1259
+ _formatter.unshift(mentionsFormatter)
1257
1260
  }
1258
1261
 
1259
1262
  _formatter.forEach((formatter) => {
1260
1263
  formatter.setComposerId(id);
1264
+ formatter.setUser(user);
1265
+ formatter.setGroup(group);
1261
1266
  let trackingCharacter = formatter.getTrackingCharacter();
1262
1267
  trackingCharacters.current.push(trackingCharacter);
1263
1268
 
@@ -59,7 +59,13 @@ export interface CometChatMessageListProps {
59
59
  errorIcon?: ImageType,
60
60
  alignment?: MessageListAlignmentType,
61
61
  showAvatar?: boolean,
62
- datePattern?: (message: CometChat.BaseMessage) => "timeFormat" | "dayDateFormat" | "dayDateTimeFormat",
62
+ /**
63
+ * This function returns a string for custom date representation based on the provided message object.
64
+ *
65
+ * @param baseMessage - The message object.
66
+ * @returns The string for custom date representation.
67
+ */
68
+ datePattern?: (message: CometChat.BaseMessage) => string,
63
69
  timeStampAlignment?: MessageTimeAlignmentType,
64
70
  dateSeparatorPattern?: (date: number) => string,
65
71
  templates?: Array<CometChatMessageTemplate>,
@@ -203,6 +209,10 @@ export const CometChatMessageList = memo(forwardRef<
203
209
  let _updatedCustomRequestBuilder = _defaultRequestBuilder;
204
210
  if (messageRequestBuilder) {
205
211
  _updatedCustomRequestBuilder = messageRequestBuilder;
212
+ if (user)
213
+ _updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setUID(user["uid"])
214
+ if (group)
215
+ _updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setGUID(group["guid"])
206
216
  } else {
207
217
  _updatedCustomRequestBuilder.hideReplies(true);
208
218
  if (user)
@@ -796,6 +806,8 @@ export const CometChatMessageList = memo(forwardRef<
796
806
  }
797
807
  tmpMsg['updatedAt'] = receipt['timestamp'];
798
808
 
809
+ tmpList[index] = CommonUtils.clone(tmpMsg);
810
+
799
811
  messagesContentListRef.current = tmpList;
800
812
  setMessagesList(tmpList);
801
813
  }
@@ -1123,12 +1135,14 @@ export const CometChatMessageList = memo(forwardRef<
1123
1135
  });
1124
1136
 
1125
1137
  const onKeyboardVisibiltyChange = (isVisible: boolean, keyboardHeight?: number | undefined) => {
1126
- if (isVisible) {
1127
- Keyboard_Height = keyboardHeight;
1128
- scrollPos = (currentScrollPosition.current.y + Keyboard_Height) - (commonVars.safeAreaInsets.top / 2);
1129
- messageListRef.current.scrollTo({ y: scrollPos, animated: false })
1130
- } else {
1131
- messageListRef.current.scrollTo({ y: scrollPos - Keyboard_Height + (commonVars.safeAreaInsets.top / 2), animated: false })
1138
+ if (messageListRef.current) {
1139
+ if (isVisible) {
1140
+ Keyboard_Height = keyboardHeight;
1141
+ scrollPos = (currentScrollPosition.current.y + Keyboard_Height) - (commonVars.safeAreaInsets.top / 2);
1142
+ messageListRef.current.scrollTo({ y: scrollPos, animated: false })
1143
+ } else {
1144
+ messageListRef.current.scrollTo({ y: scrollPos - Keyboard_Height + (commonVars.safeAreaInsets.top / 2), animated: false })
1145
+ }
1132
1146
  }
1133
1147
  }
1134
1148
 
@@ -1623,7 +1637,7 @@ export const CometChatMessageList = memo(forwardRef<
1623
1637
  ContentView={hasTemplate.ContentView?.bind(this, message, bubbleAlignment)}
1624
1638
  ThreadView={() => !isThreaded && !message.getDeletedBy() && getThreadView(message, bubbleAlignment)}
1625
1639
  BottomView={hasTemplate.BottomView && hasTemplate.BottomView?.bind(this, message, bubbleAlignment)}
1626
- StatusInfoView={() => getStatusInfoView(message, bubbleAlignment)}
1640
+ StatusInfoView={hasTemplate.StatusInfoView ? hasTemplate.StatusInfoView?.bind(this, message, bubbleAlignment) : () => getStatusInfoView(message, bubbleAlignment)}
1627
1641
  style={getStyle(message)}
1628
1642
  />
1629
1643
  </TouchableOpacity>
@@ -1790,7 +1804,7 @@ export const CometChatMessageList = memo(forwardRef<
1790
1804
 
1791
1805
  const getLoadingStateView = useCallback(() => {
1792
1806
  if (LoadingStateView)
1793
- return <LoadingStateView/>;
1807
+ return <LoadingStateView />;
1794
1808
 
1795
1809
  return (
1796
1810
  <View style={Style.msgContainerStyle}>
@@ -36,7 +36,13 @@ export interface MessageListConfigurationInterface {
36
36
  errorIcon?: ImageType;
37
37
  alignment?: MessageListAlignmentType;
38
38
  showAvatar?: boolean;
39
- datePattern?: (baseMessage: CometChat.BaseMessage) => DatePattern;
39
+ /**
40
+ * This function returns a string for custom date representation based on the provided message object.
41
+ *
42
+ * @param baseMessage - The message object.
43
+ * @returns The string for custom date representation.
44
+ */
45
+ datePattern?: (baseMessage: CometChat.BaseMessage) => string;
40
46
  timestampAlignment?: MessageTimeAlignmentType;
41
47
  templates?: CometChatMessageTemplate[];
42
48
  messageRequestBuilder?: CometChat.MessagesRequestBuilder;
@@ -114,7 +120,13 @@ export class MessageListConfiguration
114
120
  errorIcon: ImageType;
115
121
  alignment: MessageListAlignmentType;
116
122
  showAvatar: boolean;
117
- datePattern: (baseMessage: any) => DatePattern;
123
+ /**
124
+ * This function returns a string for custom date representation based on the provided message object.
125
+ *
126
+ * @param baseMessage - The message object.
127
+ * @returns The string for custom date representation.
128
+ */
129
+ datePattern: (baseMessage: CometChat.BaseMessage) => string;
118
130
  timestampAlignment: MessageTimeAlignmentType;
119
131
  templates: CometChatMessageTemplate[];
120
132
  messageRequestBuilder: CometChat.MessagesRequestBuilder;
@@ -1,5 +1,5 @@
1
1
  export const CallUIEvents = {
2
- ccCallFailled : "ccCallFailled",
2
+ ccCallFailed : "ccCallFailed",
3
3
  ccCallInitiated : "ccCallInitiated",
4
4
  ccCallRejected: "ccCallRejected",
5
5
  ccCallAccepted: "ccCallAccepted",
@@ -163,6 +163,8 @@ export const CometChatCallButtons = (props: CometChatCallButtonsInterface) => {
163
163
  "incrementUnreadCount": true,
164
164
  "pushNotification": MessageTypeConstants.meeting,
165
165
  })
166
+ customMessage.shouldUpdateConversation(true);
167
+ customMessage.setMetadata({ incrementUnreadCount: true });
166
168
  customMessage.setCustomData(customData);
167
169
  CometChatUIKit.sendCustomMessage(
168
170
  customMessage)
@@ -191,7 +193,7 @@ export const CometChatCallButtons = (props: CometChatCallButtonsInterface) => {
191
193
  },
192
194
  error => {
193
195
  console.log("Call initialization failed with exception:", error);
194
- CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccCallFailled, { call });
196
+ CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccCallFailed, { call });
195
197
  onError && onError(error);
196
198
  }
197
199
  );
@@ -18,11 +18,11 @@ const CometChatCalls = CallingPackage.CometChatCalls;
18
18
 
19
19
  export interface CometChatCallLogsConfigurationInterface {
20
20
  title?: string,
21
- SubtitleView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element,
22
- ListItemView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element,
23
- TailView?: (param: { call?: CometChat.BaseMessage }) => JSX.Element,
21
+ SubtitleView?: (param: { call?: any }) => JSX.Element,
22
+ ListItemView?: (param: { call?: any }) => JSX.Element,
23
+ TailView?: (param: { call?: any }) => JSX.Element,
24
24
  AppBarOptions?: () => JSX.Element,
25
- options?: (param: { message: CometChat.BaseMessage }) => CometChatOptions[],
25
+ options?: (param: { message: any }) => CometChatOptions[],
26
26
  callRequestBuilder?: any,
27
27
  datePattern: DatePattern,
28
28
  dateSeparatorPattern: DatePattern,
@@ -36,10 +36,10 @@ export interface CometChatCallLogsConfigurationInterface {
36
36
  loadingIcon?: ImageType,
37
37
  LoadingStateView?: () => JSX.Element,
38
38
  hideError?: boolean,
39
- onItemPress?: (item: CometChat.BaseMessage) => void,
39
+ onItemPress?: (item: any) => void,
40
40
  onError?: (e: CometChat.CometChatException) => void,
41
41
  onBack?: () => void,
42
- onInfoIconPress?: (prop: { call: CometChat.BaseMessage }) => void,
42
+ onInfoIconPress?: (prop: { call: any }) => void,
43
43
  infoIcon?: ImageType,
44
44
  avatarStyle?: AvatarStyleInterface,
45
45
  listItemStyle?: ListItemStyleInterface,
@@ -293,7 +293,7 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
293
293
  },
294
294
  error => {
295
295
  console.log("Call initialization failed with exception:", error);
296
- CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccCallFailled, { call });
296
+ CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccCallFailed, { call });
297
297
  onError && onError(error);
298
298
  }
299
299
  );
@@ -195,7 +195,7 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface) =>
195
195
  }
196
196
  },
197
197
  onError: (error) => {
198
- CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccCallFailled, { error });
198
+ CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccCallFailed, { error });
199
199
  onError && onError(error);
200
200
  }
201
201
  });
@@ -163,7 +163,7 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface) =>
163
163
  );
164
164
 
165
165
  CometChatUIEventHandler.addCallListener(listenerId, {
166
- ccCallFailled: () => {
166
+ ccCallFailed: () => {
167
167
  setCallConnected(false);
168
168
  }
169
169
  });
@@ -197,7 +197,7 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface) =>
197
197
  endCallIfRequired();
198
198
  },
199
199
  onError: (error) => {
200
- CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccCallFailled, { error });
200
+ CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccCallFailed, { error });
201
201
  }
202
202
  });
203
203
 
@@ -91,6 +91,8 @@ export class StickersExtensionDecorator extends DataSourceDecorator {
91
91
  customMessage.setMuid(new Date().getTime().toString());
92
92
  customMessage.setSender(loggedInUser.current);
93
93
  customMessage.setReceiver(user || group);
94
+ customMessage.shouldUpdateConversation(true);
95
+ customMessage.setMetadata({ incrementUnreadCount: true });
94
96
  CometChatUIKit.sendCustomMessage(customMessage).then((res) => null).catch(err => null);
95
97
  }
96
98
 
@@ -45,7 +45,7 @@ export class ThumbnailGenerationExtensionDecorator extends DataSourceDecorator {
45
45
  image = message.getType() === "image" ? message?.data?.url : Empty; //default image for type video
46
46
  } else {
47
47
  let attachmentData = thumbnailData['attachments'];
48
- if (attachmentData.length == 1) {
48
+ if (attachmentData.length) {
49
49
  let dataObj = attachmentData[0];
50
50
 
51
51
  if (!dataObj['error']) {
@@ -28,12 +28,13 @@ import { AIAssistBotExtension } from "../../AI/AIAssistBot/AIAssistBotExtension"
28
28
  import { permissionUtil } from "../utils/PermissionUtil";
29
29
  import {
30
30
  getUnixTimestamp,
31
- } from '../../shared/utils/CometChatMessageHelper';
31
+ } from '../../shared/utils/CometChatMessageHelper';
32
32
 
33
33
  export class CometChatUIKit {
34
34
  static uiKitSettings: UIKitSettings;
35
35
  static aiFeatures: AIExtensionDataSource[]
36
36
  static loggedInUser: null | CometChat.User = null;
37
+ static conversationUpdateSettings : CometChat.ConversationUpdateSettings = new CometChat.ConversationUpdateSettings();
37
38
  private static loginListenerID: string = ``;
38
39
  private static isLoginListenerAttached: boolean = false;
39
40
  static init(uiKitSettings: UIKitSettings): Promise<boolean> {
@@ -43,7 +44,6 @@ export class CometChatUIKit {
43
44
  ...uiKitSettings
44
45
  };
45
46
  var appSetting = new CometChat.AppSettingsBuilder()
46
- .subscribePresenceForAllUsers()
47
47
  .autoEstablishSocketConnection(uiKitSettings.autoEstablishSocketConnection)
48
48
  .overrideAdminHost(uiKitSettings?.overrideAdminHost)
49
49
  .overrideClientHost(uiKitSettings?.overrideClientHost)
@@ -52,6 +52,10 @@ export class CometChatUIKit {
52
52
 
53
53
  appSetting.subscriptionType = uiKitSettings.subscriptionType;
54
54
 
55
+ if (appSetting.subscriptionType === "ROLES" && Array.isArray(uiKitSettings.roles) && uiKitSettings.roles.length > 0) {
56
+ appSetting.roles = uiKitSettings.roles;
57
+ }
58
+
55
59
  CometChatUIKit.attachListener();
56
60
 
57
61
  return CometChat.init(uiKitSettings.appId, appSetting.build()).then(
@@ -66,6 +70,10 @@ export class CometChatUIKit {
66
70
  if (user) {
67
71
  this.enableExtensions();
68
72
  }
73
+ CometChat.getConversationUpdateSettings()
74
+ .then((conversationUpdateSettings: CometChat.ConversationUpdateSettings) => {
75
+ CometChatUIKit.setConversationUpdateSettings(conversationUpdateSettings);
76
+ })
69
77
  })
70
78
  .catch(error => {
71
79
  // CometChatUIKit.setLoggedInUser(null);
@@ -114,6 +122,10 @@ export class CometChatUIKit {
114
122
  new CometChat.LoginListener({
115
123
  onLoggedIn: (user: CometChat.User) => {
116
124
  CometChatUIKit.setLoggedInUser(user);
125
+ CometChat.getConversationUpdateSettings()
126
+ .then((conversationUpdateSettings: CometChat.ConversationUpdateSettings) => {
127
+ CometChatUIKit.setConversationUpdateSettings(conversationUpdateSettings);
128
+ })
117
129
  },
118
130
  onLoggedOut: () => {
119
131
  CometChatUIKit.removeLoggedInUser();
@@ -152,7 +164,7 @@ export class CometChatUIKit {
152
164
  if (CometChatUIKit.checkAuthSettings(Promise.reject)) null
153
165
  let user = await CometChat.getLoggedinUser().catch((e) => Promise.reject(e))
154
166
  if (user == null) {
155
- throw(new CometChat.CometChatException({ code: "NOT_FOUND", message: "Login user not found" }));
167
+ throw (new CometChat.CometChatException({ code: "NOT_FOUND", message: "Login user not found" }));
156
168
  } else {
157
169
  this.enableExtensions()
158
170
  }
@@ -163,6 +175,14 @@ export class CometChatUIKit {
163
175
  this.loggedInUser = user;
164
176
  }
165
177
 
178
+ private static setConversationUpdateSettings(conversationUpdateSettings: CometChat.ConversationUpdateSettings) {
179
+ this.conversationUpdateSettings = conversationUpdateSettings;
180
+ }
181
+
182
+ static getConversationUpdateSettings(): CometChat.ConversationUpdateSettings {
183
+ return this.conversationUpdateSettings
184
+ }
185
+
166
186
  private static removeLoggedInUser() {
167
187
  this.loggedInUser = null;
168
188
  }
@@ -179,7 +199,8 @@ export class CometChatUIKit {
179
199
  if (CometChatUIKit.checkAuthSettings(Promise.reject)) null
180
200
  if (uid) {
181
201
  let user = await CometChat.login(uid, CometChatUIKit.uiKitSettings?.authKey).catch(e => Promise.reject(e));
182
- CometChatUIKit.setLoggedInUser(user)
202
+ CometChatUIKit.setLoggedInUser(user);
203
+ CometChatUIKit.setConversationUpdateSettings(await CometChat.getConversationUpdateSettings());
183
204
  this.enableExtensions()
184
205
  return user;
185
206
  }
@@ -244,7 +265,7 @@ export class CometChatUIKit {
244
265
  message.setMuid(String(getUnixTimestamp()));
245
266
  }
246
267
 
247
- if(!message.getSender()){
268
+ if (!message.getSender()) {
248
269
  message.setSender(this.loggedInUser);
249
270
  }
250
271
 
@@ -273,7 +294,7 @@ export class CometChatUIKit {
273
294
  message.setMuid(String(getUnixTimestamp()));
274
295
  }
275
296
 
276
- if(!message.getSender()){
297
+ if (!message.getSender()) {
277
298
  message.setSender(this.loggedInUser);
278
299
  }
279
300
 
@@ -325,7 +346,7 @@ export class CometChatUIKit {
325
346
  message.setMuid(String(getUnixTimestamp()));
326
347
  }
327
348
 
328
- if(!message?.getSender()){
349
+ if (!message?.getSender()) {
329
350
  message.setSender(this.loggedInUser);
330
351
  }
331
352
 
@@ -358,7 +379,7 @@ export class CometChatUIKit {
358
379
  message.setMuid(String(getUnixTimestamp()));
359
380
  }
360
381
 
361
- if(!message.getSender()){
382
+ if (!message.getSender()) {
362
383
  message.setSender(this.loggedInUser);
363
384
  }
364
385
  if (!disableLocalEvents) {
@@ -395,7 +416,7 @@ export class CometChatUIKit {
395
416
  message.setMuid(String(getUnixTimestamp()));
396
417
  }
397
418
 
398
- if(!message.getSender()){
419
+ if (!message.getSender()) {
399
420
  message.setSender(this.loggedInUser);
400
421
  }
401
422
 
@@ -434,7 +455,7 @@ export class CometChatUIKit {
434
455
  message.setMuid(String(getUnixTimestamp()));
435
456
  }
436
457
 
437
- if(!message.getSender()){
458
+ if (!message.getSender()) {
438
459
  message.setSender(this.loggedInUser);
439
460
  }
440
461
  if (!disableLocalEvents) {
@@ -473,7 +494,7 @@ export class CometChatUIKit {
473
494
  message.setMuid(String(getUnixTimestamp()));
474
495
  }
475
496
 
476
- if(!message.getSender()){
497
+ if (!message.getSender()) {
477
498
  message.setSender(this.loggedInUser);
478
499
  }
479
500
 
@@ -4,8 +4,8 @@ import { ExtensionsDataSource } from "../framework"
4
4
  export type UIKitSettings = {
5
5
  appId: string,
6
6
  region: string,
7
- authKey: string,
8
- subscriptionType?: string,
7
+ authKey?: string,
8
+ subscriptionType?: "NONE" | "ALL_USERS" | "ROLES" | "FRIENDS",
9
9
  autoEstablishSocketConnection?: boolean,
10
10
  overrideAdminHost?: string,
11
11
  overrideClientHost?: string,
@@ -13,7 +13,8 @@ export type UIKitSettings = {
13
13
  googleApiKey?: string,
14
14
  disableCalling?: boolean,
15
15
  aiFeatures?:AIExtensionDataSource[],
16
- extensions?:ExtensionsDataSource[]
16
+ extensions?:ExtensionsDataSource[],
17
+ roles?: string[]
17
18
  }
18
19
 
19
20
  export function UIKitSettings({
@@ -28,7 +29,8 @@ export function UIKitSettings({
28
29
  googleApiKey,
29
30
  disableCalling,
30
31
  aiFeatures,
31
- extensions
32
+ extensions,
33
+ roles
32
34
  }: UIKitSettings): UIKitSettings {
33
35
  return {
34
36
  appId,
@@ -42,6 +44,7 @@ export function UIKitSettings({
42
44
  googleApiKey,
43
45
  disableCalling,
44
46
  aiFeatures,
45
- extensions
47
+ extensions,
48
+ roles
46
49
  }
47
50
  }
@@ -76,6 +76,9 @@ export class CometChatUIEventHandler {
76
76
  case listener._eventListener.ccShowOngoingCall?.name:
77
77
  listener._eventListener.ccShowOngoingCall(param);
78
78
  break;
79
+ case listener._eventListener.ccCallFailed?.name:
80
+ listener._eventListener.ccCallFailed(param);
81
+ break;
79
82
  }
80
83
  });
81
84
  }
@@ -135,7 +135,7 @@ type CallUIEvents = {
135
135
  ccOutgoingCallCancelled?: Function,
136
136
  ccCallEnded?: Function,
137
137
  ccCallInitiated?: Function,
138
- ccCallFailled?: Function,
138
+ ccCallFailed?: Function,
139
139
  ccShowOngoingCall?: (CometChatOngoingComponent) => void,
140
140
  }
141
141
 
@@ -166,7 +166,7 @@ export class CallUIEventListener {
166
166
  ccCallRejected?: Function = undefined;
167
167
  ccCallEnded?: Function = undefined;
168
168
  ccOutgoingCallCancelled?: Function = undefined;
169
- ccCallFailled?: Function = undefined;
169
+ ccCallFailed?: Function = undefined;
170
170
  ccCallInitiated?: Function = undefined;
171
171
  ccShowOngoingCall?: (CometChatOngoingComponent) => void;
172
172
 
@@ -180,11 +180,11 @@ export class CallUIEventListener {
180
180
  ccCallRejected,
181
181
  ccCallEnded,
182
182
  ccOutgoingCallCancelled,
183
- ccCallFailled,
183
+ ccCallFailed,
184
184
  ccCallInitiated,
185
185
  ccShowOngoingCall,
186
186
  }: CallUIEvents) {
187
- if (!isFalsy(ccCallFailled)) this.ccCallFailled = ccCallFailled;
187
+ if (!isFalsy(ccCallFailed)) this.ccCallFailed = ccCallFailed;
188
188
  if (!isFalsy(ccCallInitiated)) this.ccCallInitiated = ccCallInitiated;
189
189
  if (!isFalsy(ccOutgoingCall)) this.ccOutgoingCall = ccOutgoingCall;
190
190
  if (!isFalsy(ccCallAccepted)) this.ccCallAccepted = ccCallAccepted;
@@ -5,7 +5,7 @@ import { CometChatMessageBubble } from "../views/CometChatMessageBubble";
5
5
  import { CometChatTheme } from "../resources";
6
6
  import { ChatConfigurator } from "../framework";
7
7
  import { CometChatMessageTemplate } from "../modals";
8
- import { MessageBubbleAlignmentType } from "../base/Types";
8
+ import { BaseStyle, MessageBubbleAlignmentType } from "../base";
9
9
 
10
10
  type MessageViewType = {
11
11
  message: CometChat.BaseMessage,
@@ -14,9 +14,9 @@ type MessageViewType = {
14
14
  theme?: CometChatTheme,
15
15
  }
16
16
 
17
- const MessageContentView = (props:{message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme}) => {
17
+ const MessageContentView = (props: { message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme }) => {
18
18
  const {
19
- message,
19
+ message,
20
20
  alignment,
21
21
  theme
22
22
  } = props;
@@ -48,12 +48,21 @@ export const MessageUtils = {
48
48
  alignment,
49
49
  theme,
50
50
  } = params
51
+
52
+ const getStyle = (item: CometChat.BaseMessage) => {
53
+ let _style: BaseStyle = {};
54
+
55
+ _style.backgroundColor = (alignment !== "left" && (item.getType() === MessageTypeConstants.text || item.getType() === MessageTypeConstants.meeting)) ? theme?.palette.getPrimary() : theme?.palette.getAccent50();
56
+
57
+ return _style;
58
+ };
59
+
51
60
  return <CometChatMessageBubble
52
61
  id={`${message.getId()}`}
53
62
  alignment={alignment}
54
63
  ContentView={template?.ContentView?.bind(this, message, alignment) || MessageContentView.bind(this, message, alignment, theme)}
55
64
  BottomView={template?.BottomView && template?.BottomView?.bind(this, message, alignment)}
56
- style={{backgroundColor: theme?.palette?.getPrimary()}}
57
- />;
65
+ style={getStyle(message)}
66
+ />;
58
67
  }
59
68
  }
@@ -537,9 +537,9 @@ export const CometChatList = React.forwardRef<
537
537
  Object.keys(selectedItems).includes(item.value[listItemKey]) && ICONS.CHECK
538
538
  }
539
539
  SubtitleView={
540
- SubtitleView ? () => <SubtitleView {...item.value} /> : null
540
+ SubtitleView ? () => SubtitleView(item.value) : null
541
541
  }
542
- TailView={TailView ? () => <TailView {...item.value} /> : null}
542
+ TailView={TailView ? () => TailView(item.value) : null}
543
543
  statusIndicatorStyle={
544
544
  selectedItems[item.value[listItemKey]] === true
545
545
  ? {
@@ -167,7 +167,7 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => {
167
167
  volumeIcon={playerVolumeIcon}
168
168
  volumeIconColor={style.playerVolumeIconColor}
169
169
  />
170
- <ImageBackground source={(typeof thumbnailUrl === "object" ? thumbnailUrl?.uri : thumbnailUrl) || placeholderImage || defaultThumbnail} resizeMode={"cover"} style={{ backgroundColor, ...border, borderRadius, height, width, overflow: "hidden" }}>
170
+ <ImageBackground source={(typeof thumbnailUrl === "object" ? { uri: thumbnailUrl?.uri } : thumbnailUrl) || placeholderImage || defaultThumbnail} resizeMode={"cover"} style={{ backgroundColor, ...border, borderRadius, height, width, overflow: "hidden" }}>
171
171
  <View
172
172
  onTouchStart={handleTouchStart}
173
173
  onTouchEnd={handleTouchEnd}