@cometchat/chat-uikit-react-native 5.2.8 → 5.2.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 (55) hide show
  1. package/package.json +2 -2
  2. package/src/CometChatConversations/CometChatConversations.tsx +8 -1
  3. package/src/CometChatGroups/CometChatGroups.tsx +5 -3
  4. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +78 -18
  5. package/src/CometChatMessageList/CometChatMessageList.tsx +1181 -577
  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/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +71 -14
  19. package/src/shared/framework/MessageDataSource.tsx +79 -17
  20. package/src/shared/index.ts +2 -0
  21. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +3 -1
  22. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +3 -1
  23. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +3 -1
  24. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +3 -1
  25. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +3 -1
  26. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +3 -1
  27. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +3 -1
  28. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +3 -1
  29. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +3 -1
  30. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +3 -1
  31. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +3 -1
  32. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +3 -1
  33. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +3 -1
  34. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +3 -1
  35. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +3 -1
  36. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +3 -1
  37. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +3 -1
  38. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +3 -1
  39. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +7 -4
  40. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +20 -12
  41. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +6 -3
  42. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +2 -1
  43. package/src/shared/views/CometChatList/CometChatList.tsx +20 -1
  44. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +1 -1
  45. package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +55 -0
  46. package/src/shared/views/CometChatNewMessageIndicator/index.ts +3 -0
  47. package/src/shared/views/CometChatNewMessageIndicator/styles.ts +33 -0
  48. package/src/shared/views/CometChatRetryButton/CometChatRetryButton.tsx +54 -0
  49. package/src/shared/views/CometChatRetryButton/index.ts +3 -0
  50. package/src/shared/views/index.ts +15 -0
  51. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  52. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  53. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  54. package/android/.gradle/7.4/gc.properties +0 -0
  55. package/android/.gradle/vcs-1/gc.properties +0 -0
@@ -65,7 +65,9 @@ export const CometChatAudioBubble = ({
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) {}
69
71
  });
70
72
  }
71
73
 
