@cometchat/chat-uikit-react-native 5.0.1 → 5.1.0

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 (132) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/7.4/gc.properties +0 -0
  5. package/android/.gradle/vcs-1/gc.properties +0 -0
  6. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +87 -41
  7. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +10 -0
  8. package/ios/SoundPlayer.m +8 -0
  9. package/lib/CometChatMessageList/CometChatMessageList.js +1 -1
  10. package/lib/CometChatMessageList/CometChatMessageList.js.map +1 -1
  11. package/lib/extensions/Stickers/StickersExtensionDecorator.d.ts +1 -2
  12. package/lib/extensions/Stickers/StickersExtensionDecorator.js +1 -2
  13. package/lib/extensions/Stickers/StickersExtensionDecorator.js.map +1 -1
  14. package/lib/shared/CometChatUiKit/CometChatUIKit.d.ts +2 -1
  15. package/lib/shared/CometChatUiKit/CometChatUIKit.js +2 -1
  16. package/lib/shared/CometChatUiKit/CometChatUIKit.js.map +1 -1
  17. package/lib/shared/index.d.ts +15 -13
  18. package/lib/shared/index.js +30 -12
  19. package/lib/shared/index.js.map +1 -1
  20. package/lib/shared/utils/CometChatMessagePreview/CometChatMessagePreview.d.ts +10 -1
  21. package/lib/shared/utils/CometChatMessagePreview/CometChatMessagePreview.js +8 -0
  22. package/lib/shared/utils/CometChatMessagePreview/CometChatMessagePreview.js.map +1 -1
  23. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.d.ts +29 -0
  24. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js +29 -0
  25. package/lib/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js.map +1 -0
  26. package/lib/shared/utils/CometChatMessagePreview/index.d.ts +2 -1
  27. package/lib/shared/utils/CometChatMessagePreview/index.js +3 -1
  28. package/lib/shared/utils/CometChatMessagePreview/index.js.map +1 -1
  29. package/lib/shared/utils/CometChatMessagePreview/style.d.ts +16 -16
  30. package/lib/shared/utils/MessageUtils.js +11 -10
  31. package/lib/shared/utils/MessageUtils.js.map +1 -1
  32. package/lib/shared/utils/index.d.ts +2 -2
  33. package/lib/shared/utils/index.js +2 -2
  34. package/lib/shared/utils/index.js.map +1 -1
  35. package/lib/theme/context.js +1 -1
  36. package/lib/theme/context.js.map +1 -1
  37. package/lib/theme/default/index.d.ts +6 -0
  38. package/lib/theme/default/index.js +178 -0
  39. package/lib/theme/default/index.js.map +1 -1
  40. package/lib/theme/provider.js +1 -1
  41. package/lib/theme/provider.js.map +1 -1
  42. package/package.json +6 -4
  43. package/react-native-cometchat-ui-kit.podspec +1 -1
  44. package/src/CometChatConversations/CometChatConversations.tsx +34 -29
  45. package/src/CometChatConversations/style.ts +5 -2
  46. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +56 -44
  47. package/src/CometChatGroups/CometChatGroups.tsx +13 -10
  48. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +203 -57
  49. package/src/CometChatMessageComposer/styles.tsx +2 -6
  50. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +8 -48
  51. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -14
  52. package/src/CometChatMessageList/CometChatMessageList.tsx +18 -10
  53. package/src/CometChatMessageList/style.ts +0 -16
  54. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +3 -2
  55. package/src/CometChatUsers/CometChatUsers.tsx +9 -8
  56. package/src/calls/CallUtils.ts +14 -14
  57. package/src/calls/CallingExtensionDecorator.tsx +13 -12
  58. package/src/calls/CometChatCallBubble/CometChatCallBubble.tsx +4 -3
  59. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +15 -12
  60. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +8 -6
  61. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +4 -2
  62. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +7 -6
  63. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +7 -6
  64. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +3 -2
  65. package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +3 -2
  66. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +26 -17
  67. package/src/extensions/Polls/Polls.tsx +53 -17
  68. package/src/extensions/Polls/PollsDecorator.tsx +5 -3
  69. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +5 -4
  70. package/src/extensions/Stickers/CometChatStickerKeyboard/hooks.ts +3 -2
  71. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +5 -2
  72. package/src/index.ts +10 -4
  73. package/src/shared/CometChatUiKit/CometChatUIKit.ts +1 -2
  74. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +116 -32
  75. package/src/shared/framework/DataSource.ts +5 -2
  76. package/src/shared/framework/DataSourceDecorator.tsx +4 -4
  77. package/src/shared/framework/MessageDataSource.tsx +178 -46
  78. package/src/shared/helper/LocalizedDateHelper.ts +317 -0
  79. package/src/shared/helper/functions.js +69 -1
  80. package/src/shared/helper/useLocalizedDateHook.tsx +16 -0
  81. package/src/shared/index.ts +7 -2
  82. package/src/shared/resources/CometChatLocalizeNew/CometChatI18nProvider.tsx +106 -0
  83. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +99 -0
  84. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizeContext.tsx +15 -0
  85. package/src/shared/resources/CometChatLocalizeNew/LocalizationManager.ts +65 -0
  86. package/src/shared/resources/CometChatLocalizeNew/index.ts +25 -0
  87. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/de/translation.json +10 -1
  88. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/en/translation.json +10 -1
  89. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/es/translation.json +10 -1
  90. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/fr/translation.json +10 -1
  91. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/hi/translation.json +11 -1
  92. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/hu/translation.json +10 -1
  93. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +456 -0
  94. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +456 -0
  95. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +456 -0
  96. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/lt/translation.json +10 -1
  97. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/ms/translation.json +10 -1
  98. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +456 -0
  99. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/pt/translation.json +10 -1
  100. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/ru/translation.json +10 -1
  101. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/sv/translation.json +11 -1
  102. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +456 -0
  103. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/zh/translation.json +11 -1
  104. package/src/shared/resources/{CometChatLocalize → CometChatLocalizeNew}/resources/zh-tw/translation.json +10 -1
  105. package/src/shared/resources/CometChatLocalizeNew/type.ts +7 -0
  106. package/src/shared/resources/CometChatLocalizeNew/useCometChatTranslationHook.ts +24 -0
  107. package/src/shared/resources/index.ts +2 -2
  108. package/src/shared/utils/CommonUtils.ts +2 -1
  109. package/src/shared/utils/PermissionUtil.ts +5 -4
  110. package/src/shared/utils/conversationUtils.ts +11 -9
  111. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +8 -5
  112. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +1 -1
  113. package/src/shared/views/CometChatDate/CometChatDate.tsx +17 -14
  114. package/src/shared/views/CometChatDateSeperator/CometChatDateSeparator.tsx +6 -4
  115. package/src/shared/views/CometChatDeletedBubble/CometChatDeletedBubble.tsx +3 -2
  116. package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +11 -8
  117. package/src/shared/views/CometChatList/CometChatList.tsx +5 -4
  118. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +15 -9
  119. package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +5 -4
  120. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -2
  121. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +7 -6
  122. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +10 -7
  123. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +1 -0
  124. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +24 -47
  125. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +68 -73
  126. package/src/theme/type.ts +0 -2
  127. package/lib/theme/default/default.d.ts +0 -6
  128. package/lib/theme/default/default.js +0 -179
  129. package/lib/theme/default/default.js.map +0 -1
  130. package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +0 -183
  131. package/src/shared/resources/CometChatLocalize/index.ts +0 -3
  132. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +0 -447
