@cometchat/chat-uikit-react-native 5.0.0-beta.1 → 5.0.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 (98) hide show
  1. package/README.md +2 -3
  2. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +29 -44
  5. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +12 -0
  6. package/ios/FileManager.m +26 -9
  7. package/package.json +11 -36
  8. package/src/CometChatConversations/CometChatConversations.tsx +287 -147
  9. package/src/CometChatConversations/Skeleton.tsx +116 -73
  10. package/src/CometChatConversations/style.ts +17 -22
  11. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +439 -227
  12. package/src/CometChatGroupMembers/style.ts +2 -4
  13. package/src/CometChatGroups/CometChatGroups.tsx +239 -135
  14. package/src/CometChatGroups/GroupsStyle.ts +20 -17
  15. package/src/CometChatGroups/Skeleton.tsx +198 -288
  16. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +208 -73
  17. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +97 -43
  18. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +4 -2
  19. package/src/CometChatMessageList/CometChatMessageList.tsx +200 -76
  20. package/src/CometChatMessageList/style.ts +4 -4
  21. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +77 -11
  22. package/src/CometChatThreadHeader/style.ts +2 -2
  23. package/src/CometChatUsers/CometChatUsers.tsx +203 -51
  24. package/src/CometChatUsers/Skeleton.tsx +174 -159
  25. package/src/CometChatUsers/style.ts +21 -18
  26. package/src/calls/CallingConfiguration.ts +4 -3
  27. package/src/calls/CallingExtensionDecorator.tsx +5 -3
  28. package/src/calls/CometChatCallButtons/CometChatCallButtonConfiguration.ts +4 -2
  29. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +10 -8
  30. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +240 -97
  31. package/src/calls/CometChatCallLogs/Skeleton.tsx +175 -91
  32. package/src/calls/CometChatCallLogs/index.ts +1 -0
  33. package/src/calls/CometChatCallLogs/style.ts +85 -43
  34. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +42 -29
  35. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +36 -10
  36. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +39 -12
  37. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +5 -4
  38. package/src/extensions/Polls/PollsDecorator.tsx +30 -9
  39. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +34 -16
  40. package/src/index.ts +3 -1
  41. package/src/shared/base/Types.ts +31 -1
  42. package/src/shared/framework/DataSource.ts +64 -20
  43. package/src/shared/framework/DataSourceDecorator.tsx +46 -37
  44. package/src/shared/framework/MessageDataSource.tsx +518 -316
  45. package/src/shared/index.ts +3 -1
  46. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +3 -2
  47. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +3 -2
  48. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +3 -2
  49. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +3 -2
  50. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +3 -2
  51. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +3 -2
  52. package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +3 -2
  53. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +3 -2
  54. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +3 -2
  55. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +3 -2
  56. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +3 -2
  57. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +3 -2
  58. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +3 -2
  59. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +3 -2
  60. package/src/shared/utils/MessageUtils.tsx +41 -20
  61. package/src/shared/utils/conversationUtils.ts +2 -2
  62. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +22 -1
  63. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +20 -8
  64. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +177 -123
  65. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +76 -10
  66. package/src/shared/views/CometChatConfirmDialog/style.ts +2 -2
  67. package/src/shared/views/CometChatDate/CometChatDate.tsx +26 -18
  68. package/src/shared/views/CometChatDateSeperator/CometChatDateSeparator.tsx +22 -16
  69. package/src/shared/views/CometChatDeletedBubble/CometChatDeletedBubble.tsx +17 -5
  70. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +65 -35
  71. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +22 -11
  72. package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +47 -18
  73. package/src/shared/views/CometChatList/CometChatList.tsx +70 -46
  74. package/src/shared/views/CometChatList/Header.tsx +122 -37
  75. package/src/shared/views/CometChatList/styles.ts +1 -0
  76. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +116 -30
  77. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +52 -30
  78. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +36 -22
  79. package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +41 -13
  80. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +132 -17
  81. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +30 -2
  82. package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +10 -6
  83. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +20 -13
  84. package/src/shared/views/CometChatStatusIndicator/styles.ts +26 -13
  85. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +25 -2
  86. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +94 -14
  87. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +52 -16
  88. package/src/shared/views/CometChatTooltipMenu/index.ts +2 -1
  89. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +29 -9
  90. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +20 -2
  91. package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +29 -14
  92. package/src/shared/views/index.ts +2 -0
  93. package/src/theme/default/index.ts +5 -5
  94. package/src/theme/type.ts +2 -2
  95. package/src/shared/views/CometChatPanel/CometChatPanel.tsx +0 -57
  96. package/src/shared/views/CometChatPanel/PanelStyle.tsx +0 -43
  97. package/src/shared/views/CometChatPanel/resources/CloseIcon.png +0 -0
  98. package/src/shared/views/CometChatPanel/resources/index.ts +0 -3
