@cometchat/chat-uikit-react-native 5.3.5 → 5.3.7

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 (76) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +18 -1
  2. package/ios/FileManager.m +14 -3
  3. package/ios/SoundPlayer.m +24 -1
  4. package/package.json +2 -1
  5. package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +8 -3
  6. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +14 -11
  7. package/src/CometChatConversations/CometChatConversations.tsx +89 -51
  8. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +10 -11
  9. package/src/CometChatGroups/CometChatGroups.tsx +49 -42
  10. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +10 -7
  11. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +12 -10
  12. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +4 -3
  13. package/src/CometChatMessageList/CometChatMessageList.tsx +398 -144
  14. package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +478 -0
  15. package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +613 -0
  16. package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +4 -1
  17. package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +811 -0
  18. package/src/CometChatNotificationFeed/Skeleton.tsx +43 -0
  19. package/src/CometChatNotificationFeed/index.ts +19 -0
  20. package/src/CometChatNotificationFeed/style.ts +333 -0
  21. package/src/CometChatNotificationFeed/utils.ts +124 -0
  22. package/src/CometChatSearch/CometChatSearch.tsx +8 -6
  23. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +4 -3
  24. package/src/CometChatUsers/CometChatUsers.tsx +56 -43
  25. package/src/calls/CallingExtensionDecorator.tsx +1 -1
  26. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +3 -2
  27. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +7 -6
  28. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +2 -1
  29. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +2 -1
  30. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +4 -4
  31. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +5 -3
  32. package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +1 -1
  33. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +5 -5
  34. package/src/extensions/Polls/PollsBubble.tsx +1 -1
  35. package/src/extensions/Polls/PollsDecorator.tsx +1 -1
  36. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -2
  37. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +9 -5
  38. package/src/index.ts +7 -0
  39. package/src/shared/CometChatUiKit/CometChatUIKit.ts +48 -20
  40. package/src/shared/events/ListenerInitializer.ts +2 -1
  41. package/src/shared/framework/MessageDataSource.tsx +19 -15
  42. package/src/shared/helper/helperFunctions.ts +5 -4
  43. package/src/shared/icons/components/notification-empty.tsx +27 -0
  44. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +8 -1
  45. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +8 -1
  46. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +8 -1
  47. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +8 -1
  48. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +8 -1
  49. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +8 -1
  50. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +8 -1
  51. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +8 -1
  52. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +8 -1
  53. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +8 -1
  54. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +8 -1
  55. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +8 -1
  56. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +8 -1
  57. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +8 -1
  58. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +8 -1
  59. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +8 -1
  60. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +8 -1
  61. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +8 -1
  62. package/src/shared/services/stream-message.service.ts +0 -1
  63. package/src/shared/utils/CommonUtils.ts +1 -1
  64. package/src/shared/utils/MessageUtils.tsx +15 -13
  65. package/src/shared/utils/conversationUtils.ts +2 -2
  66. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +2 -2
  67. package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +17 -5
  68. package/src/shared/views/CometChatList/CometChatList.tsx +11 -15
  69. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +3 -3
  70. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +2 -1
  71. package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +15 -4
  72. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -3
  73. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +15 -1
  74. package/src/theme/default/default.ts +6 -0
  75. package/src/theme/provider.tsx +12 -12
  76. package/src/theme/type.ts +2 -0
@@ -1,5 +1,6 @@
1
+ let __listenerIdCounter = 0;
1
2
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
- import React, { JSX, useCallback, useEffect, useRef, useState } from "react";
3
+ import React, { JSX, useCallback, useEffect, useMemo, useRef, useState } from "react";
3
4
  import { ColorValue, KeyboardAvoidingView, Platform, View } from "react-native";