@@ -18,7 +18,7 @@ import { AnimatedAudioWaves } from "./AnimatedAudioWaves";
18
18
  const { SoundPlayer } = NativeModules;
19
19
  const eventEmitter = new NativeEventEmitter(SoundPlayer);
20
20
  let listener: EmitterSubscription;
21
- let interval: NodeJS.Timeout;
21
+ let interval: ReturnType<typeof setTimeout>;;
22
22
 
23
23
  export interface CometChatAudioBubbleInterface {
24
24
  /**
@@ -70,22 +70,24 @@ export const CometChatAudioBubble = ({
70
70
  }
71
71
 
72
72
  return () => {
73
- Platform.OS == "android" && SoundPlayer.releaseMediaPlayer();
73
+ SoundPlayer.releaseMediaPlayer();
74
74
  };
75
75
  }, [audioUrl]);
76
76
 
77
77
  useEffect(() => {
78
78
  listener = eventEmitter.addListener("soundPlayStatus", (data) => {
79
79
  if (audioUrl === data.url) {
80
- setStatus("paused");
80
+ setStatus("");
81
+
81
82
  clearInterval(interval);
82
- setCurrentTime(duration);
83
+
84
+ setCurrentTime(0);
83
85
  }
84
86
  });
85
87
 
86
88
  return () => {
87
89
  listener.remove();
88
- clearInterval(interval);
90
+ clearInterval(interval);
89
91
  };
90
92
  }, [audioUrl]);
91
93
 
@@ -231,3 +233,4 @@ export const CometChatAudioBubble = ({
231
233
  </View>
232
234
  );
233
235
  };
236
+ // CometChatAudioBubble
@@ -168,7 +168,7 @@ const CometChatBottomSheet = forwardRef(
168
168
  flex: 1,
169
169
  backgroundColor: overlayAnim.interpolate({
170
170
  inputRange: [0, 0.2],
171
- outputRange: ["rgba(0,0,0,0)", "rgba(0,0,0,0.2)"],
171
+ outputRange: ["rgba(0,0,0,0)", "rgba(0,0,0,0.35)"],
172
172
  }),
173
173
  }}
174
174
  onStartShouldSetResponder={() => {
@@ -2,7 +2,8 @@ import React, { useMemo } from "react";
2
2
  import { Text, View } from "react-native";
3
3
  import { useTheme } from "../../../theme";
4
4
  import { useCompTheme } from "../../../theme/hook";
5
- import { DateHelper, dateHelperInstance } from "../../helper/dateHelper";
5
+ import { LocalizedDateHelper } from "./../../helper/LocalizedDateHelper";
6
+ import { useLocalizedDate } from "./../../helper/useLocalizedDateHook";
6
7
  import { deepMerge } from "../../helper/helperFunctions";
7
8
  import { ValueOf } from "../../helper/types";
8
9
  import { DateStyle } from "./styles";
@@ -12,17 +13,17 @@ import { DateStyle } from "./styles";
12
13
  */
13
14
  export interface CometChatDateInterface {
14
15
  /**
15
- * Unix epoch time to be formatted and displayed.
16
- */
16
+ * Unix epoch time to be formatted and displayed.
17
+ */
17
18
  timeStamp?: number;
18
19
  /**
19
- * Pattern for formatting the date.
20
- * One of the following values:
21
- * - timeFormat: "hh:mm a".
22
- * - dayDateFormat: Today, Yesterday, week-day or "d MMM, yyyy".
23
- * - dayWeekDayDateTimeFormat: Today, Yesterday, week-day or "dd/mm/yyyy".
24
- */
25
- pattern?: ValueOf<typeof DateHelper.patterns>;
20
+ * Pattern for formatting the date.
21
+ * One of the following values:
22
+ * - timeFormat: "hh:mm a".
23
+ * - dayDateFormat: Today, Yesterday, week-day or "d MMM, yyyy".
24
+ * - dayWeekDayDateTimeFormat: Today, Yesterday, week-day or "dd/mm/yyyy".
25
+ */
26
+ pattern?: ValueOf<typeof LocalizedDateHelper.patterns>;
26
27
  /**
27
28
  * A custom date string to override the formatted date.
28
29
  */
@@ -46,6 +47,8 @@ export const CometChatDate = (props: CometChatDateInterface) => {
46
47
  const { timeStamp, pattern, customDateString, style = {} } = props;
47
48
  const theme = useTheme();
48
49
  const compTheme = useCompTheme();
50
+ const { formatDate } = useLocalizedDate();
51
+ if (!timeStamp) return null;
49
52
 
50
53
  // Merge theme date styles with component date styles and any custom style overrides.
51
54
  const dateStyles = useMemo(() => {
@@ -56,10 +59,10 @@ export const CometChatDate = (props: CometChatDateInterface) => {
56
59
  <View style={[dateStyles.containerStyle]}>
57
60
  <Text style={[dateStyles.textStyle]} numberOfLines={1}>
58
61
  {timeStamp
59
- ? customDateString
60
- ? customDateString
61
- : pattern && dateHelperInstance.getFormattedDate(timeStamp, pattern)
62
- : ""}
62
+ ? customDateString
63
+ ? customDateString
64
+ : pattern && formatDate(timeStamp, pattern)
65
+ : ""}
63
66
  </Text>
64
67
  </View>
65
68
  );
@@ -1,9 +1,10 @@
1
1
  import React from "react";
2
2
  import { Text, View } from "react-native";
3
3
  import { useTheme } from "../../../theme";
4
- import { DateHelper, dateHelperInstance } from "../../helper/dateHelper";
4
+ import { LocalizedDateHelper } from "../../helper/LocalizedDateHelper";
5
5
  import { ValueOf } from "../../helper/types";
6
6
  import { CometChatTheme } from "../../../theme/type";
7
+ import { useLocalizedDate } from "./../../helper/useLocalizedDateHook";
7
8
 
8
9
  /**
9
10
  * Props for the CometChatDateSeparator component.
@@ -20,7 +21,7 @@ export interface CometChatDateSeparatorInterface {
20
21
  * - dayDateFormat: Today, Yesterday, or "d MMM, yyyy"
21
22
  * - dayWeekDayDateTimeFormat: Today (time), weekday, Yesterday, or "dd/mm/yyyy"
22
23
  */
23
- pattern: ValueOf<typeof DateHelper.patterns>;
24
+ pattern: ValueOf<typeof LocalizedDateHelper.patterns>;
24
25
  /**
25
26
  * Custom string to be displayed instead of the formatted date.
26
27
  */
@@ -34,20 +35,21 @@ export interface CometChatDateSeparatorInterface {
34
35
  /**
35
36
  * CometChatDateSeparator is a component that displays a formatted date/time separator
36
37
  * between messages. If a custom date string is provided, it will be displayed instead.
37
- *
38
+ *
38
39
  * - Props for the component.
39
40
  * The rendered date separator view.
40
41
  */
41
42
  export const CometChatDateSeparator = (props: CometChatDateSeparatorInterface) => {
42
43
  const { timeStamp, pattern, customDateString, style } = props;
43
44
  const theme = useTheme();
45
+ const { formatDate } = useLocalizedDate();
44
46
 
45
47
  return (
46
48
  <View style={[theme.dateSeparatorStyles.containerStyle, style?.containerStyle]}>
47
49
  <Text style={[theme.dateSeparatorStyles.textStyle, style?.textStyle]}>
48
50
  {customDateString
49
51
  ? customDateString
50
- : dateHelperInstance.getFormattedDate(timeStamp, pattern)}
52
+ : formatDate(timeStamp, pattern)}
51
53
  </Text>
52
54
  </View>
53
55
  );
@@ -2,9 +2,9 @@ import React from "react";
2
2
  import { View } from "react-native";
3
3
  import { useTheme } from "../../../theme";
4
4
  import { Icon } from "../../icons/Icon";
5
- import { localize } from "../../resources";
6
5
  import { CometChatTextBubbleText } from "../CometChatTextBubble/CometChatTextBubble";
7
6
  import { DeletedBubbleStyle } from "./styles";
7
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
8
8
 
9
9
  /**
10
10
  * Props for the CometChatDeletedBubble component.
@@ -29,7 +29,8 @@ export interface CometChatDeletedBubbleInterface {
29
29
  */
30
30
  export const CometChatDeletedBubble = (props: CometChatDeletedBubbleInterface) => {
31
31
  const theme = useTheme();
32
- const { text = localize("DELETE_MSG_TEXT"), style = {} } = props;
32
+ const {t}=useCometChatTranslation()
33
+ const { text = t("DELETE_MSG_TEXT"), style = {} } = props;
33
34
 
34
35
  return (
35
36
  <View
@@ -1,8 +1,11 @@
1
+ import { getCometChatTranslation } from "../../../shared";
2
+ const t = getCometChatTranslation();
3
+
1
4
  export const Emojis = [
2
5
  {
3
6
  people: {
4
7
  id: "people",
5
- name: "Smiley & People",
8
+ name: t("SMILEY_PEOPLE"),
6
9
  symbol: "Smileys",
7
10
  emojis: {
8
11
  grinning: {
@@ -1701,7 +1704,7 @@ export const Emojis = [
1701
1704
  {
1702
1705
  animals: {
1703
1706
  id: "animals_and_nature",
1704
- name: "Animals & Nature",
1707
+ name: t("ANIMALES_NATURE"),
1705
1708
  symbol: "Animals",
1706
1709
  emojis: {
1707
1710
  dog: {
@@ -2464,7 +2467,7 @@ export const Emojis = [
2464
2467
  {
2465
2468
  food: {
2466
2469
  id: "food_and_drink",
2467
- name: "Food & Drink",
2470
+ name: t("FOOD_DRINK"),
2468
2471
  symbol: "Food",
2469
2472
  emojis: {
2470
2473
  green_apple: {
@@ -2947,7 +2950,7 @@ export const Emojis = [
2947
2950
  {
2948
2951
  activity: {
2949
2952
  id: "activity",
2950
- name: "Activity",
2953
+ name: t("ACTIVITY"),
2951
2954
  symbol: "Activity",
2952
2955
  emojis: {
2953
2956
  soccer: {
@@ -3377,7 +3380,7 @@ export const Emojis = [
3377
3380
  {
3378
3381
  travel: {
3379
3382
  id: "travel_and_places",
3380
- name: "Travel & Places",
3383
+ name: t("TRAVEL_PLACES"),
3381
3384
  symbol: "Travel",
3382
3385
  emojis: {
3383
3386
  red_car: {
@@ -3873,7 +3876,7 @@ export const Emojis = [
3873
3876
  {
3874
3877
  objects: {
3875
3878
  id: "objects",
3876
- name: "Objects",
3879
+ name: t("OBJECTS"),
3877
3880
  symbol: "Objects",
3878
3881
  emojis: {
3879
3882
  watch: {
@@ -4768,7 +4771,7 @@ export const Emojis = [
4768
4771
  {
4769
4772
  symbols: {
4770
4773
  id: "symbols",
4771
- name: "Symbols",
4774
+ name: t("SYMBOLS"),
4772
4775
  symbol: "Symbols",
4773
4776
  emojis: {
4774
4777
  heart: {
@@ -5928,7 +5931,7 @@ export const Emojis = [
5928
5931
  {
5929
5932
  flags: {
5930
5933
  id: "flags",
5931
- name: "Flags",
5934
+ name: t("FLAGS"),
5932
5935
  symbol: "Flags",
5933
5936
  emojis: {
5934
5937
  afghanistan: {
@@ -13,7 +13,6 @@ import {
13
13
  ViewStyle,
14
14
  } from "react-native";
15
15
  import { LOADING, NO_DATA_FOUND, SOMETHING_WRONG } from "../../constants/UIKitConstants";
16
- import { localize } from "../../resources/CometChatLocalize";
17
16
 
18
17
  import { CometChat } from "@cometchat/chat-sdk-react-native";
19
18
  import { useTheme } from "../../../theme";
@@ -28,6 +27,7 @@ import {
28
27
  } from "../CometChatStatusIndicator";
29
28
  import Header from "./Header";
30
29
  import styles from "./styles";
30
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
31
31
 
32
32
  export interface CometChatListActionsInterface {
33
33
  updateList: (prop: any) => void;
@@ -152,6 +152,7 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
152
152
  (props, ref) => {
153
153
  const connectionListenerId = "connectionListener_" + new Date().getTime();
154
154
  const theme = useTheme();
155
+ const {t}= useCometChatTranslation()
155
156
  const [isLoadingMore, setIsLoadingMore] = useState(false);
156
157
  const [hasMoreData, setHasMoreData] = useState(true);
157
158
 
@@ -171,8 +172,8 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
171
172
  hideSearch = false,
172
173
  title = "Title",
173
174
  EmptyView,
174
- emptyStateText = localize("NO_USERS_FOUND"),
175
- errorStateText = localize("SOMETHING_WRONG"),
175
+ emptyStateText = t("NO_USERS_FOUND"),
176
+ errorStateText = t("SOMETHING_WRONG"),
176
177
  ErrorView,
177
178
  LoadingView,
178
179
  requestBuilder,
@@ -560,7 +561,7 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
560
561
  item.value.uid &&
561
562
  item.value.uid === CometChatUIKit.loggedInUser!.getUid() &&
562
563
  item.value.name === CometChatUIKit.loggedInUser!.getName()
563
- ? localize("YOU")
564
+ ? t("YOU")
564
565
  : item.value.name
565
566
  }
566
567
  containerStyle={[listStyle?.itemStyle?.containerStyle]}
@@ -17,8 +17,8 @@ import { AnimatedAudioWaves } from "../../CometChatAudioBubble/AnimatedAudioWave
17
17
 
18
18
  const { SoundPlayer } = NativeModules;
19
19
  const eventEmitter = new NativeEventEmitter(SoundPlayer);
20
- let listener: EmitterSubscription;
21
- let interval: NodeJS.Timeout;
20
+ let listener: EmitterSubscription | undefined;
21
+ let interval: ReturnType<typeof setTimeout>;
22
22
 
23
23
  export interface CometChatAudioBubbleInterface {
24
24
  /**
@@ -65,26 +65,32 @@ export const CometChatAudioPreview = ({
65
65
  useEffect(() => {
66
66
  if (audioUrl) {
67
67
  SoundPlayer.prepareMediaPlayer(audioUrl, (s: string) => {
68
- setDuration(JSON.parse(s).duration);
68
+ try {
69
+ setDuration(JSON.parse(s).duration);
70
+ } catch (e) {
71
+ console.log("prepareMediaPlayer parse error", e);
72
+ }
69
73
  });
70
74
  }
71
75
 
76
+ // release player on unmount (all platforms) — keeps behaviour consistent with AudioBubble
72
77
  return () => {
73
- Platform.OS == "android" && SoundPlayer.releaseMediaPlayer();
78
+ SoundPlayer.releaseMediaPlayer();
74
79
  };
75
80
  }, [audioUrl]);
76
81
 
77
82
  useEffect(() => {
78
83
  listener = eventEmitter.addListener("soundPlayStatus", (data) => {
79
84
  if (audioUrl === data.url) {
80
- setStatus("paused");
85
+ // playback ended for this url — reset to idle, clear interval and reset time
86
+ setStatus("");
81
87
  clearInterval(interval);
82
- setCurrentTime(duration);
88
+ setCurrentTime(0);
83
89
  }
84
90
  });
85
91
 
86
92
  return () => {
87
- listener.remove();
93
+ listener?.remove();
88
94
  clearInterval(interval);
89
95
  };
90
96
  }, [audioUrl]);
@@ -114,7 +120,7 @@ export const CometChatAudioPreview = ({
114
120
  if (Platform.OS == "ios") {
115
121
  setStatus("playing");
116
122
  }
117
- // Get total duration when audio starts playing
123
+ // Get total duration/position when resume
118
124
  SoundPlayer.getPosition((info: string) => {
119
125
  if (info) {
120
126
  if (Platform.OS == "android") {
@@ -166,7 +172,7 @@ export const CometChatAudioPreview = ({
166
172
  }
167
173
  };
168
174
 
169
- const pressTime = useRef<number|null>(0);
175
+ const pressTime = useRef<number | null>(0);
170
176
 
171
177
  const handleTouchStart = () => {
172
178
  pressTime.current = Date.now();
@@ -9,7 +9,6 @@ import {
9
9
  TouchableOpacity,
10
10
  View,
11
11
  } from "react-native";
12
- import { localize } from "../..";
13
12
  import { useTheme } from "../../../theme";
14
13
  import { Icon } from "../../icons/Icon";
15
14
  import { AnimatingMic } from "./AnimatingMic";
@@ -17,6 +16,7 @@ import { Timer } from "./Timer";
17
16
  import { CometChatAudioPreview } from "./CometChatAudioPreview/CometChatAudioPreview";
18
17
  import { CometChatTheme } from "../../../theme/type";
19
18
  import { deepMerge } from "../../helper/helperFunctions";
19
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
20
20
 
21
21
  export interface CometChatMediaRecorderInterface {
22
22
  onClose?: Function;
@@ -41,6 +41,7 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
41
41
  });
42
42
 
43
43
  const theme = useTheme();
44
+ const {t}=useCometChatTranslation()
44
45
  const mergedStyle = useMemo(() => {
45
46
  return deepMerge(theme.mediaRecorderStyle, style ?? {});
46
47
  }, [theme, style]);
@@ -73,14 +74,14 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
73
74
  }
74
75
 
75
76
  function permissionAlert() {
76
- Alert.alert('', localize("MICROPHONE_PERMISSION"), [
77
+ Alert.alert('', t("MICROPHONE_PERMISSION"), [
77
78
  {
78
79
  style: "cancel",
79
- text: localize("CANCEL"),
80
+ text: t("CANCEL"),
80
81
  },
81
82
  {
82
83
  style: "default",
83
- text: localize("SETTINGS"),
84
+ text: t("SETTINGS"),
84
85
  onPress: () => {
85
86
  Linking.openSettings();
86
87
  },
@@ -9,10 +9,10 @@ import {
9
9
  ViewStyle,
10
10
  } from "react-native";
11
11
  import { useTheme } from "../../../theme";
12
- import { localize } from "../../resources/CometChatLocalize";
13
12
  import { CometChatTheme } from "../../../theme/type";
14
13
  import { CometChatUIEventHandler, CometChatUIEvents } from "../../events";
15
14
  import { ViewAlignment } from "../../constants/UIKitConstants";
15
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
16
16
 
17
17
  /**
18
18
  * Props for the CometChatMessageInput component.
@@ -99,9 +99,10 @@ export interface CometChatMessageInputInterface {
99
99
  */
100
100
  export const CometChatMessageInput = (props: CometChatMessageInputInterface) => {
101
101
  const theme = useTheme();
102
+ const {t}= useCometChatTranslation()
102
103
  const {
103
104
  text = "",
104
- placeHolderText = localize("ENTER_YOUR_MESSAGE_HERE"),
105
+ placeHolderText = t("ENTER_YOUR_MESSAGE_HERE"),
105
106
  onChangeText,
106
107
  style,
107
108
  SecondaryButtonView,
@@ -9,7 +9,6 @@ import {
9
9
  TouchableOpacity,
10
10
  View,
11
11
  } from "react-native";
12
- import { localize } from "../../resources";
13
12
  import { CommonUtils } from "../../utils/CommonUtils";
14
13
  import { CometChatListItem } from "../CometChatListItem";
15
14
  import { useTheme } from "../../../theme";
@@ -18,6 +17,7 @@ import { ErrorEmptyView } from "../ErrorEmptyView/ErrorEmptyView";
18
17
  import { Icon } from "../../icons/Icon";
19
18
  import { CometChatUIEventHandler, MessageEvents } from "../../events";
20
19
  import { messageStatus } from "../../utils/CometChatMessageHelper";
20
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
21
21
 
22
22
  /**
23
23
  * Props for the CometChatReactionList component.
@@ -76,6 +76,7 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
76
76
  onListEmpty,
77
77
  } = props;
78
78
  const theme = useTheme();
79
+ const {t} =useCometChatTranslation()
79
80
  const reactionListStyleFromTheme = theme.reactionListStyles.reactionListItemStyle;
80
81
  const tabStyleFromTheme = theme.reactionListStyles.tabStyle;
81
82
 
@@ -333,14 +334,14 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
333
334
  const subtitleView = useCallback((item: any) => {
334
335
  let reactedByMe = loggedInUser.current!.getUid() === item?.reactedBy?.uid;
335
336
  return reactedByMe ? (
336
- <Text style={reactionListStyleFromTheme.subtitleStyle}>{localize("TAP_TO_REMOVE")}</Text>
337
+ <Text style={reactionListStyleFromTheme.subtitleStyle}>{t("TAP_TO_REMOVE")}</Text>
337
338
  ) : null;
338
339
  }, []);
339
340
 
340
341
  const _render = ({ item, index }: { item: any; index: number }) => {
341
342
  function getName() {
342
343
  let reactedByMe = loggedInUser.current!.getUid() === item?.reactedBy?.uid;
343
- return reactedByMe ? localize("YOU") : item?.reactedBy?.name;
344
+ return reactedByMe ? t("YOU") : item?.reactedBy?.name;
344
345
  }
345
346
 
346
347
  return (
@@ -377,8 +378,8 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
377
378
  return (
378
379
  <ErrorEmptyView
379
380
  title={errorStateText ?? "Oops!"}
380
- subTitle={localize("SOMETHING_WENT_WRONG")}
381
- tertiaryTitle={localize("WRONG_TEXT_TRY_AGAIN")}
381
+ subTitle={t("SOMETHING_WENT_WRONG")}
382
+ tertiaryTitle={t("WRONG_TEXT_TRY_AGAIN")}
382
383
  Icon={
383
384
  <Icon
384
385
  name='error-state'
@@ -444,7 +445,7 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
444
445
  }
445
446
  >
446
447
  {reactionObject?.getReaction() === "All"
447
- ? localize("ALL")
448
+ ? t("ALL")
448
449
  : reactionObject?.getReaction()}
449
450
  </Text>
450
451
  <Text
@@ -13,7 +13,7 @@ import {
13
13
  CometChatTextFormatter,
14
14
  CometChatUrlsFormatter,
15
15
  } from "../../formatters";
16
- import { localize } from "../../resources";
16
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
17
17
 
18
18
  export interface CometChatTextBubbleInterface {
19
19
  /**
@@ -42,6 +42,7 @@ export const CometChatTextBubble = (props: CometChatTextBubbleInterface) => {
42
42
  export const CometChatTextBubbleText = (
43
43
  props: Omit<CometChatTextBubbleInterface, "textContainerStyle">
44
44
  ) => {
45
+ const {t}= useCometChatTranslation()
45
46
  const { text = "", textFormatters, textStyle } = props;
46
47
  const [formattedText, setFormattedText] = useState<string>("");
47
48
  // This flag will be set if the text exceeds 4 lines in collapsed mode.
@@ -60,18 +61,19 @@ export const CometChatTextBubbleText = (
60
61
  }
61
62
  }
62
63
  setFormattedText(finalText);
63
- // Reset the truncated flag when text changes.
64
- setIsTruncated(false);
64
+ // Don't reset the truncated flag when text is the same, only when text actually changes
65
+ // This preserves the expanded state when messages are updated for reactions, etc.
65
66
  }, [text, textFormatters]);
66
67
 
67
68
  // For Android, onTextLayout reliably provides the number of lines.
68
69
  const handleTextLayout = (event: any) => {
69
70
  const { lines } = event.nativeEvent;
70
71
  if (lines.length > 4) {
72
+ // Only set to true, never reset to false when a message is updated
73
+ // This preserves the truncated state when the message is updated (e.g., reactions added)
71
74
  setIsTruncated(true);
72
- } else {
73
- setIsTruncated(false);
74
75
  }
76
+ // We no longer set isTruncated to false here to preserve state during updates
75
77
  };
76
78
 
77
79
  // onLayout callback for the collapsed text (iOS)
@@ -95,7 +97,8 @@ export const CometChatTextBubbleText = (
95
97
  return (
96
98
  <View>
97
99
  <Text
98
- key={expanded ? "expanded" : "collapsed"} // Force re-render when expanded toggles
100
+ // Use text content in the key to ensure it only re-renders when text changes
101
+ key={`${expanded ? "expanded" : "collapsed"}-${text}`}
99
102
  style={textStyle}
100
103
  // Android uses onTextLayout for measuring lines.
101
104
  onTextLayout={Platform.OS !== "ios" ? handleTextLayout : undefined}
@@ -122,7 +125,7 @@ export const CometChatTextBubbleText = (
122
125
  <View style={{ alignItems: "flex-end", marginTop: 8 }}>
123
126
  <TouchableOpacity onPress={() => setExpanded(!expanded)}>
124
127
  <Text style={textStyle}>
125
- {expanded ? localize("SHOW_LESS") : localize("READ_MORE")}
128
+ {expanded ? t("SHOW_LESS") : t("READ_MORE")}
126
129
  </Text>
127
130
  </TouchableOpacity>
128
131
  </View>
@@ -23,6 +23,7 @@ const { width: screenWidth, height: screenHeight } = Dimensions.get("window");
23
23
  */
24
24
  export interface MenuItemInterface {
25
25
  text: string;
26
+ translationKey?: string; // for localization
26
27
  onPress: () => void;
27
28
  icon?: ImageSourcePropType | JSX.Element;
28
29
  textStyle?: TextStyle;
@@ -1,4 +1,4 @@
1
- import React, {JSX, useEffect, useRef, useState } from "react";
1
+ import React, { JSX, useEffect, useState } from "react";
2
2
  import {
3
3
  ActivityIndicator,
4
4
  EmitterSubscription,
@@ -7,7 +7,6 @@ import {
7
7
  ImageStyle,
8
8
  NativeEventEmitter,
9
9
  NativeModules,
10
- Platform,
11
10
  Pressable,
12
11
  View,
13
12
  ViewStyle,
@@ -76,7 +75,7 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => {
76
75
  playIcon,
77
76
  playIconStyle,
78
77
  onPress,
79
- playIconContainerStyle,
78
+ playIconContainerStyle = {},
80
79
  imageStyle,
81
80
  } = props;
82
81
 
@@ -130,27 +129,6 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => {
130
129
  };
131
130
  }, []);
132
131
 
133
- const pressTime = useRef<number | null>(0);
134
-
135
- // const handleTouchStart = () => {
136
- // pressTime.current = Date.now();
137
- // };
138
-
139
- // const handleTouchEnd = () => {
140
- // if (pressTime.current === null && Platform.OS === "ios") return;
141
- // const endTime = Date.now();
142
- // const pressDuration = endTime - pressTime.current!;
143
- // if (pressDuration < 500) {
144
- // playVideo();
145
- // }
146
- // };
147
-
148
- // const onTouchMove = () => {
149
- // if (Platform.OS === "ios") {
150
- // pressTime.current = null;
151
- // }
152
- // };
153
-
154
132
  return (
155
133
  <>
156
134
  <CometChatVideoPlayer
@@ -163,29 +141,28 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => {
163
141
  onLoad={() => setIsLoading(false)}
164
142
  />
165
143
  <ImageBackground source={imageSource} resizeMode={"cover"} style={imageStyle}>
166
- <Pressable
167
- onPress={() => playVideo()}
168
- style={{ height: "100%", width: "100%", alignItems: "center", justifyContent: "center" }}
169
- >
170
- <View>
171
- {isLoading ? (
172
- <ActivityIndicator
173
- size={typeof playIconStyle?.height === "number" ? playIconStyle.height : "large"}
174
- color={playIconStyle?.tintColor}
175
- />
176
- ) : (
177
- <Icon
178
- name='play-arrow-fill'
179
- height={playIconStyle?.height}
180
- width={playIconStyle?.width}
181
- icon={playIcon}
182
- imageStyle={playIconStyle}
183
- color={playIconStyle?.tintColor}
184
- ></Icon>
185
- )}
186
- </View>
187
- </Pressable>
144
+ <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
145
+ <Pressable onPress={() => playVideo()} style={playIconContainerStyle} hitSlop={12}>
146
+ <View>
147
+ {isLoading ? (
148
+ <ActivityIndicator
149
+ size={typeof playIconStyle?.height === "number" ? playIconStyle.height : "large"}
150
+ color={playIconStyle?.tintColor}
151
+ />
152
+ ) : (
153
+ <Icon
154
+ name='play-arrow-fill'
155
+ height={playIconStyle?.height}
156
+ width={playIconStyle?.width}
157
+ icon={playIcon}
158
+ imageStyle={playIconStyle}
159
+ color={playIconStyle?.tintColor}
160
+ ></Icon>
161
+ )}
162
+ </View>
163
+ </Pressable>
164
+ </View>
188
165
  </ImageBackground>
189
166
  </>
190
167
  );
191
- };
168
+ };