@@ -14,77 +14,89 @@ import { CometChatTheme } from "../../../theme/type";
14
14
  import { CometChatUIEventHandler, CometChatUIEvents } from "../../events";
15
15
  import { ViewAlignment } from "../../constants/UIKitConstants";
16
16
 
17
+ /**
18
+ * Props for the CometChatMessageInput component.
19
+ */
17
20
  export interface CometChatMessageInputInterface {
18
21
  /**
19
- *
22
+ * Text for the input.
20
23
  *
21
24
  * @type {string}
22
- * @description text for the input
23
25
  */
24
26
  text?: string;
25
27
  /**
26
- *
28
+ * Placeholder text for the input.
27
29
  *
28
30
  * @type {string}
29
- * @description placeholder text
30
31
  */
31
32
  placeHolderText?: string;
32
33
  /**
34
+ * Callback function invoked when the input text changes.
33
35
  *
34
- *
35
- * @description callback when input state changes
36
+ * @param {string} newText - The new text entered.
36
37
  */
37
38
  onChangeText?: (arg0: string) => void;
39
+ /**
40
+ * Custom style for the message input.
41
+ */
38
42
  style?: CometChatTheme["messageComposerStyles"]["messageInputStyles"];
39
43
  /**
40
- *
44
+ * Maximum height for the input.
41
45
  *
42
46
  * @type {number}
43
- * @description max height for the input
44
47
  */
45
48
  maxHeight?: number;
46
49
  /**
50
+ * React component for the voice recording button.
47
51
  *
52
+ * @type {JSX.Element}
53
+ */
54
+ VoiceRecordingButtonView?: JSX.Element;
55
+ /**
56
+ * React component for the secondary button.
48
57
  *
49
- * @type {React.FC}
50
- * @description React component for Secondary button
58
+ * @type {JSX.Element}
51
59
  */
52
60
  SecondaryButtonView?: JSX.Element;
53
61
  /**
62
+ * React component for the auxiliary button.
54
63
  *
55
- *
56
- * @type {React.FC}
57
- * @description React component for Auxiliary button
64
+ * @type {JSX.Element}
58
65
  */
59
66
  AuxiliaryButtonView?: JSX.Element;
60
67
  /**
68
+ * Placement for the auxiliary button.
61
69
  *
62
- *
63
- * @type {('left' | 'right')}
64
- * @description Placement for Auxiliary button
70
+ * @type {"left" | "right"}
65
71
  */
66
72
  auxiliaryButtonAlignment?: "left" | "right";
67
73
  /**
68
- *
74
+ * React component for the primary button.
69
75
  *
70
76
  * @type {React.FC}
71
- * @description React component for Primary button
72
77
  */
73
78
  PrimaryButtonView?: React.FC;
74
79
  /**
80
+ * Callback for when the text selection changes.
75
81
  *
76
- *
77
- * @description callback for onSelectionChange
82
+ * @param {NativeSyntheticEvent<TextInputSelectionChangeEventData>} event - The selection change event.
78
83
  */
79
84
  onSelectionChange?: (e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => void;
80
85
  /**
81
- *
86
+ * Reference for the TextInput component.
82
87
  *
83
88
  * @type {RefObject<any>}
84
- * @description ref of {TextInput}
85
89
  */
86
90
  messageInputRef?: RefObject<any>;
87
91
  }
92
+
93
+ /**
94
+ * CometChatMessageInput renders a message input field with a divider and action buttons.
95
+ * It supports auxiliary, secondary, and primary buttons along with search input functionality.
96
+ *
97
+ * Props for the component.
98
+ * The rendered message input component.
99
+ */
88
100
  export const CometChatMessageInput = (props: CometChatMessageInputInterface) => {
89
101
  const theme = useTheme();
90
102
  const {
@@ -98,6 +110,7 @@ export const CometChatMessageInput = (props: CometChatMessageInputInterface) =>
98
110
  PrimaryButtonView,
99
111
  onSelectionChange,
100
112
  messageInputRef,
113
+ VoiceRecordingButtonView,
101
114
  } = props;
102
115
 
103
116
  return (
@@ -133,6 +146,7 @@ export const CometChatMessageInput = (props: CometChatMessageInputInterface) =>
133
146
  >
134
147
  <View style={{ flexDirection: "row", alignItems: "center", gap: theme.spacing.spacing.s4 }}>
135
148
  {SecondaryButtonView}
149
+ {VoiceRecordingButtonView}
136
150
  {auxiliaryButtonAlignment === "left" && AuxiliaryButtonView}
137
151
  </View>
138
152
  <View style={{ flexDirection: "row", alignItems: "center", gap: theme.spacing.spacing.s4 }}>
@@ -4,24 +4,52 @@ import { CometChatTheme } from "../../../theme/type";
4
4
  import { useTheme } from "../../../theme";
5
5
  import { Icon } from "../../icons/Icon";
6
6
 
7
- export const CometChatQuickReactions = (props: {
7
+ /**
8
+ * Props for the CometChatQuickReactions component.
9
+ */
10
+ export interface CometChatQuickReactionsProps {
11
+ /**
12
+ * An array of quick reaction emojis.
13
+ * Accepts a tuple with up to five strings.
14
+ */
8
15
  quickReactions?: [string, string?, string?, string?, string?];
16
+ /**
17
+ * Custom style for the quick reactions component.
18
+ */
9
19
  style?: CometChatTheme["quickReactionStyle"];
20
+ /**
21
+ * Callback invoked when a reaction emoji is pressed.
22
+ *
23
+ * @param {string} emoji - The emoji that was pressed.
24
+ */
10
25
  onReactionPress?: (emoji: string) => void;
26
+ /**
27
+ * Callback invoked when the add reaction button is pressed.
28
+ */
11
29
  onAddReactionPress?: () => void;
30
+ /**
31
+ * URL for the add reaction icon.
32
+ */
12
33
  addReactionUrl?: ImageSourcePropType;
13
- }) => {
34
+ }
35
+
36
+ /**
37
+ * CometChatQuickReactions displays a list of quick reaction emojis along with an option to add a new reaction.
38
+ *
39
+ * @param {CometChatQuickReactionsProps} props - Props for the component.
40
+ * @returns {JSX.Element} The rendered quick reactions component.
41
+ */
42
+ export const CometChatQuickReactions = (props: CometChatQuickReactionsProps) => {
14
43
  const { quickReactions, style, onReactionPress, onAddReactionPress, addReactionUrl } = props;
15
44
  const theme = useTheme();
16
45
 
17
- function getEmojis() {
18
- let defaultEmojis = (Array.isArray(quickReactions) && quickReactions) || [
19
- "👍",
20
- "❤️",
21
- "😂",
22
- "😢",
23
- "🙏",
24
- ];
46
+ /**
47
+ * Returns the array of emojis to be displayed.
48
+ *
49
+ * @returns {string[]} An array of emoji strings.
50
+ */
51
+ function getEmojis(): string[] {
52
+ let defaultEmojis = Array.isArray(quickReactions) ? quickReactions.filter((e): e is string => typeof e === 'string') : ["👍", "❤️", "😂", "😢", "🙏"];
25
53
  return defaultEmojis;
26
54
  }
27
55
 
@@ -31,7 +59,7 @@ export const CometChatQuickReactions = (props: {
31
59
  <TouchableOpacity
32
60
  key={index}
33
61
  style={[theme.quickReactionStyle.emojiContainerStyle, style?.emojiContainerStyle]}
34
- onPress={() => onReactionPress && onReactionPress(item!)}
62
+ onPress={() => onReactionPress && onReactionPress(item)}
35
63
  >
36
64
  <Text
37
65
  style={[
@@ -47,8 +75,8 @@ export const CometChatQuickReactions = (props: {
47
75
  onPress={() => onAddReactionPress && onAddReactionPress()}
48
76
  style={[theme.quickReactionStyle.emojiContainerStyle, style?.emojiContainerStyle]}
49
77
  >
50
- <Icon name='add-reaction' color={theme.color.iconSecondary}></Icon>
78
+ <Icon name="add-reaction" color={theme.color.iconSecondary} />
51
79
  </TouchableOpacity>
52
80
  </View>
53
81
  );
54
- };
82
+ };
@@ -1,5 +1,5 @@
1
1
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
- import React, { useCallback, useContext, useEffect, useRef, useState } from "react";
2
+ import React, { useCallback, useEffect, useRef, useState } from "react";
3
3
  import {
4
4
  ActivityIndicator,
5
5
  FlatList,
@@ -16,14 +16,47 @@ import { useTheme } from "../../../theme";
16
16
  import { Skeleton } from "../../../CometChatConversations";
17
17
  import { ErrorEmptyView } from "../ErrorEmptyView/ErrorEmptyView";
18
18
  import { Icon } from "../../icons/Icon";
19
+ import { CometChatUIEventHandler, MessageEvents } from "../../events";
20
+ import { messageStatus } from "../../utils/CometChatMessageHelper";
19
21
 
22
+ /**
23
+ * Props for the CometChatReactionList component.
24
+ */
20
25
  export interface CometChatReactionListInterface {
26
+ /**
27
+ * The message object whose reactions will be displayed.
28
+ */
21
29
  message: CometChat.BaseMessage;
30
+ /**
31
+ * Callback function invoked when a reaction is pressed.
32
+ *
33
+ * @param messageReaction - The reaction object that was pressed.
34
+ * @param message - The message object.
35
+ */
22
36
  onPress?: (messageReaction: CometChat.Reaction, message: CometChat.BaseMessage) => void;
37
+ /**
38
+ * Request builder for fetching reactions.
39
+ */
23
40
  reactionsRequestBuilder?: CometChat.ReactionsRequestBuilder;
41
+ /**
42
+ * The currently selected reaction filter (e.g. "All" or a specific reaction).
43
+ */
24
44
  selectedReaction?: string;
45
+ /**
46
+ * A custom component to render in case of an error state.
47
+ *
48
+ * @returns A JSX element representing the error state.
49
+ */
25
50
  ErrorStateView?: () => JSX.Element;
51
+ /**
52
+ * Custom error text to display when an error occurs.
53
+ */
26
54
  errorStateText?: string;
55
+ /**
56
+ * A custom component to render during the loading state.
57
+ *
58
+ * @returns A JSX element representing the loading state.
59
+ */
27
60
  LoadingStateView?: () => JSX.Element;
28
61
  }
29
62
 
@@ -51,6 +84,7 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
51
84
  const requestBuilderMap = useRef<Record<string, CometChat.ReactionsRequest>>({});
52
85
  const reactionListMap = useRef<Record<string, CometChat.Reaction[]>>({});
53
86
  const listRef = useRef<FlatList | null>(null);
87
+ const [messageObject, setMessageObject] = useState<CometChat.BaseMessage>(message);
54
88
 
55
89
  useEffect(() => {
56
90
  CometChat.getLoggedinUser()
@@ -60,7 +94,7 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
60
94
  // onError && onError(rej);
61
95
  });
62
96
  showReactions(true);
63
- let newMessageReactions = message?.getReactions() || [];
97
+ let newMessageReactions = messageObject?.getReactions() || [];
64
98
  _setAllReactions(newMessageReactions);
65
99
  }, []);
66
100
 
@@ -80,7 +114,7 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
80
114
  if (firstFetch && currentSelectedReaction !== "All") {
81
115
  await getReactionList(getRequestBuilder("All"), "All");
82
116
  }
83
- setReactionList(list);
117
+ setReactionList(list ?? []);
84
118
  };
85
119
 
86
120
  const getRequestBuilder = (reaction: string): CometChat.ReactionsRequest => {
@@ -89,8 +123,8 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
89
123
  return requestBuilderMap.current[reaction];
90
124
  }
91
125
 
92
- requestBuilder = reactionsRequestBuilder || new CometChat.ReactionsRequestBuilder();
93
- requestBuilder.setLimit(10).setMessageId(message?.getId());
126
+ requestBuilder = reactionsRequestBuilder || new CometChat.ReactionsRequestBuilder().setLimit(10);
127
+ requestBuilder.setMessageId(messageObject?.getId());
94
128
 
95
129
  if (reaction !== "All") {
96
130
  requestBuilder.setReaction(reaction);
@@ -116,8 +150,8 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
116
150
  setState("done");
117
151
  return list;
118
152
  } catch (error: any) {
119
- console.log("error while fetching reactions", error);
120
- if (error?.code === "REQUEST_IN_PROGRESS") return;
153
+ //console.log("error while fetching reactions", error);
154
+ if (error?.code === "REQUEST_IN_PROGRESS") return null;
121
155
  setState("error");
122
156
  return [];
123
157
  }
@@ -138,20 +172,100 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
138
172
  }
139
173
  setState("done");
140
174
  } catch (error: any) {
141
- console.log("error while fetching next reactions", error);
175
+ //console.log("error while fetching next reactions", error);
142
176
  if (error?.code === "REQUEST_IN_PROGRESS") return;
143
177
  setState("error");
144
178
  }
145
179
  };
146
180
 
181
+ const reactToMessage = useCallback((emoji: string) => {
182
+ const msgObj = CommonUtils.clone(messageObject);
183
+
184
+ const messageId = msgObj?.getId();
185
+ const reactions = msgObj?.getReactions() || [];
186
+ const emojiObject = reactions?.find((reaction: any) => {
187
+ return reaction?.reaction == emoji;
188
+ });
189
+ if (emojiObject && emojiObject?.getReactedByMe()) {
190
+ const updatedReactions: any[] = [];
191
+ reactions.forEach((reaction: any) => {
192
+ if (reaction?.getReaction() == emoji) {
193
+ if (reaction?.getCount() === 1) {
194
+ return;
195
+ } else {
196
+ reaction.setCount(reaction?.getCount() - 1);
197
+ reaction.setReactedByMe(false);
198
+ updatedReactions.push(reaction);
199
+ }
200
+ } else {
201
+ updatedReactions.push(reaction);
202
+ }
203
+ });
204
+
205
+ const newMessageObj = CommonUtils.clone(msgObj);
206
+ newMessageObj.setReactions(updatedReactions);
207
+
208
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, {
209
+ message: newMessageObj,
210
+ status: messageStatus.success,
211
+ });
212
+ CometChat.removeReaction(messageId, emoji)
213
+ .then((message: any) => {})
214
+ .catch((error: any) => {
215
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, {
216
+ message: msgObj,
217
+ status: messageStatus.success,
218
+ });
219
+ //console.log(error);
220
+ });
221
+ } else {
222
+ const updatedReactions: any[] = [];
223
+ const reactionAvailable = reactions.find((reaction: any) => {
224
+ return reaction?.getReaction() == emoji;
225
+ });
226
+ reactions.forEach((reaction: any) => {
227
+ if (reaction?.getReaction() == emoji) {
228
+ reaction.setCount(reaction?.getCount() + 1);
229
+ reaction.setReactedByMe(true);
230
+ updatedReactions.push(reaction);
231
+ } else {
232
+ updatedReactions.push(reaction);
233
+ }
234
+ });
235
+ if (!reactionAvailable) {
236
+ const react: CometChat.ReactionCount = new CometChat.ReactionCount(emoji, 1, true);
237
+ updatedReactions.push(react);
238
+ }
239
+
240
+ const newMessageObj = CommonUtils.clone(msgObj);
241
+
242
+ newMessageObj.setReactions(updatedReactions);
243
+
244
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, {
245
+ message: newMessageObj,
246
+ status: messageStatus.success,
247
+ });
248
+
249
+ CometChat.addReaction(messageId, emoji)
250
+ .then((response: any) => {})
251
+ .catch((error: any) => {
252
+ //console.log(error);
253
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, {
254
+ message: msgObj,
255
+ status: messageStatus.success,
256
+ });
257
+ });
258
+ }
259
+ }, [messageObject]);
260
+
147
261
  const removeReaction = (reactionObj: CometChat.Reaction) => {
148
262
  let reactedByMe = loggedInUser.current!.getUid() === reactionObj?.getReactedBy()?.getUid();
263
+ if (onPress) {
264
+ onPress(reactionObj, newMessageObj.current);
265
+ return;
266
+ }
149
267
  if (reactedByMe) {
150
- if (onPress) {
151
- onPress(reactionObj, newMessageObj.current);
152
- return;
153
- }
154
-
268
+ reactToMessage(reactionObj?.getReaction());
155
269
  let newReactionList = reactionList
156
270
  ? [...reactionList]?.filter(
157
271
  (reaction: CometChat.Reaction) =>
@@ -198,6 +312,7 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
198
312
  }
199
313
 
200
314
  newMessageObj.current.setReactions(newMessageReactions);
315
+ setMessageObject(newMessageObj.current);
201
316
  }
202
317
  };