@@ -118,20 +120,24 @@ export const CometChatAudioBubble = ({
118
120
  }
119
121
  // Get total duration when audio starts playing
120
122
  SoundPlayer.getPosition((info: string) => {
121
- if (info) {
122
- if (Platform.OS == "android") {
123
- setStatus("playing");
123
+ try {
124
+ if (info) {
125
+ if (Platform.OS == "android") {
126
+ setStatus("playing");
127
+ }
128
+ setCurrentTime(JSON.parse(info).position);
124
129
  }
125
- setCurrentTime(JSON.parse(info).position);
126
- }
130
+ } catch (e) {}
127
131
  });
128
132
 
129
133
  // Start tracking the current time
130
134
  interval = setInterval(() => {
131
135
  SoundPlayer.getPosition((info: string) => {
132
- if (info) {
133
- setCurrentTime(JSON.parse(info).position);
134
- }
136
+ try {
137
+ if (info) {
138
+ setCurrentTime(JSON.parse(info).position);
139
+ }
140
+ } catch (e) {}
135
141
  });
136
142
  }, 500);
137
143
  return;
@@ -145,9 +151,11 @@ export const CometChatAudioBubble = ({
145
151
  setStatus("playing");
146
152
  // Get total duration when audio starts playing
147
153
  SoundPlayer.getPosition((info: string) => {
148
- if (info) {
149
- setCurrentTime(JSON.parse(info).position);
150
- }
154
+ try {
155
+ if (info) {
156
+ setCurrentTime(JSON.parse(info).position);
157
+ }
158
+ } catch (e) {}
151
159
  });
152
160
 
153
161
  // Start tracking the current time
@@ -1,5 +1,5 @@
1
1
  import React, { useMemo } from "react";
2
- import { Text, View } from "react-native";
2
+ import { Text, View, Dimensions } from "react-native";
3
3
  import { useTheme } from "../../../theme";
4
4
  import { deepMerge } from "../../helper/helperFunctions";
5
5
  import { BadgeStyle } from "./styles";
@@ -49,9 +49,12 @@ export const CometChatBadge = (props: CometChatBadgeProps) => {
49
49
  // If count is zero or an empty string, do not render the badge.
50
50
  if (countText.length === 0) return null;
51
51
 
52
+ const fontScale = Dimensions.get('window').fontScale;
53
+ const badgeSize = 25 * fontScale;
54
+
52
55
  return (
53
- <View style={[badgeStyle.containerStyle]}>
54
- <Text style={[badgeStyle.textStyle]}>{countText}</Text>
56
+ <View style={[badgeStyle.containerStyle, { width: badgeSize, height: badgeSize }]}>
57
+ <Text style={[badgeStyle.textStyle]} numberOfLines={1} adjustsFontSizeToFit={true}>{countText}</Text>
55
58
  </View>
56
59
  );
57
60
  };
@@ -91,7 +91,7 @@ const CometChatBottomSheet = forwardRef(
91
91
  onDismiss,
92
92
  } = props;
93
93
 
94
- // Animated value for overlay fade
94
+ // All hooks called unconditionally at top level
95
95
  const overlayAnim = useRef(new Animated.Value(0)).current;
96
96
  const [isModalOpen, setIsModalOpen] = useState(isOpen);
97
97
 
@@ -161,6 +161,7 @@ const CometChatBottomSheet = forwardRef(
161
161
  visible={isModalOpen}
162
162
  onRequestClose={togglePanel}
163
163
  onDismiss={onDismiss}
164
+ supportedOrientations={["portrait", "landscape"]}
164
165
  >
165
166
  {/* Animated overlay that fades in from transparent to a semi-transparent black */}
166
167
  <Animated.View
@@ -38,6 +38,7 @@ export interface CometChatListActionsInterface {
38
38
  getListItem: (itemId: string | number) => any;
39
39
  getSelectedItems: () => Array<any>;
40
40
  getAllListItems: () => Array<any>;
41
+ reload: () => void;
41
42
  }
42
43
 
43
44
  export interface CometChatListStylesInterface {
@@ -212,6 +213,7 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
212
213
  updateAndMoveToFirst,
213
214
  getSelectedItems,
214
215
  getAllListItems,
216
+ reload,
215
217
  };
216
218
  });
217
219
 
@@ -491,7 +493,7 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
491
493
  if (newlist.length === 0) setHasMoreData(false);
492
494
  }
493
495
 
494
- // If we *did* get results but less than a full “page”, also stop further loads
496
+ // If we *did* get results but less than a full "page", also stop further loads
495
497
  if (newlist.length === 0) setHasMoreData(false);
496
498
 
497
499
  props.onListFetched?.(finalList);
@@ -508,6 +510,23 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
508
510
  });
509
511
  };
510
512
 
