@cometchat/chat-uikit-react-native 5.2.8 → 5.2.9

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 (49) hide show
  1. package/package.json +1 -1
  2. package/src/CometChatConversations/CometChatConversations.tsx +8 -1
  3. package/src/CometChatGroups/CometChatGroups.tsx +5 -3
  4. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +55 -8
  5. package/src/CometChatMessageList/CometChatMessageList.tsx +1169 -548
  6. package/src/CometChatMessageList/components/MessageListItem.tsx +127 -0
  7. package/src/CometChatMessageList/components/MessageModals.tsx +60 -0
  8. package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +130 -0
  9. package/src/CometChatMessageList/components/ReactionModals.tsx +70 -0
  10. package/src/CometChatUsers/CometChatUsers.tsx +4 -1
  11. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +27 -36
  12. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +13 -9
  13. package/src/shared/base/Types.ts +1 -0
  14. package/src/shared/constants/UIKitConstants.ts +1 -0
  15. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +4 -0
  16. package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -1
  17. package/src/shared/events/conversations.ts +1 -0
  18. package/src/shared/framework/MessageDataSource.tsx +79 -17
  19. package/src/shared/index.ts +2 -0
  20. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +3 -1
  21. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +3 -1
  22. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +3 -1
  23. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +3 -1
  24. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +3 -1
  25. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +3 -1
  26. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +3 -1
  27. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +3 -1
  28. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +3 -1
  29. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +3 -1
  30. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +3 -1
  31. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +3 -1
  32. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +3 -1
  33. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +3 -1
  34. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +3 -1
  35. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +3 -1
  36. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +3 -1
  37. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +3 -1
  38. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +7 -4
  39. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +20 -12
  40. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +6 -3
  41. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +2 -1
  42. package/src/shared/views/CometChatList/CometChatList.tsx +20 -1
  43. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +2 -3
  44. package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +55 -0
  45. package/src/shared/views/CometChatNewMessageIndicator/index.ts +3 -0
  46. package/src/shared/views/CometChatNewMessageIndicator/styles.ts +33 -0
  47. package/src/shared/views/CometChatRetryButton/CometChatRetryButton.tsx +54 -0
  48. package/src/shared/views/CometChatRetryButton/index.ts +3 -0
  49. package/src/shared/views/index.ts +15 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "5.2.8",
3
+ "version": "5.2.9",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
@@ -19,6 +19,7 @@ import {
19
19
  CometChatList,
20
20
  CometChatListActionsInterface,
21
21
  CometChatMentionsFormatter,
22
+ CometChatRetryButton,
22
23
  CometChatSoundManager,
23
24
  CometChatStatusIndicator,
24
25
  CometChatTextFormatter,
@@ -358,6 +359,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
358
359
  * ErrorStateView renders a view to show when an error occurs.
359
360
  */
360
361
  const ErrorStateView = useCallback(() => {
362
+ if (hideError) return null;
361
363
  return (
362
364
  <ErrorEmptyView
363
365
  title={t("OOPS")}
@@ -378,9 +380,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
378
380
  containerStyle={mergedStyles?.errorStateStyle?.containerStyle}
379
381
  titleStyle={mergedStyles?.errorStateStyle?.titleStyle}
380
382
  subTitleStyle={mergedStyles?.errorStateStyle?.subTitleStyle}
383
+ RetryView={<CometChatRetryButton onPress={() => conversationListRef.current?.reload()} />}
381
384
  />
382
385
  );
383
- }, [theme, mergedStyles]);
386
+ }, [theme, mergedStyles, hideError]);
384
387
 
