@cometchat/chat-uikit-react-native 4.3.8 → 4.3.10

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 (51) hide show
  1. package/package.json +1 -1
  2. package/src/CometChatAddMembers/CometChatAddMembers.tsx +2 -1
  3. package/src/CometChatBannedMembers/CometChatBannedMembers.tsx +3 -0
  4. package/src/CometChatConversations/CometChatConversations.tsx +180 -29
  5. package/src/CometChatConversations/ConversationsConfiguration.ts +16 -6
  6. package/src/CometChatDetails/CometChatDetails.tsx +13 -9
  7. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +19 -3
  8. package/src/CometChatGroupMembers/GroupMemberConfiguration.ts +26 -2
  9. package/src/CometChatGroupsWithMessages/CometChatGroupsWithMessages.tsx +4 -2
  10. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +12 -3
  11. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +1 -1
  12. package/src/CometChatMessageList/CometChatMessageList.tsx +32 -5
  13. package/src/CometChatMessageList/MessageListConfiguration.ts +14 -2
  14. package/src/CometChatTransferOwnership/CometChatTransferOwnership.tsx +1 -0
  15. package/src/CometChatUsersWithMessages/CometChatUsersWithMessages.tsx +5 -3
  16. package/src/calls/CallEvents.ts +1 -1
  17. package/src/calls/CallingExtentionDecorator.tsx +2 -1
  18. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +3 -1
  19. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +1 -1
  20. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +1 -1
  21. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +2 -2
  22. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +3 -0
  23. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +3 -0
  24. package/src/extensions/Polls/PollsDecorator.tsx +23 -26
  25. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +5 -0
  26. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +1 -1
  27. package/src/index.ts +10 -1
  28. package/src/shared/CometChatUiKit/CometChatUIKit.ts +33 -13
  29. package/src/shared/CometChatUiKit/UIKitSettings.ts +8 -5
  30. package/src/shared/constants/UIKitConstants.ts +2 -2
  31. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +3 -0
  32. package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -4
  33. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +4 -1
  34. package/src/shared/formatters/CometChatTextFormatter.ts +1 -1
  35. package/src/shared/framework/DataSource.ts +1 -2
  36. package/src/shared/framework/DataSourceDecorator.tsx +1 -2
  37. package/src/shared/framework/MessageDataSource.tsx +28 -6
  38. package/src/shared/index.ts +11 -3
  39. package/src/shared/libs/VideoPlayer/Video.js +4 -5
  40. package/src/shared/modals/CometChatMessageTemplate.ts +15 -0
  41. package/src/shared/modals/InteractiveData/InteractiveElements/index.ts +1 -0
  42. package/src/shared/modals/InteractiveData/InteractiveEntities/ElementEntity.ts +1 -2
  43. package/src/shared/modals/InteractiveData/index.ts +1 -0
  44. package/src/shared/modals/index.ts +3 -2
  45. package/src/shared/utils/MessageUtils.tsx +1 -0
  46. package/src/shared/views/CometChatDateTimePicker/CometChatDateTimePicker.tsx +1 -1
  47. package/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx +3 -5
  48. package/src/shared/views/CometChatList/CometChatList.tsx +44 -17
  49. package/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx +3 -5
  50. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +1 -1
  51. package/src/shared/views/index.ts +4 -0