513
+ /**
514
+ * Reloads the list by fetching fresh data (matches Calls tab behavior)
515
+ */
516
+ const reload = () => {
517
+ // Prevent multiple reloads if a load operation is already in progress
518
+ if (isLoadingMore) return;
519
+
520
+ setDataLoadingStatus(LOADING);
521
+ setHasMoreData(true);
522
+ if (requestBuilder) {
523
+ if (searchInputRef.current)
524
+ listHandlerRef.current = requestBuilder.setSearchKeyword(searchInputRef.current).build();
525
+ else listHandlerRef.current = requestBuilder.build();
526
+ }
527
+ handleList(true);
528
+ };
529
+
511
530
  const renderFooter = useCallback(() => {
512
531
  if (!isLoadingMore || !hasMoreData) return null;
513
532
  return (
@@ -105,7 +105,7 @@ export interface CometChatMessageInputInterface {
105
105
  */
106
106
  export const CometChatMessageInput = (props: CometChatMessageInputInterface) => {
107
107
  const theme = useTheme();
108
- const {t}= useCometChatTranslation()
108
+ const { t } = useCometChatTranslation()
109
109
  const {
110
110
  text = "",
111
111
  placeHolderText = t("ENTER_YOUR_MESSAGE_HERE"),
@@ -0,0 +1,55 @@
1
+ import React, { useMemo } from "react";
2
+ import { Text, View } from "react-native";
3
+ import { useTheme } from "../../../theme";
4
+ import { deepMerge } from "../../helper/helperFunctions";
5
+ import { NewMessageIndicatorStyle, getNewMessageIndicatorStyle } from "./styles";
6
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
7
+
8
+ /**
9
+ * Props for the CometChatNewMessageIndicator component.
10
+ */
11
+ export interface CometChatNewMessageIndicatorInterface {
12
+ /**
13
+ * Custom styles for the new message indicator component.
14
+ */
15
+ style?: NewMessageIndicatorStyle;
16
+ /**
17
+ * Text to display in the indicator.
18
+ * Default: "New Messages"
19
+ */
20
+ text?: string;
21
+ /**
22
+ * Custom component to render instead of the default indicator.
23
+ */
24
+ NewMessageIndicatorView?: React.ComponentType<any>;
25
+ }
26
+
27
+ /**
28
+ * CometChatNewMessageIndicator is a component for displaying a "New Messages" separator.
29
+ *
30
+ * It renders a horizontal line with a text label in the center.
31
+ * The component is fully customizable via styles or by providing a custom view.
32
+ */
33
+ export const CometChatNewMessageIndicator = React.memo((props: CometChatNewMessageIndicatorInterface) => {
34
+ const { style = {}, text, NewMessageIndicatorView } = props;
35
+ const theme = useTheme();
36
+ const { t } = useCometChatTranslation();
37
+
38
+ // Merge default styles with any custom style overrides.
39
+ const indicatorStyles = useMemo(() => {
40
+ const defaultStyles = getNewMessageIndicatorStyle(theme);
41
+ return deepMerge(defaultStyles, style);
42
+ }, [theme, style]);
43
+
44
+ if (NewMessageIndicatorView) {
45
+ return <NewMessageIndicatorView {...props} />;
46
+ }
47
+
48
+ return (
49
+ <View style={indicatorStyles.containerStyle}>
50
+ <View style={indicatorStyles.lineStyle} />
51
+ <Text style={indicatorStyles.textStyle} numberOfLines={1}>{text || t("NEW")}</Text>
52
+ <View style={indicatorStyles.lineStyle} />
53
+ </View>
54
+ );
55
+ });
@@ -0,0 +1,3 @@
1
+ export { CometChatNewMessageIndicator } from "./CometChatNewMessageIndicator";
2
+ export type { CometChatNewMessageIndicatorInterface } from "./CometChatNewMessageIndicator";
3
+ export type { NewMessageIndicatorStyle } from "./styles";
@@ -0,0 +1,33 @@
1
+ import { StyleSheet, TextStyle, ViewStyle } from "react-native";
2
+ import { CometChatTheme } from "../../../theme/type";
3
+
4
+ export type NewMessageIndicatorStyle = {
5
+ containerStyle?: ViewStyle;
6
+ textStyle?: TextStyle;
7
+ lineStyle?: ViewStyle;
8
+ };
9
+
10
+ export const getNewMessageIndicatorStyle = (
11
+ theme: CometChatTheme
12
+ ): NewMessageIndicatorStyle => {
13
+ return StyleSheet.create({
14
+ containerStyle: {
15
+ flexDirection: "row",
16
+ alignItems: "center",
17
+ justifyContent: "center",
18
+ marginVertical: 8,
19
+ width: "100%",
20
+ },
21
+ textStyle: {
22
+ color: theme.color.error,
23
+ ...theme.typography.caption1.medium,
24
+ marginHorizontal: 8,
25
+ },
26
+ lineStyle: {
27
+ flex: 1,
28
+ height: 1,
29
+ backgroundColor: theme.color.error,
30
+ opacity: 0.5,
31
+ },
32
+ });
33
+ };
@@ -0,0 +1,54 @@
1
+ import React from "react";
2
+ import { Text, TouchableOpacity } from "react-native";
3
+ import { useTheme } from "../../../theme";
4
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
5
+
6
+ /**
7
+ * Props for the CometChatRetryButton component.
8
+ */
9
+ export interface CometChatRetryButtonProps {
10
+ /**
11
+ * Callback function to execute when the retry button is pressed.
12
+ */
13
+ onPress: () => void;
14
+ }
15
+
16
+ /**
17
+ * CometChatRetryButton is a reusable component that renders a styled retry button.
18
+ * It is commonly used in error states to allow users to retry failed operations.
19
+ *
20
+ * @param props - The props for the component.
21
+ * @returns The rendered retry button element.
22
+ */
23
+ export const CometChatRetryButton = (props: CometChatRetryButtonProps) => {
24
+ const { onPress } = props;
25
+ const theme = useTheme();
26
+ const { t } = useCometChatTranslation();
27
+
28
+ const retryText = t("RETRY");
29
+
30
+ return (
31
+ <TouchableOpacity
32
+ onPress={onPress}
33
+ accessibilityRole='button'
34
+ accessibilityLabel={retryText}
35
+ style={{
36
+ backgroundColor: theme.color.primary,
37
+ paddingVertical: theme.spacing.spacing.s3,
38
+ paddingHorizontal: theme.spacing.spacing.s10,
39
+ borderRadius: theme.spacing.radius.r2,
40
+ marginTop: theme.spacing.spacing.s5,
41
+ }}
42
+ >
43
+ <Text
44
+ style={{
45
+ color: theme.color.primaryButtonIcon,
46
+ ...theme.typography.button.medium,
47
+ }}
48
+ >
49
+ {retryText}
50
+ </Text>
51
+ </TouchableOpacity>
52
+ );
53
+ };
54
+
@@ -0,0 +1,3 @@
1
+ export { CometChatRetryButton } from "./CometChatRetryButton";
2
+ export type { CometChatRetryButtonProps } from "./CometChatRetryButton";
3
+
@@ -70,6 +70,10 @@ import {
70
70
  CometChatReactions,
71
71
  CometChatReactionsInterface,
72
72
  } from "./CometChatReactions";
73
+ import {
74
+ CometChatRetryButton,
75
+ CometChatRetryButtonProps,
76
+ } from "./CometChatRetryButton";
73
77
 
74
78
  import { CometChatEmojiKeyboard } from "./CometChatEmojiKeyboard";
75
79
 
@@ -86,6 +90,12 @@ import {
86
90
  CometChatReportDialogInterface,
87
91
  } from "./CometChatReportDialog";
88
92
 
93
+ import {
94
+ CometChatNewMessageIndicator,
95
+ CometChatNewMessageIndicatorInterface,
96
+ NewMessageIndicatorStyle,
97
+ } from "./CometChatNewMessageIndicator";
98
+
89
99
  export type {
90
100
  CometChatConfirmDialogInterface,
91
101
  CometChatReportDialogInterface,
@@ -102,10 +112,12 @@ export type {
102
112
  CometChatMessageInputInterface,
103
113
  CometChatReactionListInterface,
104
114
  CometChatReactionsInterface,
115
+ CometChatRetryButtonProps,
105
116
  CometChatStatusIndicatorInterface,
106
117
  CometChatSuggestionListInterface,
107
118
  CometChatVideoBubbleInterface,
108
119
  CometChatTextBubbleInterface,
120
+ CometChatNewMessageIndicatorInterface,
109
121
  };
110
122
 
111
123
  export {
@@ -127,11 +139,13 @@ export {
127
139
  CometChatQuickReactions,
128
140
  CometChatReactionList,
129
141
  CometChatReactions,
142
+ CometChatRetryButton,
130
143
  CometChatStatusIndicator,
131
144
  CometChatSuggestionList,
132
145
  CometChatTextBubble,
133
146
  CometChatVideoBubble,
134
147
  SuggestionItem,
148
+ CometChatNewMessageIndicator,
135
149
  };
136
150
 
137
151
 
@@ -140,4 +154,5 @@ export type {
140
154
  CometChatListProps,
141
155
  DateStyle,
142
156
  MenuItemInterface,
157
+ NewMessageIndicatorStyle,
143
158
  };
File without changes
File without changes