4
5
  import {
5
6
  CometChatList,
@@ -227,7 +228,7 @@ export const CometChatUsers = React.forwardRef<
227
228
  CometChatUsersActionsInterface,
228
229
  CometChatUsersInterface
229
230
  >((props, ref) => {
230
- const userListenerId = "userStatus_" + new Date().getTime();
231
+ const userListenerId = useRef("userStatus_" + Date.now() + "_" + (++__listenerIdCounter)).current;
231
232
  const theme = useTheme();
232
233
  const {t}= useCometChatTranslation()
233
234
  const [hideSearchError, setHideSearchError] = useState(false);
@@ -263,20 +264,20 @@ export const CometChatUsers = React.forwardRef<
263
264
  ...newProps
264
265
  } = props;
265
266
  const userRef = useRef<CometChatUsersActionsInterface>(null);
266
- const mergedStyle = deepMerge(theme.userStyles, style);
267
+ const mergedStyle = useMemo(() => deepMerge(theme.userStyles, style), [theme, style]);
267
268
 
268
269
  // ----- Tooltip functionality for users -----
269
270
  const [tooltipVisible, setTooltipVisible] = useState(false);
270
271
  const [selectedUser, setSelectedUser] = useState<CometChat.User | null>(null);
271
272
  const tooltipPosition = useRef({ pageX: 0, pageY: 0 });
272
273
 
273
- const buildMenuItems = (user: CometChat.User): MenuItemInterface[] => {
274
+ const buildMenuItems = useCallback((user: CometChat.User): MenuItemInterface[] => {
274
275
  if (options) return options(user);
275
276
  if (addOptions) return addOptions(user);
276
277
  return [];
277
- };
278
+ }, [options, addOptions]);
278
279
 
279
- const handleItemLongPress = (user: CometChat.User, e?: any) => {
280
+ const handleItemLongPress = useCallback((user: CometChat.User, e?: any) => {
280
281
  if (props.onItemLongPress) {
281
282
  props.onItemLongPress(user);
282
283
  return;
@@ -293,7 +294,7 @@ export const CometChatUsers = React.forwardRef<
293
294
  }
294
295
  setSelectedUser(user);
295
296
  setTooltipVisible(true);
296
- };
297
+ }, [props.onItemLongPress, buildMenuItems]);
297
298
 
298
299
  useEffect(() => {
299
300
  // Listen for changes in user online/offline status.
@@ -302,12 +303,12 @@ export const CometChatUsers = React.forwardRef<
302
303
  new CometChat.UserListener({
303
304
  onUserOnline: (onlineUser: CometChat.User) => {
304
305
  if (!onlineUser.getBlockedByMe()) {
305
- userRef.current!.updateList(onlineUser);
306
+ userRef.current?.updateList(onlineUser);
306
307
  }
307
308
  },
308
309
  onUserOffline: (offlineUser: CometChat.User) => {
309
310
  if (!offlineUser.getBlockedByMe()) {
310
- userRef.current!.updateList(offlineUser);
311
+ userRef.current?.updateList(offlineUser);
311
312
  }
312
313
  },
313
314
  })
@@ -324,7 +325,7 @@ export const CometChatUsers = React.forwardRef<
324
325
  const clonedUser = CommonUtils.clone(user);
325
326
  clonedUser.blockedByMe = true;
326
327
  clonedUser.hasBlockedMe = true;
327
- userRef.current!.updateList(clonedUser);
328
+ userRef.current?.updateList(clonedUser);
328
329
  };
329
330
 
330
331
  /**
@@ -336,10 +337,10 @@ export const CometChatUsers = React.forwardRef<
336
337
  const clonedUser = CommonUtils.clone(user);
337
338
  clonedUser.blockedByMe = false;
338
339
  clonedUser.hasBlockedMe = false;
339
- userRef.current!.updateList(clonedUser);
340
+ userRef.current?.updateList(clonedUser);
340
341
 
341
342
  CometChat.getUser(clonedUser.getUid()).then((updatedUser) => {
342
- userRef.current!.updateList(updatedUser);
343
+ userRef.current?.updateList(updatedUser);
343
344
  });
344
345
  };
345
346
 
@@ -436,6 +437,45 @@ export const CometChatUsers = React.forwardRef<
436
437
  );
437
438
  }, [theme, mergedStyle, hideError]);
438
439
 
440
+ // Memoize tooltip menu items — avoids .map() creating new array on every render
441
+ const tooltipMenuItems = useMemo(() => {
442
+ if (!selectedUser) return [];
443
+ return buildMenuItems(selectedUser).map((menuItem) => ({
444
+ text: menuItem.text,
445
+ onPress: () => {
446
+ menuItem.onPress();
447
+ setTooltipVisible(false);
448
+ },
449
+ textColor: menuItem.textColor,
450
+ iconColor: menuItem.iconColor,
451
+ disabled: menuItem.disabled,
452
+ }));
453
+ }, [selectedUser, tooltipVisible, buildMenuItems]);
454
+
455
+ // Stable onListFetched callback
456
+ const handleListFetched = useCallback((users: CometChat.User[]) => {
457
+ if (users.length === 0) {
458
+ onEmpty?.();
459
+ } else {
460
+ onLoad?.(users);
461
+ }
462
+ }, [onEmpty, onLoad]);
463
+
464
+ // Stable request builder — avoids creating new instance every render
465
+ const defaultRequestBuilder = useMemo(
466
+ () => (usersRequestBuilder && usersRequestBuilder.setSearchKeyword(searchKeyword)) ||
467
+ new CometChat.UsersRequestBuilder()
468
+ .setLimit(30)
469
+ .hideBlockedUsers(false)
470
+ .setRoles([])
471
+ .friendsOnly(false)
472
+ .setStatus("")
473
+ .setTags([])
474
+ .setUIDs([])
475
+ .setSearchKeyword(searchKeyword),
476
+ [usersRequestBuilder, searchKeyword]
477
+ );
478
+
439
479
  return (
440
480
  <View style={theme.userStyles.containerStyle}>
441
481
  <CometChatList
@@ -453,30 +493,12 @@ export const CometChatUsers = React.forwardRef<
453
493
  LeadingView={LeadingView}
454
494
  onSelection={onSelection}
455
495
  onSubmit={onSubmit}
456
- // Pass our custom long press handler which shows tooltip if options exist.
457
- onItemLongPress={(user: CometChat.User, e: any) => handleItemLongPress(user, e)}
496
+ onItemLongPress={handleItemLongPress}
458
497
  ItemView={props.ItemView}
459
- onListFetched={(users: CometChat.User[]) => {
460
- if (users.length === 0) {
461
- onEmpty?.();
462
- } else {
463
- onLoad?.(users);
464
- }
465
- }}
498
+ onListFetched={handleListFetched}
466
499
  ref={userRef}
467
500
  hideSearch={hideSearch ? hideSearch : hideSearchError}
468
- requestBuilder={
469
- (usersRequestBuilder && usersRequestBuilder.setSearchKeyword(searchKeyword)) ||
470
- new CometChat.UsersRequestBuilder()
471
- .setLimit(30)
472
- .hideBlockedUsers(false)
473
- .setRoles([])
474
- .friendsOnly(false)
475
- .setStatus("")
476
- .setTags([])
477
- .setUIDs([])
478
- .setSearchKeyword(searchKeyword)
479
- }
501
+ requestBuilder={defaultRequestBuilder}
480
502
  listStyle={mergedStyle}
481
503
  hideStickyHeader={!stickyHeaderVisibility}
482
504
  listItemKey='uid'
@@ -516,16 +538,7 @@ export const CometChatUsers = React.forwardRef<
516
538
  event={{
517
539
  nativeEvent: tooltipPosition.current,
518
540
  }}
519
- menuItems={buildMenuItems(selectedUser).map((menuItem) => ({
520
- text: menuItem.text,
521
- onPress: () => {
522
- menuItem.onPress();
523
- setTooltipVisible(false);
524
- },
525
- textColor: menuItem.textColor,
526
- iconColor: menuItem.iconColor,
527
- disabled: menuItem.disabled,
528
- }))}
541
+ menuItems={tooltipMenuItems}
529
542
  />
530
543
  </View>
531
544
  )}
@@ -220,7 +220,7 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
220
220
  if (this.isDeletedMessage(message))
221
221
  return ChatConfigurator.dataSource.getDeleteMessageBubble(message, theme);
222
222
 
223
- const isSentByMe = message.getSender().getUid() === loggedInUser!.getUid();
223
+ const isSentByMe = message.getSender()?.getUid() === loggedInUser?.getUid();
224
224
 
225
225
  const _style = isSentByMe
226
226
  ? theme.messageListStyles.outgoingMessageBubbleStyles?.meetCallBubbleStyles
@@ -1,3 +1,4 @@
1
+ let __listenerIdCounter = 0;
1
2
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
3
  import React, { useEffect, useMemo, useRef, useState } from "react";
3
4
  import {
@@ -27,7 +28,7 @@ import { JSX } from "react";
27
28
 
28
29
  const CometChatCalls = CallingPackage.CometChatCalls;
29
30
 
30
- const listenerId = "callEventListener_" + new Date().getTime();
31
+ const listenerId = "callEventListener_" + Date.now() + "_" + (++__listenerIdCounter);
31
32
 
32
33
  /**
33
34
  * Props for the CometChatCallButtons component.
@@ -153,7 +154,7 @@ export const CometChatCallButtons = (props: CometChatCallButtonsInterface): JSX.
153
154
  );
154
155
  customMessage.setCategory(CometChat.CATEGORY_CUSTOM as CometChat.MessageCategory);
155
156
  customMessage.setMuid(String(getUnixTimestampInMilliseconds()));
156
- customMessage.setSender(loggedInUser.current!);
157
+ customMessage.setSender(loggedInUser.current);
157
158
  customMessage.setReceiver(group);
158
159
  customMessage.setMetadata({
159
160
  ...customMessage.getMetadata(),
@@ -1,3 +1,4 @@
1
+ let __listenerIdCounter = 0;
1
2
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
3
  import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
4
  import {
@@ -30,7 +31,7 @@ import { CometChatTooltipMenu, MenuItemInterface } from "../../shared/views/Come
30
31
  import { JSX } from "react";
31
32
  import { useCometChatTranslation, useLocalizedDate, LocalizedDateHelper } from "../../shared";
32
33
 
33
- const listenerId = "callEventListener_" + new Date().getTime();
34
+ const listenerId = "callEventListener_" + Date.now() + "_" + (++__listenerIdCounter);
34
35
  const CometChatCalls = CallingPackage.CometChatCalls;
35
36
 
36
37
  /**
@@ -210,10 +211,10 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
210
211
  */
211
212
  function setRequestBuilder() {
212
213
  const reqBuilder = callLogRequestBuilder
213
- ? callLogRequestBuilder.setAuthToken(loggedInUser.current!.getAuthToken())
214
+ ? callLogRequestBuilder.setAuthToken(loggedInUser.current?.getAuthToken())
214
215
  : new CometChatCalls.CallLogRequestBuilder()
215
216
  .setLimit(30)
216
- .setAuthToken(loggedInUser.current!.getAuthToken() || "")
217
+ .setAuthToken(loggedInUser.current?.getAuthToken() || "")
217
218
  .setCallCategory("call");
218
219
  callLogRequestBuilderRef.current = reqBuilder.build();
219
220
  }
@@ -225,9 +226,9 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
225
226
  const fetchCallLogs = (isAppending: boolean = true) => {
226
227
  setListState("loading");
227
228
  callLogRequestBuilderRef
228
- .current!.fetchNext()
229
+ .current?.fetchNext()
229
230
  .then((callLogs: any) => {
230
- if (callLogRequestBuilderRef.current!.limit > callLogs.length) {
231
+ if (callLogRequestBuilderRef.current?.limit > callLogs.length) {
231
232
  setHasMoreData(false);
232
233
  }
233
234
  if (callLogs.length > 0) {
@@ -409,7 +410,7 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
409
410
  if (ItemView) return ItemView(item);
410
411
 
411
412
  const { title, avatarUrl } = getCallDetails(item);
412
- const callStatus = CallUtils.getCallStatusForCallLogs(item, loggedInUser.current!);
413
+ const callStatus = CallUtils.getCallStatusForCallLogs(item, loggedInUser.current);
413
414
 
414
415
  return (
415
416
  <TouchableOpacity
@@ -1,3 +1,4 @@
1
+ let __listenerIdCounter = 0;
1
2
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
3
  import React, { useEffect, useMemo, useRef, useState } from "react";
3
4
  import { Text, TouchableOpacity, View, StyleSheet } from "react-native";
@@ -20,7 +21,7 @@ import { JSX } from "react";
20
21
  import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
21
22
  import { SafeAreaView } from "react-native-safe-area-context";
22
23
 
23
- const listnerID = "CALL_LISTENER_" + new Date().getTime();
24
+ const listnerID = "CALL_LISTENER_" + Date.now() + "_" + (++__listenerIdCounter);
24
25
  const CometChatCalls = CallingPackage.CometChatCalls;
25
26
 
26
27
  /**
@@ -1,3 +1,4 @@
1
+ let __listenerIdCounter = 0;
1
2
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
3
  import React, { JSX, useEffect, useMemo, useRef, useState } from "react";
3
4
  import { Modal, Text, TouchableOpacity, View } from "react-native";
@@ -19,7 +20,7 @@ import { DeepPartial } from "../../shared/helper/types";
19
20
  import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
20
21
  import { SafeAreaView } from "react-native-safe-area-context";
21
22
 
22
- const listenerId = "callListener_" + new Date().getTime();
23
+ const listenerId = "callListener_" + Date.now() + "_" + (++__listenerIdCounter);
23
24
  const CometChatCalls = CallingPackage.CometChatCalls;
24
25
 
25
26
  /**
@@ -53,9 +53,9 @@ export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator
53
53
  }
54
54
 
55
55
  if (
56
- conversation.getLastMessage().getType() == ExtensionTypeConstants.document &&
57
- conversation.getLastMessage().getCategory() == MessageCategoryConstants.custom &&
58
- conversation.getLastMessage().getDeletedAt() === undefined
56
+ conversation.getLastMessage()?.getType() == ExtensionTypeConstants.document &&
57
+ conversation.getLastMessage()?.getCategory() == MessageCategoryConstants.custom &&
58
+ conversation.getLastMessage()?.getDeletedAt() === undefined
59
59
  ) {
60
60
  return getMessagePreviewInternal(
61
61
  "collaborative-document-fill",
@@ -253,7 +253,7 @@ export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator
253
253
  let url: string = documentData.document_url;
254
254
 
255
255
  const _style =
256
- message.getSender().getUid() === loggedInUser!.getUid()
256
+ message.getSender()?.getUid() === loggedInUser?.getUid()
257
257
  ? theme.messageListStyles.outgoingMessageBubbleStyles?.collaborativeBubbleStyles
258
258
  : theme.messageListStyles.incomingMessageBubbleStyles?.collaborativeBubbleStyles;
259
259
 
@@ -36,7 +36,7 @@ const t = getCometChatTranslation();
36
36
  export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorator {
37
37
  whiteboardUrl: string = "v1/create";
38
38
 
39
- loggedInUser!: CometChat.User;
39
+ loggedInUser: CometChat.User | null = null;
40
40
 
41
41
  /**
42
42
  * Creates an instance of CollaborativeWhiteboardExtensionDecorator.
@@ -48,7 +48,9 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
48
48
 
49
49
  CometChat.getLoggedinUser()
50
50
  .then((u) => {
51
- this.loggedInUser = u!;
51
+ if (u) {
52
+ this.loggedInUser = u;
53
+ }
52
54
  })
53
55
  .catch((err) => console.log(err));
54
56
  }
@@ -330,7 +332,7 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
330
332
  const username = this.loggedInUser?.getName()?.replace(" ", "_");
331
333
  const url: string = whiteboardData.board_url + "&username=" + username;
332
334
  const _style =
333
- message.getSender().getUid() === loggedInUser!.getUid()
335
+ message.getSender()?.getUid() === loggedInUser?.getUid()
334
336
  ? theme.messageListStyles.outgoingMessageBubbleStyles?.collaborativeBubbleStyles
335
337
  : theme.messageListStyles.incomingMessageBubbleStyles?.collaborativeBubbleStyles;
336
338
 
@@ -65,7 +65,7 @@ export class LinkPreviewExtensionDecorator extends DataSourceDecorator {
65
65
  return super.getTextMessageContentView(message, alignment, theme, additionalParams);
66
66
  } else {
67
67
  const _style: DeepPartial<BubbleStyles["linkPreviewBubbleStyles"]> =
68
- message.getSender().getUid() === loggedInUser!.getUid()
68
+ message.getSender()?.getUid() === loggedInUser?.getUid()
69
69
  ? theme.messageListStyles?.outgoingMessageBubbleStyles?.linkPreviewBubbleStyles
70
70
  : theme.messageListStyles?.incomingMessageBubbleStyles?.linkPreviewBubbleStyles;
71
71
  const { image, favicon, title, url, description } = linkData.links[0];
@@ -294,7 +294,7 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
294
294
  let textFormatters = [...(additionalParams?.textFormatters || [])];
295
295
 
296
296
  // Determine if the message was sent by the logged-in user.
297
- const isMessageSentByLoggedInUser = message.getSender().getUid() === loggedInUser!.getUid();
297
+ const isMessageSentByLoggedInUser = message.getSender()?.getUid() === loggedInUser?.getUid();
298
298
 
299
299
  // Select the appropriate style based on the sender.
300
300
  const _style: Partial<CometChatTheme["textBubbleStyles"]> = isMessageSentByLoggedInUser
@@ -304,9 +304,9 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
304
304
  .textBubbleStyles as CometChatTheme["textBubbleStyles"]);
305
305
 
306
306
  // Create URL formatter and set properties.
307
- let linksTextFormatter = ChatConfigurator.getDataSource().getUrlsFormatter(loggedInUser!);
307
+ let linksTextFormatter = ChatConfigurator.getDataSource().getUrlsFormatter(loggedInUser);
308
308
  let mentionsTextFormatter = ChatConfigurator.getDataSource().getMentionsFormatter(
309
- loggedInUser!,
309
+ loggedInUser,
310
310
  theme
311
311
  );
312
312
  linksTextFormatter.setMessage(message);
@@ -319,7 +319,7 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
319
319
 
320
320
  // Configure mentions formatter if mentioned users are present.
321
321
  if (!additionalParams?.disableMentions && mentionedUsers && mentionedUsers.length) {
322
- mentionsTextFormatter.setLoggedInUser(loggedInUser!);
322
+ mentionsTextFormatter.setLoggedInUser(loggedInUser);
323
323
  mentionsTextFormatter.setMessage(message);
324
324
  mentionsTextFormatter.setId("ccDefaultMentionFormatterId");
325
325
  }
@@ -337,7 +337,7 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator {
337
337
  mentionsFormatterExists = true;
338
338
  formatter.setMessage(message);
339
339
  formatter.setTargetElement(MentionsTargetElement.textbubble);
340
- formatter.setLoggedInUser(CometChatUIKit.loggedInUser!);
340
+ formatter.setLoggedInUser(CometChatUIKit.loggedInUser);
341
341
  formatter.setContext(isMessageSentByLoggedInUser ? "outgoing" : "incoming");
342
342
  }
343
343
  formatter.setMessage(message);
@@ -193,7 +193,7 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
193
193
  */
194
194
  const handleResult = (id: string) => {
195
195
  let newOptionsMetaData = { ...optionsMetaData };
196
- if (newOptionsMetaData.results?.options[id]?.["voters"]?.[loggedInUser!.getUid()]) return;
196
+ if (newOptionsMetaData.results?.options[id]?.["voters"]?.[loggedInUser?.getUid()]) return;
197
197
  // Set the loading option id here
198
198
  setLoadingOption(id);
199
199
  setIsLoading(true);
@@ -245,7 +245,7 @@ export class PollsExtensionDecorator extends DataSourceDecorator {
245
245
  if (message && _loggedInUser) {
246
246
  const metaData = getExtensionData(message, MetadataConstants.extensions?.polls);
247
247
  const _style =
248
- message.getSender().getUid() === _loggedInUser.getUid()
248
+ message.getSender()?.getUid() === _loggedInUser.getUid()
249
249
  ? theme.messageListStyles.outgoingMessageBubbleStyles?.pollBubbleStyles
250
250
  : theme.messageListStyles.incomingMessageBubbleStyles?.pollBubbleStyles;
251
251
 
@@ -131,7 +131,7 @@ const StickerButton = ({ user, group, id, stickerIconStyle, stickerIcon, replyTo
131
131
  customMessage.setCategory(CometChat.CATEGORY_CUSTOM as CometChat.MessageCategory);
132
132
  customMessage.setParentMessageId(parentId);
133
133
  customMessage.setMuid(String(getUnixTimestampInMilliseconds()));
134
- customMessage.setSender(loggedInUser.current!);
134
+ customMessage.setSender(loggedInUser.current);
135
135
  customMessage.setReceiver(user || group);
136
136
  customMessage.shouldUpdateConversation(true);
137
137
  customMessage.setMetadata({ incrementUnreadCount: true });
@@ -333,7 +333,7 @@ export class StickersExtensionDecorator extends DataSourceDecorator {
333
333
  message?.["data"]?.["customData"]?.["sticker_url"];
334
334
  let loggedInUser = CometChatUIKit.loggedInUser;
335
335
  const _style =
336
- message.getSender().getUid() === loggedInUser!.getUid()
336
+ message.getSender()?.getUid() === loggedInUser?.getUid()
337
337
  ? theme.messageListStyles.outgoingMessageBubbleStyles
338
338
  : theme.messageListStyles.incomingMessageBubbleStyles;
339
339
  return (
@@ -58,8 +58,12 @@ export class ThumbnailGenerationExtensionDecorator extends DataSourceDecorator {
58
58
  if (attachmentData.length) {
59
59
  const dataObj = attachmentData[0];
60
60
  if (!dataObj["error"]) {
61
- const imageLink = dataObj?.["data"]?.["thumbnails"]?.["url_small"];
62
- image = imageLink ? { uri: dataObj["data"]["thumbnails"]["url_small"] } : image;
61
+ const thumbnails = dataObj?.["data"]?.["thumbnails"] ?? {};
62
+ const imageLink =
63
+ thumbnails["url_large"] ??
64
+ thumbnails["url_medium"] ??
65
+ thumbnails["url_small"];
66
+ image = imageLink ? { uri: imageLink } : image;
63
67
  }
64
68
  }
65
69
  }
@@ -85,7 +89,7 @@ export class ThumbnailGenerationExtensionDecorator extends DataSourceDecorator {
85
89
  const image = this.checkThumbnail(message);
86
90
  const loggedInUser = CometChatUIKit.loggedInUser;
87
91
  const _style =
88
- message.getSender().getUid() === loggedInUser!.getUid()
92
+ message.getSender()?.getUid() === loggedInUser?.getUid()
89
93
  ? theme.messageListStyles.outgoingMessageBubbleStyles?.videoBubbleStyles
90
94
  : theme.messageListStyles.incomingMessageBubbleStyles?.videoBubbleStyles;
91
95
  return (
@@ -118,9 +122,9 @@ export class ThumbnailGenerationExtensionDecorator extends DataSourceDecorator {
118
122
  theme: CometChatTheme
119
123
  ): JSX.Element {
120
124
  const image = this.checkThumbnail(message);
121
- const loggedInUser = CometChatUIKit.loggedInUser!;
125
+ const loggedInUser = CometChatUIKit.loggedInUser;
122
126
  const _style =
123
- message.getSender().getUid() === loggedInUser.getUid()
127
+ message.getSender()?.getUid() === loggedInUser?.getUid()
124
128
  ? theme.messageListStyles.outgoingMessageBubbleStyles?.imageBubbleStyles
125
129
  : theme.messageListStyles.incomingMessageBubbleStyles?.imageBubbleStyles;
126
130
  return (
package/src/index.ts CHANGED
@@ -111,6 +111,11 @@ import {
111
111
  ConversationInterface
112
112
  } from "./CometChatConversations";
113
113
 
114
+ import {
115
+ CometChatNotificationFeed,
116
+ CometChatNotificationFeedInterface,
117
+ } from "./CometChatNotificationFeed";
118
+
114
119
  import { CometChatGroupMembers, CometChatGroupMembersInterface } from "./CometChatGroupMembers";
115
120
 
116
121
  import {
@@ -213,6 +218,7 @@ export {
213
218
  //
214
219
  CometChatConversationUtils,
215
220
  CometChatConversations,
221
+ CometChatNotificationFeed,
216
222
  CometChatCreatePoll,
217
223
  CometChatDate,
218
224
  /* Reactions */
@@ -361,6 +367,7 @@ export type {
361
367
  CometChatUsersInterface,
362
368
  CometChatVideoBubbleInterface,
363
369
  ConversationInterface,
370
+ CometChatNotificationFeedInterface,
364
371
  LinkPreviewBubbleInterface,
365
372
  PollsConfigurationInterface,
366
373
  RecorderState,
@@ -51,29 +51,27 @@ export class CometChatUIKit {
51
51
  async() => {
52
52
  CometChat.setSource("uikit-v5", Platform.OS, "react-native");
53
53
  ListenerInitializer.attachListeners();
54
- await CometChat.getLoggedinUser()
55
- .then((user: any) => {
56
- CometChatUIKit.setLoggedInUser(user);
57
- if (user) {
58
- this.enableExtensions();
54
+ try {
55
+ const user = await CometChat.getLoggedinUser();
56
+ CometChatUIKit.setLoggedInUser(user);
57
+ if (user) {
58
+ this.enableExtensions();
59
+ }
60
+ const conversationUpdateSettings = await CometChat.getConversationUpdateSettings();
61
+ CometChatUIKit.setConversationUpdateSettings(conversationUpdateSettings);
62
+ permissionUtil.init().then((res) => {
63
+ if (res !== true) {
64
+ console.warn("[IOS] Permission initialization failed.");
59
65
  }
60
- CometChat.getConversationUpdateSettings().then(
61
- (conversationUpdateSettings: CometChat.ConversationUpdateSettings) => {
62
- CometChatUIKit.setConversationUpdateSettings(conversationUpdateSettings);
63
- }
64
- );
65
- permissionUtil.init().then((res) => {
66
- if (res !== true) {
67
- console.warn("[IOS] Permission initialization failed.");
68
- }
69
- });
70
- })
71
- .catch((error: any) => {
72
- // CometChatUIKit.setLoggedInUser(null);
73
66
  });
67
+ } catch (error) {
68
+ CometChatUIKit.setLoggedInUser(null);
69
+ console.warn("[CometChatUIKit] Failed to restore session:", error);
70
+ }
74
71
  },
75
72
  (error: any) => {
76
- // console.log("Initialization failed with error:", error);
73
+ console.error("[CometChatUIKit] SDK initialization failed:", error);
74
+ throw error;
77
75
  }
78
76
  );
79
77
  }
@@ -112,6 +110,26 @@ export class CometChatUIKit {
112
110
  },
113
111
  })
114
112
  );
113
+
114
+ // Re-fetch conversation update settings on every websocket reconnection
115
+ // This ensures dashboard setting changes are picked up without requiring a metro reload
116
+ CometChat.addConnectionListener(
117
+ "__CometChatUIKit_ConnectionListener__",
118
+ new CometChat.ConnectionListener({
119
+ onConnected: () => {
120
+ CometChat.getConversationUpdateSettings().then(
121
+ (conversationUpdateSettings: CometChat.ConversationUpdateSettings) => {
122
+ CometChatUIKit.setConversationUpdateSettings(conversationUpdateSettings);
123
+ }
124
+ ).catch(() => {
125
+ // Silently ignore — will retry on next reconnection
126
+ });
127
+ },
128
+ inConnecting: () => {},
129
+ onDisconnected: () => {},
130
+ })
131
+ );
132
+
115
133
  CometChatUIKit.isLoginListenerAttached = true;
116
134
  }
117
135
 
@@ -175,6 +193,7 @@ export class CometChatUIKit {
175
193
  private static removeListener() {
176
194
  if (CometChatUIKit.isLoginListenerAttached) {
177
195
  CometChat.removeLoginListener(CometChatUIKit.loginListenerID);
196
+ CometChat.removeConnectionListener("__CometChatUIKit_ConnectionListener__");
178
197
  CometChatUIKit.isLoginListenerAttached = false;
179
198
  CometChatUIKit.loginListenerID = ``;
180
199
  }
@@ -214,9 +233,18 @@ export class CometChatUIKit {
214
233
 
215
234
  static logout(): Promise<Object> {
216
235
  if (this.checkAuthSettings(Promise.reject)) {
236
+ return Promise.reject(
237
+ new CometChat.CometChatException({
238
+ code: "ERR",
239
+ message: "UIKit not initialized. Call CometChatUIKit.init() first.",
240
+ })
241
+ );
217
242
  }
218
243
 
219
- return CometChat.logout();
244
+ return CometChat.logout().then(() => {
245
+ CometChatUIKit.loggedInUser = null;
246
+ return {};
247
+ });
220
248
  }
221
249
 
222
250
  static createUser(user: CometChat.User): Promise<CometChat.User> {
@@ -1,3 +1,4 @@
1
+ let __listenerIdCounter = 0;
1
2
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
3
  import { MessageTypeConstants } from "../constants/UIKitConstants";
3
4
  import { CometChatUIEventHandler } from "./CometChatUIEventHandler/CometChatUIEventHandler";
@@ -6,7 +7,7 @@ import * as CometChatUIKitConstants from '../constants/UIKitConstants';
6
7
 
7
8
  export class ListenerInitializer {
8
9
  private static messageListenerId = `ListenerInitializer_listener`;
9
- static streamListenerId: string = "agent_" + new Date().getTime();
10
+ static streamListenerId: string = "agent_" + Date.now() + "_" + (++__listenerIdCounter);
10
11
 
11
12
  public static attachListeners(user?: CometChat.User) {
12
13
  CometChat.addMessageListener(this.messageListenerId, this.getMessageListenerObject());