385
388
  /**
386
389
  * EmptyStateView renders a view when no conversations are available.
@@ -1266,6 +1269,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
1266
1269
  conversationListRef.current!.removeItemFromList(conversation.getConversationId());
1267
1270
  removeItemFromSelectionList(conversation.getConversationId());
1268
1271
  },
1272
+ // Handle conversation updates from external sources (e.g., when conversation properties change)
1273
+ ccUpdateConversation: ({ conversation }: { conversation: CometChat.Conversation }) => {
1274
+ conversationListRef.current!.updateList(conversation);
1275
+ },
1269
1276
  });
1270
1277
  // Listen for message events.
1271
1278
  CometChatUIEventHandler.addMessageListener(messageListenerId, {
@@ -1,7 +1,7 @@
1
1
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
2
  import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
3
- import { ColorValue, ImageSourcePropType, Text, View } from "react-native";
4
- import { CometChatList, CometChatListActionsInterface } from "../shared";
3
+ import { ImageSourcePropType, Text, View } from "react-native";
4
+ import { CometChatList, CometChatListActionsInterface, CometChatRetryButton } from "../shared";
5
5
  import { SelectionMode } from "../shared/base/Types";
6
6
  import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
7
7
  import { deepMerge } from "../shared/helper/helperFunctions";
@@ -293,6 +293,7 @@ export const CometChatGroups = React.forwardRef((props: CometChatGroupsInterface
293
293
  useEffect(() => {
294
294
  setHideSearchError(true); // Hide search while showing error
295
295
  }, []);
296
+ if (hideError) return null;
296
297
  return (
297
298
  <View style={{ flex: 1 }}>
298
299
  <ErrorEmptyView
@@ -317,10 +318,11 @@ export const CometChatGroups = React.forwardRef((props: CometChatGroupsInterface
317
318
  }}
318
319
  titleStyle={mergedStyle.errorStateStyle.titleStyle}
319
320
  subTitleStyle={mergedStyle.errorStateStyle.subTitleStyle}
321
+ RetryView={<CometChatRetryButton onPress={() => groupListRef.current?.reload()} />}
320
322
  />
321
323
  </View>
322
324
  );
323
- }, [mergedStyle, mode, theme]);
325
+ }, [mergedStyle, mode, theme, hideError]);
324
326
 
325
327
  /**
326
328
  * Build final list of menu items for a given group:
@@ -581,7 +581,9 @@ export const CometChatMessageComposer = React.forwardRef(
581
581
  const [plainText, setPlainText] = React.useState(initialComposertext ?? "");
582
582
  const bottomSheetRef = React.useRef<any>(null);
583
583
  const [showStopButton, setShowStopButton] = React.useState(false);
584
-
584
+ const [isSendButtonDisabledForDelay, setIsSendButtonDisabledForDelay] = React.useState(false);
585
+ const sendButtonDelayTimer = React.useRef<NodeJS.Timeout | null>(null);
586
+
585
587
  const closeReplyPreview = useCallback(() => {
586
588
  setReplyMessage(null);
587
589
  }, []);
@@ -604,6 +606,13 @@ export const CometChatMessageComposer = React.forwardRef(
604
606
  useEffect(() => {
605
607
  setShowStopButton(false);
606
608
  setIsStreaming(false);
609
+
610
+ // Cleanup function to clear the delay timer on unmount
611
+ return () => {
612
+ if (sendButtonDelayTimer.current) {
613
+ clearTimeout(sendButtonDelayTimer.current);
614
+ }
615
+ };
607
616
  }, []);
608
617
 
609
618
  useLayoutEffect(() => {
@@ -869,7 +878,24 @@ export const CometChatMessageComposer = React.forwardRef(
869
878
  return;
870
879
  }
871
880
 
872
- let finalTextInput = getRegexString(plainTextInput.current);
881
+ if (Platform.OS === "ios" && messageInputRef.current) {
882
+ InteractionManager.runAfterInteractions(() => {
883
+ let textToProcess = plainTextInput.current;
884
+ if (typeof inputMessage === 'string' && inputMessage.trim().length > 0) {
885
+ textToProcess = inputMessage;
886
+ }
887
+
888
+ processAndSendMessage(textToProcess);
889
+ });
890
+ return; // Exit early, processAndSendMessage will handle sending
891
+ }
892
+
893
+ // For non-iOS platforms, proceed normally
894
+ processAndSendMessage(plainTextInput.current);
895
+ };
896
+
897
+ const processAndSendMessage = (textToProcess: string) => {
898
+ let finalTextInput = getRegexString(textToProcess);
873
899
  let trimmedTextInput = finalTextInput.trim();
874
900
 
875
901
  if (trimmedTextInput.trim().length === 0) {
@@ -926,6 +952,18 @@ export const CometChatMessageComposer = React.forwardRef(
926
952
  setWarningMessage("");
927
953
  setReplyMessage(null);
928
954
 
955
+ // Clear the TextInput on iOS to remove auto-corrected text
956
+ if (Platform.OS === "ios" && messageInputRef.current) {
957
+ InteractionManager.runAfterInteractions(() => {
958
+ try {
959
+ messageInputRef.current?.setNativeProps?.({ text: "" });
960
+ messageInputRef.current?.clear?.();
961
+ } catch (error) {
962
+ // Ignore errors when clearing
963
+ }
964
+ });
965
+ }
966
+
929
967
  if (onSendButtonPress) {
930
968
  onSendButtonPress(textMessage);
931
969
  return;
@@ -938,6 +976,17 @@ export const CometChatMessageComposer = React.forwardRef(
938
976
 
939
977
  if (!disableSoundForOutgoingMessages) playAudio();
940
978
 
979
+ // Enable 1-second delay for agentic users
980
+ if (isAgenticUser()) {
981
+ setIsSendButtonDisabledForDelay(true);
982
+ if (sendButtonDelayTimer.current) {
983
+ clearTimeout(sendButtonDelayTimer.current);
984
+ }
985
+ sendButtonDelayTimer.current = setTimeout(() => {
986
+ setIsSendButtonDisabledForDelay(false);
987
+ }, 1000);
988
+ }
989
+
941
990
  CometChat.sendMessage(textMessage)
942
991
  .then((message: any) => {
943
992
  if (isAgenticUser() && !parentMessageId && message?.getId) {
@@ -1285,7 +1334,7 @@ export const CometChatMessageComposer = React.forwardRef(
1285
1334
  const isAgenticUserCheck = isAgenticUser();
1286
1335
 
1287
1336
  if (isAgenticUserCheck) {
1288
- const disabled = isStreaming || plainText.trim().length === 0 || (messagePreview && !hasEdited);
1337
+ const disabled = isStreaming || plainTextInput.current.trim().length === 0|| (messagePreview && !hasEdited) || isSendButtonDisabledForDelay;
1289
1338
  const SendButtonComponent = DefaultAgentSendButtonView;
1290
1339
  // Create a ref-like object that matches what CometChatSendButtonView expects
1291
1340
  const composerRef = {
@@ -1328,7 +1377,7 @@ export const CometChatMessageComposer = React.forwardRef(
1328
1377
  />
1329
1378
  </TouchableOpacity>
1330
1379
  );
1331
- }, [mergedComposerStyle, inputMessage, plainText, messagePreview, hasEdited, isStreaming, DefaultAgentSendButtonView, user, isAgenticUser, sendTextMessage, hideSendButton, SendButtonView]);
1380
+ }, [mergedComposerStyle, inputMessage, plainText, messagePreview, hasEdited, isStreaming, DefaultAgentSendButtonView, user, isAgenticUser, sendTextMessage, hideSendButton, SendButtonView, isSendButtonDisabledForDelay]);
1332
1381
 
1333
1382
  //fetch logged in user
1334
1383
  useEffect(() => {
@@ -1890,9 +1939,7 @@ export const CometChatMessageComposer = React.forwardRef(
1890
1939
  let decr = 0;
1891
1940
 
1892
1941
  plainTextInput.current = newText;
1893
- if (!(oldText.length > newText.length)) {
1894
- setPlainText(newText);
1895
- }
1942
+ setPlainText(newText);
1896
1943
 
1897
1944
  const newMentionMap: Map<string, SuggestionItem> = new Map(mentionMap.current);
1898
1945
 
@@ -2314,7 +2361,7 @@ export const CometChatMessageComposer = React.forwardRef(
2314
2361
  return;
2315
2362
  }
2316
2363
  }
2317
-
2364
+
2318
2365
  setSelectionPosition(selection);
2319
2366
  openList(selection);
2320
2367
  }}