203
318
 
@@ -248,8 +363,8 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
248
363
  return (
249
364
  <ErrorEmptyView
250
365
  title={errorStateText ?? "Oops!"}
251
- subTitle='Looks like something went wrong.'
252
- tertiaryTitle='Please try again.'
366
+ subTitle={localize("SOMETHING_WENT_WRONG")}
367
+ tertiaryTitle={localize("WRONG_TEXT_TRY_AGAIN")}
253
368
  Icon={
254
369
  <Icon
255
370
  name='error-state'
@@ -310,8 +425,8 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
310
425
  ? tabStyleFromTheme.selectedItemTextStyle
311
426
  : tabStyleFromTheme.selectedItemEmojiStyle
312
427
  : reactionObject?.getReaction() === "All"
313
- ? tabStyleFromTheme.itemTextStyle
314
- : tabStyleFromTheme.itemEmojiStyle
428
+ ? tabStyleFromTheme.itemTextStyle
429
+ : tabStyleFromTheme.itemEmojiStyle
315
430
  }
316
431
  >
317
432
  {reactionObject?.getReaction() === "All"
@@ -5,20 +5,48 @@ import { MessageBubbleAlignmentType } from "../../base/Types";
5
5
  import { CometChatTheme } from "../../../theme/type";
6
6
  import { DeepPartial } from "../../helper/types";
7
7
 
8
+ /**
9
+ * Props for rendering reactions on a message bubble.
10
+ */
8
11
  export interface CometChatReactionsInterface {
12
+ /**
13
+ * The message object for which reactions will be displayed.
14
+ */
9
15
  messageObject: CometChat.BaseMessage;
16
+ /**
17
+ * Custom styles for the reaction bubble.
18
+ */
10
19
  style?: DeepPartial<CometChatTheme["messageBubbleReactionStyles"]>;
20
+ /**
21
+ * Callback invoked when a reaction is pressed.
22
+ *
23
+ * @param reaction - The reaction count object that was pressed.
24
+ * @param messageObject - The message object associated with the reaction.
25
+ */
11
26
  onReactionPress?: (
12
27
  reaction: CometChat.ReactionCount,
13
28
  messageObject: CometChat.BaseMessage
14
29
  ) => void;
30
+ /**
31
+ * Callback invoked when a reaction is long pressed.
32
+ *
33
+ * @param reaction - The reaction count object that was long pressed.
34
+ * @param messageObject - The message object associated with the reaction.
35
+ */
15
36
  onReactionLongPress?: (
16
37
  reaction: CometChat.ReactionCount,
17
38
  messageObject: CometChat.BaseMessage
18
39
  ) => void;
40
+ /**
41
+ * Alignment of the reaction bubble.
42
+ */
19
43
  alignment?: MessageBubbleAlignmentType;
44
+ /**
45
+ * Maximum width for the content inside the reaction bubble.
46
+ */
20
47
  maxContentWidth?: number;
21
48
  }
49
+
22
50
  const CometChatReactions = (props: CometChatReactionsInterface) => {
23
51
  const { messageObject, style, onReactionPress, onReactionLongPress, alignment, maxContentWidth } =
24
52
  props;
@@ -73,7 +101,7 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
73
101
  return (
74
102
  <TouchableOpacity
75
103
  onPress={() => {
76
- onReactionLongPress && onReactionLongPress(AllObj, messageObject);
104
+ onReactionPress && onReactionPress(AllObj, messageObject);
77
105
  }}
78
106
  onLongPress={() => {
79
107
  onReactionLongPress && onReactionLongPress(AllObj, messageObject);
@@ -149,4 +177,4 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
149
177
  ) : null;
150
178
  };
151
179
 
152
- export { CometChatReactions };
180
+ export { CometChatReactions };
@@ -7,16 +7,20 @@ import { ReceiptStyles } from "./style";
7
7
  import { MessageReceipt } from "../../constants/UIKitConstants";
8
8
 
9
9
  /**
10
+ * Props for the CometChatReceipt component.
10
11
  *
11
- * CometChatReceipt is a component used to display the status of a message by a custom symbol.
12
- * This component returns the appropriate symbol depending upon the message status and can be customised.
13
- *
14
- * @version 1.0.0
15
- * @author CometChat
12
+ * CometChatReceipt is a component used to display the status of a message using a custom symbol.
13
+ * It returns an appropriate symbol depending on the message status and can be customized via style.
16
14
  *
17
15
  */
18
16
  export interface CometChatReceiptInterface {
17
+ /**
18
+ * The message receipt object representing the status of the message.
19
+ */
19
20
  receipt?: MessageReceipt;
21
+ /**
22
+ * Custom styles to override or extend the default receipt styles.
23
+ */
20
24
  style?: Partial<ReceiptStyles>;
21
25
  }
22
26
 
@@ -93,4 +97,4 @@ export const CometChatReceipt = (props: CometChatReceiptInterface) => {
93
97
  );
94
98
  }
95
99
  return null;
96
- };
100
+ };
@@ -6,44 +6,52 @@ import { useCompTheme } from "../../../theme/hook";
6
6
  import { deepMerge } from "../../helper/helperFunctions";
7
7
  import { StatusIndicatorStyles } from "./styles";
8
8
 
9
+ /**
10
+ * Props for the CometChatStatusIndicator component.
11
+ */
9
12
  export interface CometChatStatusIndicatorInterface {
10
- type?: "online" | "offline" | "private" | "protected" | "public";
13
+ /**
14
+ * The status type to be displayed. Can be one of:
15
+ * "online", "offline", "private", "protected", or "public".
16
+ */
17
+ type?: "online" | "offline" | "private" | "protected" | "public" | null;
18
+ /**
19
+ * Custom styles for the status indicator.
20
+ */
11
21
  style?: Partial<StatusIndicatorStyles>;
12
22
  }
13
23
 
14
24
  /**
15
- *
16
- * CometChatStatusIndicator is a component useful for indicating the status of user/group
17
- * This component displays the online/offline status of user/group
25
+ * CometChatStatusIndicator is a component used for indicating the status of a user or group.
26
+ * It displays the online/offline or custom status of the user/group using a predefined symbol or style.
18
27
  *
19
28
  * @author CometChat
20
- *
21
29
  */
22
30
 
23
31
  export const CometChatStatusIndicator = ({
24
32
  type = "offline",
25
- style = {},
33
+ style,
26
34
  }: CometChatStatusIndicatorInterface) => {
27
35
  const theme = useTheme();
28
36
  const compTheme = useCompTheme();
29
37
  const statusIndicatorStyles = useMemo(() => {
30
- return deepMerge(theme.statusIndicatorStyles, compTheme.statusIndicatorStyles ?? {}, style);
38
+ return deepMerge(theme.statusIndicatorStyle, compTheme.statusIndicatorStyle ?? {}, style ?? {});
31
39
  }, [theme, compTheme, style]);
32
40
 
33
41
  if (type === CometChat.USER_STATUS.ONLINE) {
34
42
  return (
35
43
  <View
36
- style={[statusIndicatorStyles.containerStyle, statusIndicatorStyles.containerStyleOnline]}
44
+ style={[ statusIndicatorStyles.containerStyleOnline]}
37
45
  />
38
46
  );
39
47
  }
40
48
  if (type === CometChat.GROUP_TYPE.PRIVATE) {
41
49
  return (
42
50
  <View
43
- style={[statusIndicatorStyles.containerStyle, statusIndicatorStyles.containerStylePrivate]}
51
+ style={[ statusIndicatorStyles.containerStylePrivate]}
44
52
  >
45
53
  <Image
46
- style={[statusIndicatorStyles.imageStyle, statusIndicatorStyles.imageStylePrivate]}
54
+ style={[statusIndicatorStyles.imageStylePrivate]}
47
55
  source={require("./private.png")}
48
56
  />
49
57
  </View>
@@ -53,16 +61,15 @@ export const CometChatStatusIndicator = ({
53
61
  return (
54
62
  <View
55
63
  style={[
56
- statusIndicatorStyles.containerStyle,
57
64
  statusIndicatorStyles.containerStyleProtected,
58
65
  ]}
59
66
  >
60
67
  <Image
61
- style={[statusIndicatorStyles.imageStyle, statusIndicatorStyles.imageStyleProtected]}
68
+ style={[ statusIndicatorStyles.imageStyleProtected]}
62
69
  source={require("./protected.png")}
63
70
  />
64
71
  </View>
65
72
  );
66
73
  }
67
74
  return null;
68
- };
75
+ };
@@ -2,12 +2,9 @@ import { ImageStyle, StyleSheet, ViewStyle } from "react-native";
2
2
  import { CometChatTheme } from "../../../theme/type";
3
3
 
4
4
  export type StatusIndicatorStyles = {
5
- containerStyle: ViewStyle;
6
5
  containerStyleOnline: ViewStyle;
7
6
  containerStylePrivate: ViewStyle;
8
7
  containerStyleProtected: ViewStyle;
9
-
10
- imageStyle: ImageStyle;
11
8
  imageStylePrivate: ImageStyle;
12
9
  imageStyleProtected: ImageStyle;
13
10
  };
@@ -18,7 +15,20 @@ export const getStatusIndicatorStyles = (
18
15
  typography: CometChatTheme["typography"]
19
16
  ): StatusIndicatorStyles => {
20
17
  return StyleSheet.create({
21
- containerStyle: {
18
+ containerStyleOnline: {
19
+ position: "absolute",
20
+ end: spacing.spacing.s0,
21
+ bottom: spacing.spacing.s0,
22
+ height: spacing.spacing.s3 + spacing.spacing.s0_5,
23
+ width: spacing.spacing.s3 + spacing.spacing.s0_5,
24
+ borderRadius: spacing.radius.max,
25
+ borderWidth: spacing.spacing.s0_5,
26
+ borderColor: color.background1,
27
+ backgroundColor: color.success,
28
+ justifyContent: "center",
29
+ alignItems: "center",
30
+ },
31
+ containerStylePrivate: {
22
32
  position: "absolute",
23
33
  end: spacing.spacing.s0,
24
34
  bottom: spacing.spacing.s0,
@@ -31,17 +41,20 @@ export const getStatusIndicatorStyles = (
31
41
  justifyContent: "center",
32
42
  alignItems: "center",
33
43
  },
34
- containerStyleOnline: {},
35
- containerStylePrivate: {},
36
44
  containerStyleProtected: {
45
+ position: "absolute",
46
+ end: spacing.spacing.s0,
47
+ bottom: spacing.spacing.s0,
48
+ height: spacing.spacing.s3 + spacing.spacing.s0_5,
49
+ width: spacing.spacing.s3 + spacing.spacing.s0_5,
50
+ borderRadius: spacing.radius.max,
51
+ borderWidth: spacing.spacing.s0_5,
52
+ borderColor: color.background1,
53
+ justifyContent: "center",
54
+ alignItems: "center",
37
55
  backgroundColor: color.warning,
38
56
  },
39
-
40
- imageStyle: {
41
- width: spacing.spacing.s2,
42
- height: spacing.spacing.s2,
43
- },
44
- imageStylePrivate: {},
45
- imageStyleProtected: {},
57
+ imageStylePrivate: { width: spacing.spacing.s2, height: spacing.spacing.s2 },
58
+ imageStyleProtected: { width: spacing.spacing.s2, height: spacing.spacing.s2 },
46
59
  });
47
60
  };