@@ -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 => {
@@ -884,7 +885,11 @@ export const CometChatMessageComposer = React.forwardRef(
884
885
  setMentionsSearchData([]);
885
886
  plainTextInput.current = ""
886
887
 
887
- onSendButtonPress && onSendButtonPress(textMessage);
888
+ if (onSendButtonPress) {
889
+ onSendButtonPress(textMessage);
890
+ return;
891
+ }
892
+
888
893
  if (finalTextInput.trim().length == 0) {
889
894
  return;
890
895
  }
@@ -981,6 +986,7 @@ export const CometChatMessageComposer = React.forwardRef(
981
986
  mediaMessage['_id'] = '_' + Math.random().toString(36).substr(2, 9);
982
987
  mediaMessage.setId(mediaMessage['_id']);
983
988
  mediaMessage.setMuid(String(getUnixTimestamp()));
989
+ mediaMessage.setSentAt(getUnixTimestamp());
984
990
  mediaMessage.setData({
985
991
  type: messageType,
986
992
  category: CometChat.CATEGORY_MESSAGE,
@@ -1005,6 +1011,7 @@ export const CometChatMessageComposer = React.forwardRef(
1005
1011
  localMessage['_id'] = '_' + Math.random().toString(36).substr(2, 9);
1006
1012
  localMessage.setId(localMessage['_id']);
1007
1013
  localMessage.setMuid(String(getUnixTimestamp()));
1014
+ localMessage.setSentAt(getUnixTimestamp());
1008
1015
  localMessage.setData({
1009
1016
  type: messageType,
1010
1017
  category: CometChat.CATEGORY_MESSAGE,
@@ -1249,11 +1256,13 @@ export const CometChatMessageComposer = React.forwardRef(
1249
1256
  mentionsFormatter.setUser(user);
1250
1257
  mentionsFormatter.setGroup(group);
1251
1258
 
1252
- _formatter.push(mentionsFormatter)
1259
+ _formatter.unshift(mentionsFormatter)
1253
1260
  }
1254
1261
 
1255
1262
  _formatter.forEach((formatter) => {
1256
1263
  formatter.setComposerId(id);
1264
+ formatter.setUser(user);
1265
+ formatter.setGroup(group);
1257
1266
  let trackingCharacter = formatter.getTrackingCharacter();
1258
1267
  trackingCharacters.current.push(trackingCharacter);
1259
1268
 
@@ -1788,7 +1797,7 @@ export const CometChatMessageComposer = React.forwardRef(
1788
1797
  <KeyboardAvoidingView
1789
1798
  key={id}
1790
1799
  behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
1791
- keyboardVerticalOffset={Platform.select({ios: kbOffset})}
1800
+ keyboardVerticalOffset={Platform.select({ ios: kbOffset })}
1792
1801
  {...keyboardAvoidingViewProps}
1793
1802
  >
1794
1803
  <View
@@ -414,7 +414,7 @@ export const CometChatMessageHeader = (
414
414
  {!hideBackIcon && <BackButton />}
415
415
  <View style={{ flex: 1 }}>
416
416
  {ListItemView ? (
417
- <ListItemView />
417
+ <ListItemView user={user} group={group}/>
418
418
  ) : (
419
419
  <CometChatListItem
420
420
  id={user ? user.getUid() : groupObj ? groupObj.getGuid() : undefined}
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef, useEffect, useRef, useState, useImperativeHandle, useContext, useCallback, memo, useLayoutEffect } from "react";
2
- import { View, FlatList, Text, Image, TouchableOpacity, ActivityIndicator, Modal, SafeAreaView, NativeModules, ScrollView, Dimensions, Platform } from "react-native";
2
+ import { View, FlatList, Text, Image, TouchableOpacity, ActivityIndicator, Modal, SafeAreaView, NativeModules, ScrollView, Dimensions, Platform, Keyboard } from "react-native";
3
3
  //@ts-ignore
4
4
  import { CometChat } from "@cometchat/chat-sdk-react-native";
5
5
  import { LeftArrowCurve, RightArrowCurve } from "./resources";
@@ -33,6 +33,7 @@ import { CometChatQuickReactions, QuickReactionsConfigurationInterface } from ".
33
33
  import { CometChatReactions, ReactionsConfigurationInterface } from "../shared/views/CometChatReactions";
34
34
  import { CommonUtils } from "../shared/utils/CommonUtils";
35
35
  import Clipboard from "@react-native-clipboard/clipboard";
36
+ import { commonVars } from "../shared/base/vars";
36
37
 
37
38
  let templatesMap = new Map<string, CometChatMessageTemplate>();
38
39
 
@@ -58,7 +59,13 @@ export interface CometChatMessageListProps {
58
59
  errorIcon?: ImageType,
59
60
  alignment?: MessageListAlignmentType,
60
61
  showAvatar?: boolean,
61
- 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,
62
69
  timeStampAlignment?: MessageTimeAlignmentType,
63
70
  dateSeparatorPattern?: (date: number) => string,
64
71
  templates?: Array<CometChatMessageTemplate>,
@@ -229,6 +236,8 @@ export const CometChatMessageList = memo(forwardRef<
229
236
  }, []);
230
237
 
231
238
  const { theme } = useContext<CometChatContextType>(CometChatContext);
239
+ let Keyboard_Height = 0;
240
+ let scrollPos = 0;
232
241
 
233
242
  // creating style based on styles from users
234
243
  const _messageListStyle = useRef(new MessageListStyle({
@@ -808,6 +817,10 @@ export const CometChatMessageList = memo(forwardRef<
808
817
  }
809
818
 
810
819
  useEffect(() => {
820
+
821
+ const showSubscription = Keyboard.addListener('keyboardDidShow', (e) => onKeyboardVisibiltyChange(true, e?.endCoordinates?.height));
822
+ const hideSubscription = Keyboard.addListener('keyboardDidHide', () => onKeyboardVisibiltyChange(false));
823
+
811
824
  CometChatUIEventHandler.addUIListener(
812
825
  uiEventListenerShow,
813
826
  {
@@ -848,6 +861,8 @@ export const CometChatMessageList = memo(forwardRef<
848
861
  });
849
862
 
850
863
  return () => {
864
+ showSubscription.remove();
865
+ hideSubscription.remove();
851
866
  CometChatUIEventHandler.removeUIListener(uiEventListenerShow)
852
867
  CometChatUIEventHandler.removeUIListener(uiEventListenerHide)
853
868
  CometChatUIEventHandler.removeUIListener(uiEventListener);
@@ -1113,6 +1128,18 @@ export const CometChatMessageList = memo(forwardRef<
1113
1128
  }
1114
1129
  });
1115
1130
 
1131
+ const onKeyboardVisibiltyChange = (isVisible: boolean, keyboardHeight?: number | undefined) => {
1132
+ if (messageListRef.current) {
1133
+ if (isVisible) {
1134
+ Keyboard_Height = keyboardHeight;
1135
+ scrollPos = (currentScrollPosition.current.y + Keyboard_Height) - (commonVars.safeAreaInsets.top / 2);
1136
+ messageListRef.current.scrollTo({ y: scrollPos, animated: false })
1137
+ } else {
1138
+ messageListRef.current.scrollTo({ y: scrollPos - Keyboard_Height + (commonVars.safeAreaInsets.top / 2), animated: false })
1139
+ }
1140
+ }
1141
+ }
1142
+
1116
1143
  const getMessageById = (messageId: string): CometChat.BaseMessage => {
1117
1144
  const message = messagesList.find((message) => message.getId() === messageId);
1118
1145
  return message;
@@ -1603,8 +1630,8 @@ export const CometChatMessageList = memo(forwardRef<
1603
1630
  alignment={isThreaded ? "left" : bubbleAlignment}
1604
1631
  ContentView={hasTemplate.ContentView?.bind(this, message, bubbleAlignment)}
1605
1632
  ThreadView={() => !isThreaded && !message.getDeletedBy() && getThreadView(message, bubbleAlignment)}
1606
- BottomView={() => ChatConfigurator.dataSource.getBottomView(message, bubbleAlignment)} // Note please rewrite this
1607
- StatusInfoView={() => getStatusInfoView(message, bubbleAlignment)}
1633
+ BottomView={hasTemplate.BottomView && hasTemplate.BottomView?.bind(this, message, bubbleAlignment)}
1634
+ StatusInfoView={hasTemplate.StatusInfoView ? hasTemplate.StatusInfoView?.bind(this, message, bubbleAlignment) : () => getStatusInfoView(message, bubbleAlignment)}
1608
1635
  style={getStyle(message)}
1609
1636
  />
1610
1637
  </TouchableOpacity>
@@ -1771,7 +1798,7 @@ export const CometChatMessageList = memo(forwardRef<
1771
1798
 
1772
1799
  const getLoadingStateView = useCallback(() => {
1773
1800
  if (LoadingStateView)
1774
- return LoadingStateView;
1801
+ return <LoadingStateView />;
1775
1802
 
1776
1803
  return (
1777
1804
  <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;
@@ -131,6 +131,7 @@ export const CometChatTransferOwnership = (
131
131
  }}
132
132
  selectionMode={'single'}
133
133
  onSelection={transferOwnership}
134
+ groupMemberStyle={transferOwnershipStyle}
134
135
  onBack={onBack}
135
136
  {...newProps}
136
137
  />
@@ -31,9 +31,11 @@ export const CometChatUsersWithMessages = (props: CometChatUsersWithMessagesInte
31
31
  messagesConfigurations,
32
32
  onError
33
33
  } = props;
34
-
35
- const [showComponent, setShowComponent] = useState(ComponentNames.UserList);
36
- const [selectedUser, setSelectedUser] = useState(undefined);
34
+ const [showComponent, setShowComponent] = useState(
35
+ user && user instanceof CometChat.User ? ComponentNames.Messages : ComponentNames.UserList);
36
+ const [selectedUser, setSelectedUser] = useState(
37
+ user && user instanceof CometChat.User ? user : undefined
38
+ );
37
39
  // const [showForwarding, setShowForwarding] = useState(false);
38
40
 
39
41
  const loggedInUser = useRef(null);
@@ -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",
@@ -3,7 +3,8 @@ import { Modal, Text, View, Image, Platform } from "react-native";
3
3
  import { CometChat } from "@cometchat/chat-sdk-react-native";
4
4
  import { CometChatMessageTemplate } from "../shared/modals";
5
5
  import { localize } from "../shared/resources/CometChatLocalize";
6
- import { DataSource, DataSourceDecorator } from "../shared/framework";
6
+ import { DataSourceDecorator } from "../shared/framework/DataSourceDecorator";
7
+ import { DataSource } from "../shared/framework/DataSource";
7
8
  import { CometChatTheme } from "../shared/resources/CometChatTheme";
8
9
  import { CallingConfiguration } from "./CallingConfiguration";
9
10
  import { CallContstatnts, MessageCategoryConstants, MessageOptionConstants, MessageTypeConstants } from "../shared/constants/UIKitConstants";
@@ -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
  );
@@ -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
 
@@ -158,6 +158,9 @@ export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator
158
158
  options: (loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group)=>
159
159
 
160
160
  ChatConfigurator.dataSource.getMessageOptions(loggedInUser, messageObject,group),
161
+ BottomView: (message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType) => {
162
+ return ChatConfigurator.dataSource.getBottomView(message, alignment);
163
+ }
161
164
  }));
162
165
 
163
166
  return templateList;
@@ -162,6 +162,9 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
162
162
  options: (loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group)=>
163
163
 
164
164
  ChatConfigurator.dataSource.getMessageOptions(loggedInUser, messageObject,group),
165
+ BottomView: (message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType) => {
166
+ return ChatConfigurator.dataSource.getBottomView(message, alignment);
167
+ }
165
168
  }));
166
169
 
167
170
  return templateList;
@@ -21,12 +21,11 @@ import { ICONS as ICONS2 } from './resources';
21
21
  import { CometChatCreatePoll } from './Polls';
22
22
  import { PollsBubble } from './PollsBubble';
23
23
  import { AdditionalBubbleStylingParams, MessageBubbleAlignmentType } from '../../shared/base/Types';
24
+ import { CometChatUIKit } from '../../shared';
24
25
 
25
26
  export class PollsExtensionDecorator extends DataSourceDecorator {
26
27
  pollsConfiguration?: PollsConfigurationInterface;
27
28
 
28
- loggedInUser: CometChat.User;
29
-
30
29
  constructor(
31
30
  dataSource: DataSource,
32
31
  pollsConfiguration?: PollsConfigurationInterface
@@ -35,12 +34,6 @@ export class PollsExtensionDecorator extends DataSourceDecorator {
35
34
  if (pollsConfiguration != undefined) {
36
35
  this.pollsConfiguration = pollsConfiguration;
37
36
  }
38
-
39
- CometChat.getLoggedinUser()
40
- .then((u) => {
41
- this.loggedInUser = u;
42
- })
43
- .catch((err) => console.log(err));
44
37
  }
45
38
 
46
39
  isDeletedMessage(message: CometChat.BaseMessage): boolean {
@@ -88,22 +81,22 @@ export class PollsExtensionDecorator extends DataSourceDecorator {
88
81
  ): CometChatMessageComposerActionInterface[] {
89
82
  let attachmentOptions: CometChatMessageComposerActionInterface[] =
90
83
  super.getAttachmentOptions(user, group, composerId);
91
- if(composerId == undefined || (composerId as Map<any, any>).get("parentMessageId") == undefined)
92
- attachmentOptions.push({
93
- id: 'polls',
94
- title: 'Polls',
95
- iconUrl: ICONS2.DOCUMENT,
96
- CustomView: (user, group, _id, pollsProps) => {
97
- return (
98
- <CometChatCreatePoll
99
- user={user}
100
- group={group}
101
- {...pollsProps}
102
- {...this.pollsConfiguration}
103
- />
104
- );
105
- },
106
- });
84
+ if (composerId == undefined || (composerId as Map<any, any>).get("parentMessageId") == undefined)
85
+ attachmentOptions.push({
86
+ id: 'polls',
87
+ title: 'Polls',
88
+ iconUrl: ICONS2.DOCUMENT,
89
+ CustomView: (user, group, _id, pollsProps) => {
90
+ return (
91
+ <CometChatCreatePoll
92
+ user={user}
93
+ group={group}
94
+ {...pollsProps}
95
+ {...this.pollsConfiguration}
96
+ />
97
+ );
98
+ },
99
+ });
107
100
  return attachmentOptions;
108
101
  }
109
102
 
@@ -135,6 +128,9 @@ export class PollsExtensionDecorator extends DataSourceDecorator {
135
128
  messageObject,
136
129
  group
137
130
  ),
131
+ BottomView: (message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType) => {
132
+ return ChatConfigurator.dataSource.getBottomView(message, alignment);
133
+ }
138
134
  })
139
135
  );
140
136
 
@@ -145,7 +141,8 @@ export class PollsExtensionDecorator extends DataSourceDecorator {
145
141
  message: CometChat.BaseMessage,
146
142
  _alignment: MessageBubbleAlignmentType
147
143
  ) {
148
- if (message && this.loggedInUser) {
144
+ let _loggedInUser = CometChatUIKit.loggedInUser;
145
+ if (message && _loggedInUser) {
149
146
  const metaData = getExtentionData(
150
147
  message,
151
148
  MetadataConstants.extensions?.polls
@@ -156,7 +153,7 @@ export class PollsExtensionDecorator extends DataSourceDecorator {
156
153
  pollQuestion={message['customData']?.['question']}
157
154
  options={message['customData']?.['options']}
158
155
  pollId={message['customData']?.['id']}
159
- loggedInUser={this.loggedInUser}
156
+ loggedInUser={_loggedInUser}
160
157
  // choosePoll
161
158
  senderUid={message['sender']?.['uid']}
162
159
  metadata={metaData}
@@ -44,6 +44,9 @@ export class StickersExtensionDecorator extends DataSourceDecorator {
44
44
  },
45
45
  options: (loggedInuser, message, group) => {
46
46
  return ChatConfigurator.dataSource.getMessageOptions(loggedInuser, message, group);
47
+ },
48
+ BottomView: (message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType) => {
49
+ return ChatConfigurator.dataSource.getBottomView(message, alignment);
47
50
  }
48
51
  })
49
52
  );
@@ -88,6 +91,8 @@ export class StickersExtensionDecorator extends DataSourceDecorator {
88
91
  customMessage.setMuid(new Date().getTime().toString());
89
92
  customMessage.setSender(loggedInUser.current);
90
93
  customMessage.setReceiver(user || group);
94
+ customMessage.shouldUpdateConversation(true);
95
+ customMessage.setMetadata({ incrementUnreadCount: true });
91
96
  CometChatUIKit.sendCustomMessage(customMessage).then((res) => null).catch(err => null);
92
97
  }
93
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']) {
package/src/index.ts CHANGED
@@ -180,6 +180,10 @@ import {
180
180
  SuggestionListConfiguration,
181
181
  SuggestionListConfigurationInterface,
182
182
  SuggestionItem,
183
+ DateTimeElement,
184
+ CometChatDateTimePicker,
185
+ CometChatDateTimePickerInterface,
186
+ DatePickerStyleInterface,
183
187
  } from './shared';
184
188
 
185
189
  import {
@@ -747,8 +751,13 @@ export {
747
751
  CometChatSuggestionListInterface,
748
752
  SuggestionItem,
749
753
  SuggestionListConfiguration,
750
- SuggestionListConfigurationInterface
754
+ SuggestionListConfigurationInterface,
751
755
  /* Text Formatters */
756
+
757
+ DateTimeElement,
758
+ CometChatDateTimePicker,
759
+ CometChatDateTimePickerInterface,
760
+ DatePickerStyleInterface,
752
761
 
753
762
  };
754
763
 
@@ -18,23 +18,23 @@ import { TextModerationExtension } from "../../extensions/TextModeration";
18
18
  import { ThumbnailGenerationExtension } from "../../extensions/ThumbnailGeneration";
19
19
  import { CometChatSoundManager } from "../utils";
20
20
  import { CometChatLocalize } from "../resources";
21
- import { CardMessage, CustomInteractiveMessage, FormMessage } from "../modals/InteractiveData";
21
+ import { CardMessage, CustomInteractiveMessage, FormMessage, SchedulerMessage } from "../modals/InteractiveData";
22
22
  import { ListenerInitializer } from "../events/ListenerInitializer";
23
23
  import { AIConversationStarterExtension } from "../../AI/AIConversationStarter/AIConversationStarter";
24
24
  import { AIExtensionDataSource } from "../../AI/AIExtensionDataSource";
25
25
  import { AISmartRepliesExtension } from "../../AI/AISmartReplies/AISmartReplies";
26
26
  import { AIConversationSummaryExtension } from "../../AI/AIConversationSummary/AIConversationSummaryExtension";
27
27
  import { AIAssistBotExtension } from "../../AI/AIAssistBot/AIAssistBotExtension";
28
- import { SchedulerMessage } from "../modals/InteractiveData/InteractiveMessage";
29
28
  import { permissionUtil } from "../utils/PermissionUtil";
30
29
  import {
31
30
  getUnixTimestamp,
32
- } from '../../shared/utils/CometChatMessageHelper';
31
+ } from '../../shared/utils/CometChatMessageHelper';
33
32
 
34
33
  export class CometChatUIKit {
35
34
  static uiKitSettings: UIKitSettings;
36
35
  static aiFeatures: AIExtensionDataSource[]
37
36
  static loggedInUser: null | CometChat.User = null;
37
+ static conversationUpdateSettings : CometChat.ConversationUpdateSettings = new CometChat.ConversationUpdateSettings();
38
38
  private static loginListenerID: string = ``;
39
39
  private static isLoginListenerAttached: boolean = false;
40
40
  static init(uiKitSettings: UIKitSettings): Promise<boolean> {
@@ -44,7 +44,6 @@ export class CometChatUIKit {
44
44
  ...uiKitSettings
45
45
  };
46
46
  var appSetting = new CometChat.AppSettingsBuilder()
47
- .subscribePresenceForAllUsers()
48
47
  .autoEstablishSocketConnection(uiKitSettings.autoEstablishSocketConnection)
49
48
  .overrideAdminHost(uiKitSettings?.overrideAdminHost)
50
49
  .overrideClientHost(uiKitSettings?.overrideClientHost)
@@ -53,6 +52,10 @@ export class CometChatUIKit {
53
52
 
54
53
  appSetting.subscriptionType = uiKitSettings.subscriptionType;
55
54
 
55
+ if (appSetting.subscriptionType === "ROLES" && Array.isArray(uiKitSettings.roles) && uiKitSettings.roles.length > 0) {
56
+ appSetting.roles = uiKitSettings.roles;
57
+ }
58
+
56
59
  CometChatUIKit.attachListener();
57
60
 
58
61
  return CometChat.init(uiKitSettings.appId, appSetting.build()).then(
@@ -67,6 +70,10 @@ export class CometChatUIKit {
67
70
  if (user) {
68
71
  this.enableExtensions();
69
72
  }
73
+ CometChat.getConversationUpdateSettings()
74
+ .then((conversationUpdateSettings: CometChat.ConversationUpdateSettings) => {
75
+ CometChatUIKit.setConversationUpdateSettings(conversationUpdateSettings);
76
+ })
70
77
  })
71
78
  .catch(error => {
72
79
  // CometChatUIKit.setLoggedInUser(null);
@@ -115,6 +122,10 @@ export class CometChatUIKit {
115
122
  new CometChat.LoginListener({
116
123
  onLoggedIn: (user: CometChat.User) => {
117
124
  CometChatUIKit.setLoggedInUser(user);
125
+ CometChat.getConversationUpdateSettings()
126
+ .then((conversationUpdateSettings: CometChat.ConversationUpdateSettings) => {
127
+ CometChatUIKit.setConversationUpdateSettings(conversationUpdateSettings);
128
+ })
118
129
  },
119
130
  onLoggedOut: () => {
120
131
  CometChatUIKit.removeLoggedInUser();
@@ -153,7 +164,7 @@ export class CometChatUIKit {
153
164
  if (CometChatUIKit.checkAuthSettings(Promise.reject)) null
154
165
  let user = await CometChat.getLoggedinUser().catch((e) => Promise.reject(e))
155
166
  if (user == null) {
156
- 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" }));
157
168
  } else {
158
169
  this.enableExtensions()
159
170
  }
@@ -164,6 +175,14 @@ export class CometChatUIKit {
164
175
  this.loggedInUser = user;
165
176
  }
166
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
+
167
186
  private static removeLoggedInUser() {
168
187
  this.loggedInUser = null;
169
188
  }
@@ -180,7 +199,8 @@ export class CometChatUIKit {
180
199
  if (CometChatUIKit.checkAuthSettings(Promise.reject)) null
181
200
  if (uid) {
182
201
  let user = await CometChat.login(uid, CometChatUIKit.uiKitSettings?.authKey).catch(e => Promise.reject(e));
183
- CometChatUIKit.setLoggedInUser(user)
202
+ CometChatUIKit.setLoggedInUser(user);
203
+ CometChatUIKit.setConversationUpdateSettings(await CometChat.getConversationUpdateSettings());
184
204
  this.enableExtensions()
185
205
  return user;
186
206
  }
@@ -245,7 +265,7 @@ export class CometChatUIKit {
245
265
  message.setMuid(String(getUnixTimestamp()));
246
266
  }
247
267
 
248
- if(!message.getSender()){
268
+ if (!message.getSender()) {
249
269
  message.setSender(this.loggedInUser);
250
270
  }
251
271
 
@@ -274,7 +294,7 @@ export class CometChatUIKit {
274
294
  message.setMuid(String(getUnixTimestamp()));
275
295
  }
276
296
 
277
- if(!message.getSender()){
297
+ if (!message.getSender()) {
278
298
  message.setSender(this.loggedInUser);
279
299
  }
280
300
 
@@ -326,7 +346,7 @@ export class CometChatUIKit {
326
346
  message.setMuid(String(getUnixTimestamp()));
327
347
  }
328
348
 
329
- if(!message?.getSender()){
349
+ if (!message?.getSender()) {
330
350
  message.setSender(this.loggedInUser);
331
351
  }
332
352
 
@@ -359,7 +379,7 @@ export class CometChatUIKit {
359
379
  message.setMuid(String(getUnixTimestamp()));
360
380
  }
361
381
 
362
- if(!message.getSender()){
382
+ if (!message.getSender()) {
363
383
  message.setSender(this.loggedInUser);
364
384
  }
365
385
  if (!disableLocalEvents) {
@@ -396,7 +416,7 @@ export class CometChatUIKit {
396
416
  message.setMuid(String(getUnixTimestamp()));
397
417
  }
398
418
 
399
- if(!message.getSender()){
419
+ if (!message.getSender()) {
400
420
  message.setSender(this.loggedInUser);
401
421
  }
402
422
 
@@ -435,7 +455,7 @@ export class CometChatUIKit {
435
455
  message.setMuid(String(getUnixTimestamp()));
436
456
  }
437
457
 
438
- if(!message.getSender()){
458
+ if (!message.getSender()) {
439
459
  message.setSender(this.loggedInUser);
440
460
  }
441
461
  if (!disableLocalEvents) {
@@ -474,7 +494,7 @@ export class CometChatUIKit {
474
494
  message.setMuid(String(getUnixTimestamp()));
475
495
  }
476
496
 
477
- if(!message.getSender()){
497
+ if (!message.getSender()) {
478
498
  message.setSender(this.loggedInUser);
479
499
  }
480
500