@cometchat/chat-uikit-react-native 5.2.3 → 5.2.4
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.
- package/package.json +1 -1
- package/src/CometChatConversations/CometChatConversations.tsx +167 -86
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +312 -116
- package/src/CometChatMessageComposer/styles.tsx +2 -1
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +83 -17
- package/src/CometChatMessageList/CometChatMessageList.tsx +549 -70
- package/src/CometChatMessageList/style.ts +4 -2
- package/src/CometChatSearch/CometChatSearch.tsx +1718 -0
- package/src/CometChatSearch/SearchConstants.ts +46 -0
- package/src/CometChatSearch/Skeleton.tsx +192 -0
- package/src/CometChatSearch/index.ts +1 -0
- package/src/CometChatSearch/style.ts +414 -0
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +43 -7
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +45 -7
- package/src/extensions/Polls/Polls.tsx +36 -2
- package/src/extensions/Polls/PollsBubble.tsx +13 -9
- package/src/extensions/Polls/PollsDecorator.tsx +13 -1
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +50 -11
- package/src/extensions/Stickers/style.ts +0 -1
- package/src/index.ts +5 -0
- package/src/shared/base/Types.ts +8 -0
- package/src/shared/constants/UIKitConstants.ts +2 -0
- package/src/shared/events/CometChatMessageEvents/index.ts +8 -7
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -0
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +158 -27
- package/src/shared/framework/DataSource.ts +7 -0
- package/src/shared/framework/DataSourceDecorator.tsx +12 -0
- package/src/shared/framework/MessageDataSource.tsx +182 -1
- package/src/shared/helper/functions.js +0 -67
- package/src/shared/helper/helperFunctions.ts +73 -0
- package/src/shared/icons/components/documents.tsx +23 -0
- package/src/shared/icons/components/empty-search.tsx +52 -0
- package/src/shared/icons/components/message-blocked.tsx +1 -1
- package/src/shared/icons/components/unread.tsx +29 -0
- package/src/shared/icons/icon-mapping.tsx +7 -0
- package/src/shared/index.ts +2 -1
- package/src/shared/modals/CometChatMessageTemplate.ts +23 -0
- package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +4 -4
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +17 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +70 -34
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +60 -24
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +60 -24
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +40 -4
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +38 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +40 -4
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +274 -23
- package/src/shared/utils/MessageUtils.tsx +0 -1
- package/src/shared/views/CometChatAudioBubble/style.ts +0 -2
- package/src/shared/views/CometChatFileBubble/style.ts +0 -4
- package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +1 -0
- package/src/shared/views/CometChatList/CometChatList.tsx +12 -0
- package/src/shared/views/CometChatList/Header.tsx +79 -49
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +14 -4
- package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +390 -0
- package/src/shared/views/CometChatReportDialog/index.ts +3 -0
- package/src/shared/views/CometChatReportDialog/style.ts +164 -0
- package/src/shared/views/CometChatStatusIndicator/private.png +0 -0
- package/src/shared/views/CometChatStatusIndicator/protected.png +0 -0
- package/src/shared/views/CometChatStatusIndicator/styles.ts +2 -2
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +18 -2
- package/src/shared/views/index.ts +6 -0
- package/src/theme/default/default.ts +3 -0
- package/src/theme/provider.tsx +7 -5
- package/src/theme/type.ts +2 -0
|
@@ -24,7 +24,9 @@ import { CometChatTheme } from "../../theme/type";
|
|
|
24
24
|
import { CometChatCollaborativeBubble } from "../CollaborativeBubble/CometChatCollaborativeBubble";
|
|
25
25
|
import { ExtensionConstants, ExtensionTypeConstants } from "../ExtensionConstants";
|
|
26
26
|
import { getExtensionData } from "../ExtensionModerator";
|
|
27
|
-
import { getCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew/LocalizationManager"
|
|
27
|
+
import { getCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew/LocalizationManager";
|
|
28
|
+
import { CometChatMessageEvents } from "../../shared/events/CometChatMessageEvents";
|
|
29
|
+
import { messageStatus } from "../../shared/utils/CometChatMessageHelper";
|
|
28
30
|
const t = getCometChatTranslation();
|
|
29
31
|
|
|
30
32
|
export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator {
|
|
@@ -121,13 +123,23 @@ export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator
|
|
|
121
123
|
/>
|
|
122
124
|
),
|
|
123
125
|
onPress: (user, group) => {
|
|
124
|
-
this.shareCollaborativedocument(
|
|
126
|
+
this.shareCollaborativedocument(
|
|
127
|
+
user,
|
|
128
|
+
group,
|
|
129
|
+
additionalAttachmentOptionsParams?.replyToMessage,
|
|
130
|
+
additionalAttachmentOptionsParams?.closeReplyPreview
|
|
131
|
+
);
|
|
125
132
|
},
|
|
126
133
|
});
|
|
127
134
|
return attachmentOptions;
|
|
128
135
|
}
|
|
129
136
|
|
|
130
|
-
shareCollaborativedocument(
|
|
137
|
+
shareCollaborativedocument(
|
|
138
|
+
user?: CometChat.User,
|
|
139
|
+
group?: CometChat.Group,
|
|
140
|
+
replyToMessage?: CometChat.BaseMessage,
|
|
141
|
+
closeReplyPreview?: () => void
|
|
142
|
+
) {
|
|
131
143
|
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccToggleBottomSheet, {
|
|
132
144
|
isBottomSheetVisible: false,
|
|
133
145
|
});
|
|
@@ -144,17 +156,33 @@ export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator
|
|
|
144
156
|
} else {
|
|
145
157
|
}
|
|
146
158
|
|
|
159
|
+
const payload: any = {
|
|
160
|
+
receiver: receiverId,
|
|
161
|
+
receiverType: receiverType,
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
if (replyToMessage) {
|
|
165
|
+
payload.quotedMessageId = replyToMessage.getId();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (closeReplyPreview) {
|
|
169
|
+
closeReplyPreview();
|
|
170
|
+
}
|
|
171
|
+
|
|
147
172
|
CometChat.callExtension(
|
|
148
173
|
ExtensionConstants.document,
|
|
149
174
|
ExtensionConstants.post,
|
|
150
175
|
this.documentUrl,
|
|
151
|
-
|
|
152
|
-
receiver: receiverId,
|
|
153
|
-
receiverType: receiverType,
|
|
154
|
-
}
|
|
176
|
+
payload
|
|
155
177
|
)
|
|
156
178
|
.then((response) => {
|
|
157
179
|
console.log("extension sent ", response);
|
|
180
|
+
if (replyToMessage) {
|
|
181
|
+
CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
|
|
182
|
+
message: replyToMessage,
|
|
183
|
+
status: messageStatus.success,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
158
186
|
})
|
|
159
187
|
.catch((error) => {
|
|
160
188
|
console.log("error", error);
|
|
@@ -182,6 +210,14 @@ export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator
|
|
|
182
210
|
return this.getCollaborativeBubble(message, _alignment, theme);
|
|
183
211
|
}
|
|
184
212
|
},
|
|
213
|
+
ReplyView: (
|
|
214
|
+
message: CometChat.BaseMessage,
|
|
215
|
+
_alignment?: MessageBubbleAlignmentType,
|
|
216
|
+
onReplyViewClicked?: (messageToReply: CometChat.BaseMessage) => void
|
|
217
|
+
) => {
|
|
218
|
+
let documentMessage: CometChat.CustomMessage = message as CometChat.CustomMessage;
|
|
219
|
+
return ChatConfigurator.dataSource.getReplyView?.(documentMessage, theme, additionalParams) || null;
|
|
220
|
+
},
|
|
185
221
|
options: (
|
|
186
222
|
loggedInUser: CometChat.User,
|
|
187
223
|
messageObject: CometChat.BaseMessage,
|
package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx
CHANGED
|
@@ -25,7 +25,9 @@ import { Icon } from "../../shared/icons/Icon";
|
|
|
25
25
|
import { getMessagePreviewInternal } from "../../shared/utils/MessageUtils";
|
|
26
26
|
import { DEFAULT_ICONS } from "../../theme/default/resources/icons";
|
|
27
27
|
import { CometChatTheme } from "../../theme/type";
|
|
28
|
-
import { getCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew/LocalizationManager"
|
|
28
|
+
import { getCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew/LocalizationManager";
|
|
29
|
+
import { CometChatMessageEvents } from "../../shared/events/CometChatMessageEvents";
|
|
30
|
+
import { messageStatus } from "../../shared/utils/CometChatMessageHelper";
|
|
29
31
|
const t = getCometChatTranslation();
|
|
30
32
|
|
|
31
33
|
/**
|
|
@@ -176,7 +178,12 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
|
|
|
176
178
|
/>
|
|
177
179
|
),
|
|
178
180
|
onPress: (user, group) => {
|
|
179
|
-
this.shareCollaborativeWhiteboard(
|
|
181
|
+
this.shareCollaborativeWhiteboard(
|
|
182
|
+
user,
|
|
183
|
+
group,
|
|
184
|
+
additionalAttachmentOptionsParams?.replyToMessage,
|
|
185
|
+
additionalAttachmentOptionsParams?.closeReplyPreview
|
|
186
|
+
);
|
|
180
187
|
},
|
|
181
188
|
});
|
|
182
189
|
}
|
|
@@ -188,8 +195,15 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
|
|
|
188
195
|
*
|
|
189
196
|
* @param user - (Optional) The user object.
|
|
190
197
|
* @param group - (Optional) The group object.
|
|
198
|
+
* @param replyToMessage - (Optional) The message to reply to.
|
|
199
|
+
* @param closeReplyPreview - (Optional) Function to close reply preview.
|
|
191
200
|
*/
|
|
192
|
-
shareCollaborativeWhiteboard(
|
|
201
|
+
shareCollaborativeWhiteboard(
|
|
202
|
+
user?: CometChat.User,
|
|
203
|
+
group?: CometChat.Group,
|
|
204
|
+
replyToMessage?: CometChat.BaseMessage,
|
|
205
|
+
closeReplyPreview?: () => void
|
|
206
|
+
) {
|
|
193
207
|
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccToggleBottomSheet, {
|
|
194
208
|
isBottomSheetVisible: false,
|
|
195
209
|
});
|
|
@@ -204,17 +218,33 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
|
|
|
204
218
|
receiverType = ReceiverTypeConstants.group;
|
|
205
219
|
}
|
|
206
220
|
|
|
221
|
+
const payload: any = {
|
|
222
|
+
receiver: receiverId,
|
|
223
|
+
receiverType: receiverType,
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
if (replyToMessage) {
|
|
227
|
+
payload.quotedMessageId = replyToMessage.getId();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (closeReplyPreview) {
|
|
231
|
+
closeReplyPreview();
|
|
232
|
+
}
|
|
233
|
+
|
|
207
234
|
CometChat.callExtension(
|
|
208
235
|
ExtensionConstants.whiteboard,
|
|
209
236
|
ExtensionConstants.post,
|
|
210
237
|
this.whiteboardUrl,
|
|
211
|
-
|
|
212
|
-
receiver: receiverId,
|
|
213
|
-
receiverType: receiverType,
|
|
214
|
-
}
|
|
238
|
+
payload
|
|
215
239
|
)
|
|
216
240
|
.then((response) => {
|
|
217
241
|
console.log("extension sent ", response);
|
|
242
|
+
if (replyToMessage) {
|
|
243
|
+
CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
|
|
244
|
+
message: replyToMessage,
|
|
245
|
+
status: messageStatus.success,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
218
248
|
})
|
|
219
249
|
.catch((error) => {
|
|
220
250
|
console.log("error", error);
|
|
@@ -249,6 +279,14 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
|
|
|
249
279
|
return this.getCollaborativeBubble(message, _alignment, theme);
|
|
250
280
|
}
|
|
251
281
|
},
|
|
282
|
+
ReplyView: (
|
|
283
|
+
message: CometChat.BaseMessage,
|
|
284
|
+
_alignment?: MessageBubbleAlignmentType,
|
|
285
|
+
onReplyViewClicked?: (messageToReply: CometChat.BaseMessage) => void
|
|
286
|
+
) => {
|
|
287
|
+
let whiteboardMessage: CometChat.CustomMessage = message as CometChat.CustomMessage;
|
|
288
|
+
return ChatConfigurator.dataSource.getReplyView?.(whiteboardMessage, theme, additionalParams) || null;
|
|
289
|
+
},
|
|
252
290
|
options: (
|
|
253
291
|
loggedInUser: CometChat.User,
|
|
254
292
|
messageObject: CometChat.BaseMessage,
|
|
@@ -19,6 +19,8 @@ import { Icon } from "../../shared/icons/Icon";
|
|
|
19
19
|
import { useTheme } from "../../theme";
|
|
20
20
|
import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
|
|
21
21
|
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
|
|
22
|
+
import { CometChatMessageEvents } from "../../shared/events/CometChatMessageEvents";
|
|
23
|
+
import { messageStatus } from "../../shared/utils/CometChatMessageHelper";
|
|
22
24
|
|
|
23
25
|
const { CommonUtil } = NativeModules;
|
|
24
26
|
|
|
@@ -96,6 +98,20 @@ export interface CometChatCreatePollInterface {
|
|
|
96
98
|
* @description Default number of answer options
|
|
97
99
|
*/
|
|
98
100
|
defaultAnswers?: number;
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
*
|
|
104
|
+
* @type {CometChat.BaseMessage}
|
|
105
|
+
* @description The message to reply to
|
|
106
|
+
*/
|
|
107
|
+
replyToMessage?: CometChat.BaseMessage;
|
|
108
|
+
/**
|
|
109
|
+
*
|
|
110
|
+
*
|
|
111
|
+
* @type {() => void}
|
|
112
|
+
* @description Function to close the reply preview
|
|
113
|
+
*/
|
|
114
|
+
closeReplyPreview?: () => void;
|
|
99
115
|
}
|
|
100
116
|
|
|
101
117
|
/**
|
|
@@ -119,6 +135,8 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
|
|
|
119
135
|
answerHelpText,
|
|
120
136
|
addAnswerText,
|
|
121
137
|
defaultAnswers = 2,
|
|
138
|
+
replyToMessage,
|
|
139
|
+
closeReplyPreview,
|
|
122
140
|
} = props;
|
|
123
141
|
|
|
124
142
|
const [question, setQuestion] = useState("");
|
|
@@ -167,16 +185,32 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
|
|
|
167
185
|
if (!validate()) return;
|
|
168
186
|
setLoader(true);
|
|
169
187
|
|
|
170
|
-
|
|
188
|
+
const payload: any = {
|
|
171
189
|
question: question,
|
|
172
190
|
options: answers.filter((item) => item),
|
|
173
191
|
receiver: user ? user?.getUid() : group ? group?.getGuid() : "",
|
|
174
192
|
receiverType: user ? "user" : group ? "group" : "",
|
|
175
|
-
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
if (replyToMessage) {
|
|
196
|
+
payload.quotedMessageId = replyToMessage.getId();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (closeReplyPreview) {
|
|
200
|
+
closeReplyPreview();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
CometChat.callExtension("polls", "POST", "v2/create", payload)
|
|
176
204
|
.then((response) => {
|
|
177
205
|
console.log("poll created", response);
|
|
178
206
|
onClose && onClose();
|
|
179
207
|
setLoader(false);
|
|
208
|
+
if (replyToMessage) {
|
|
209
|
+
CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
|
|
210
|
+
message: replyToMessage,
|
|
211
|
+
status: messageStatus.success,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
180
214
|
})
|
|
181
215
|
.catch((error) => {
|
|
182
216
|
console.log("poll error", error);
|
|
@@ -162,14 +162,16 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
|
|
|
162
162
|
|
|
163
163
|
useEffect(() => {
|
|
164
164
|
let allOptions: Array<{ id: any; value: any }> = [];
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
if (options) {
|
|
166
|
+
for (const [key, value] of Object.entries(options)) {
|
|
167
|
+
allOptions.push({ id: key, value });
|
|
168
|
+
}
|
|
167
169
|
}
|
|
168
170
|
setOptionsList(allOptions);
|
|
169
171
|
if (metadata) {
|
|
170
172
|
setOptionsMetaData(metadata);
|
|
171
173
|
}
|
|
172
|
-
const optionsFromResult = metadata
|
|
174
|
+
const optionsFromResult = metadata?.results?.options ?? {};
|
|
173
175
|
|
|
174
176
|
for (const key in optionsFromResult) {
|
|
175
177
|
if (
|
|
@@ -177,7 +179,7 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
|
|
|
177
179
|
optionsFromResult[key].voters &&
|
|
178
180
|
Object.keys(optionsFromResult[key].voters).length
|
|
179
181
|
) {
|
|
180
|
-
if (optionsFromResult[key].voters[loggedInUser
|
|
182
|
+
if (loggedInUser && optionsFromResult[key].voters[loggedInUser.getUid()]) {
|
|
181
183
|
setSelectedVote(key);
|
|
182
184
|
}
|
|
183
185
|
}
|
|
@@ -230,6 +232,8 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
|
|
|
230
232
|
if (thirdavatarStyle && thirdavatarStyle.containerStyle) {
|
|
231
233
|
thirdavatarStyle.containerStyle.marginLeft = -10;
|
|
232
234
|
}
|
|
235
|
+
// Ensure value is a string for rendering
|
|
236
|
+
let optionText = typeof value === 'string' ? value : (value && value.value ? value.value : String(value));
|
|
233
237
|
return (
|
|
234
238
|
<Pressable
|
|
235
239
|
style={{ flexDirection: "row", marginBottom: 15, gap: 10 }}
|
|
@@ -262,10 +266,10 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
|
|
|
262
266
|
|
|
263
267
|
<View style={{ gap: 5, width: "100%", flex: 1 }}>
|
|
264
268
|
<View style={{ flex: 1, flexDirection: "row", justifyContent: "space-between" }}>
|
|
265
|
-
<Text style={optionTextStyle}>{
|
|
269
|
+
<Text style={optionTextStyle}>{optionText}</Text>
|
|
266
270
|
<View style={{ flexDirection: "row", gap: theme.spacing.spacing.s1 }}>
|
|
267
271
|
<View style={{ left: 0, flexDirection: "row" }}>
|
|
268
|
-
{optionsMetaData
|
|
272
|
+
{optionsMetaData?.results?.options?.[id]?.voters &&
|
|
269
273
|
Object.keys(optionsMetaData.results.options[id].voters)
|
|
270
274
|
.slice(0, 3)
|
|
271
275
|
.map((key, index) => {
|
|
@@ -288,7 +292,7 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
|
|
|
288
292
|
</View>
|
|
289
293
|
|
|
290
294
|
<Text style={voteCountTextStyle}>
|
|
291
|
-
{optionsMetaData
|
|
295
|
+
{optionsMetaData?.results?.options?.[id]?.count ?? 0}
|
|
292
296
|
</Text>
|
|
293
297
|
</View>
|
|
294
298
|
</View>
|
|
@@ -299,7 +303,7 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
|
|
|
299
303
|
{
|
|
300
304
|
backgroundColor: activeProgressBarTint,
|
|
301
305
|
width: getSliderWidth(
|
|
302
|
-
optionsMetaData
|
|
306
|
+
optionsMetaData?.results?.options?.[id]?.voters
|
|
303
307
|
? Object.keys(optionsMetaData.results.options[id].voters).length
|
|
304
308
|
: 0
|
|
305
309
|
),
|
|
@@ -320,7 +324,7 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
|
|
|
320
324
|
*/
|
|
321
325
|
const getSliderWidth = useCallback(
|
|
322
326
|
(voters: number) => {
|
|
323
|
-
const totalVotes =
|
|
327
|
+
const totalVotes = metadata?.results?.total ?? 0;
|
|
324
328
|
return totalVotes ? (((voters / totalVotes) * 100 + "%") as DimensionValue) : "0%";
|
|
325
329
|
},
|
|
326
330
|
[metadata]
|
|
@@ -20,7 +20,9 @@ import { getMessagePreviewInternal } from "../../shared/utils/MessageUtils";
|
|
|
20
20
|
import { CometChatTheme } from "../../theme/type";
|
|
21
21
|
import { CometChatCreatePoll } from "./Polls";
|
|
22
22
|
import { PollsBubble } from "./PollsBubble";
|
|
23
|
-
import { getCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew/LocalizationManager"
|
|
23
|
+
import { getCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew/LocalizationManager";
|
|
24
|
+
import { CometChatMessageEvents } from "../../shared/events/CometChatMessageEvents";
|
|
25
|
+
import { messageStatus } from "../../shared/utils/CometChatMessageHelper";
|
|
24
26
|
|
|
25
27
|
const t = getCometChatTranslation();
|
|
26
28
|
|
|
@@ -163,6 +165,8 @@ export class PollsExtensionDecorator extends DataSourceDecorator {
|
|
|
163
165
|
group={group}
|
|
164
166
|
{...pollsProps}
|
|
165
167
|
{...this.pollsConfiguration}
|
|
168
|
+
replyToMessage={additionalAttachmentOptionsParams?.replyToMessage}
|
|
169
|
+
closeReplyPreview={additionalAttachmentOptionsParams?.closeReplyPreview}
|
|
166
170
|
/>
|
|
167
171
|
);
|
|
168
172
|
},
|
|
@@ -198,6 +202,14 @@ export class PollsExtensionDecorator extends DataSourceDecorator {
|
|
|
198
202
|
return this.getPollBubble(message, _alignment, theme);
|
|
199
203
|
}
|
|
200
204
|
},
|
|
205
|
+
ReplyView: (
|
|
206
|
+
message: CometChat.BaseMessage,
|
|
207
|
+
_alignment?: MessageBubbleAlignmentType,
|
|
208
|
+
onReplyViewClicked?: (messageToReply: CometChat.BaseMessage) => void
|
|
209
|
+
) => {
|
|
210
|
+
let pollMessage: CometChat.CustomMessage = message as CometChat.CustomMessage;
|
|
211
|
+
return ChatConfigurator.dataSource.getReplyView?.(pollMessage, theme, additionalParams) || null;
|
|
212
|
+
},
|
|
201
213
|
options: (loggedInUser, messageObject, theme, group) =>
|
|
202
214
|
ChatConfigurator.dataSource.getMessageOptions(
|
|
203
215
|
loggedInUser,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
2
|
import React, { JSX, useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
-
import { Keyboard, KeyboardEventName, Platform, TouchableOpacity } from "react-native";
|
|
3
|
+
import { Keyboard, KeyboardEventName, Platform, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import {
|
|
5
5
|
AdditionalParams,
|
|
6
6
|
CometChatMessageTemplate,
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
CometChatUIEvents,
|
|
9
9
|
MessageBubbleAlignmentType,
|
|
10
10
|
} from "../../shared";
|
|
11
|
+
import { CometChatMessageEvents } from "../../shared/events/CometChatMessageEvents";
|
|
12
|
+
import { messageStatus } from "../../shared/utils/CometChatMessageHelper";
|
|
11
13
|
import { ChatConfigurator, DataSource, DataSourceDecorator } from "../../shared/framework";
|
|
12
14
|
import { CometChatUIKit } from "../../shared/CometChatUiKit/CometChatUIKit";
|
|
13
15
|
import { MessageCategoryConstants, ViewAlignment } from "../../shared/constants/UIKitConstants";
|
|
@@ -35,12 +37,22 @@ const t = getCometChatTranslation();
|
|
|
35
37
|
* @param {CometChat.Group} props.group - Group object representing the chat group.
|
|
36
38
|
* @param {Map<string, any>} props.id - Additional metadata, like parent message ID.
|
|
37
39
|
*/
|
|
38
|
-
const StickerButton = ({ user, group, id, stickerIconStyle, stickerIcon }: any) => {
|
|
40
|
+
const StickerButton = ({ user, group, id, stickerIconStyle, stickerIcon, replyToMessage, closeReplyPreview }: any) => {
|
|
39
41
|
const [isPanelOpen, setIsPanelOpen] = useState(false); // Tracks sticker panel visibility state.
|
|
40
42
|
const [keyboardOpen, setKeyboardOpen] = useState(false); // Tracks if the system keyboard is open.
|
|
41
43
|
const loggedInUser = useRef<CometChat.User | null>(null); // Stores the currently logged-in user.
|
|
42
44
|
const theme = useTheme(); // Retrieves theme configurations for styling.
|
|
43
45
|
const uiListenerIdRef = useRef<string>(`sticker_button_${Date.now()}`);
|
|
46
|
+
|
|
47
|
+
// Use refs to store reply message info to avoid stale closures
|
|
48
|
+
const replyToMessageRef = useRef(replyToMessage);
|
|
49
|
+
const closeReplyPreviewRef = useRef(closeReplyPreview);
|
|
50
|
+
|
|
51
|
+
// Update refs when props change
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
replyToMessageRef.current = replyToMessage;
|
|
54
|
+
closeReplyPreviewRef.current = closeReplyPreview;
|
|
55
|
+
}, [replyToMessage, closeReplyPreview]);
|
|
44
56
|
|
|
45
57
|
|
|
46
58
|
/**
|
|
@@ -124,10 +136,29 @@ const StickerButton = ({ user, group, id, stickerIconStyle, stickerIcon }: any)
|
|
|
124
136
|
customMessage.shouldUpdateConversation(true);
|
|
125
137
|
customMessage.setMetadata({ incrementUnreadCount: true });
|
|
126
138
|
|
|
139
|
+
// Set quoted message if replying - use ref to get current value
|
|
140
|
+
const currentReplyMessage = replyToMessageRef.current;
|
|
141
|
+
if (currentReplyMessage) {
|
|
142
|
+
customMessage.setQuotedMessage(currentReplyMessage);
|
|
143
|
+
customMessage.setQuotedMessageId(currentReplyMessage.getId());
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Close reply preview immediately after triggering send
|
|
147
|
+
const currentClosePreview = closeReplyPreviewRef.current;
|
|
148
|
+
if (currentClosePreview) {
|
|
149
|
+
currentClosePreview();
|
|
150
|
+
}
|
|
151
|
+
|
|
127
152
|
// Send the custom message using CometChatUIKit.
|
|
128
153
|
CometChatUIKit.sendCustomMessage(customMessage)
|
|
129
154
|
.then((res) => {
|
|
130
|
-
|
|
155
|
+
// Emit reply event if this was a reply
|
|
156
|
+
if (currentReplyMessage) {
|
|
157
|
+
CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
|
|
158
|
+
message: res,
|
|
159
|
+
status: messageStatus.success,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
131
162
|
})
|
|
132
163
|
.catch((err) => {
|
|
133
164
|
console.error("Failed to send sticker:", err);
|
|
@@ -268,6 +299,10 @@ export class StickersExtensionDecorator extends DataSourceDecorator {
|
|
|
268
299
|
return this.getStickerBubble(message as CometChat.CustomMessage, alignment, theme);
|
|
269
300
|
}
|
|
270
301
|
},
|
|
302
|
+
ReplyView: (message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType) => {
|
|
303
|
+
const replyView = ChatConfigurator.dataSource.getReplyView?.(message, theme, additionalParams);
|
|
304
|
+
return replyView || null;
|
|
305
|
+
},
|
|
271
306
|
options: (loggedInuser, message, theme, group) => {
|
|
272
307
|
return ChatConfigurator.dataSource.getMessageOptions(
|
|
273
308
|
loggedInuser,
|
|
@@ -302,14 +337,16 @@ export class StickersExtensionDecorator extends DataSourceDecorator {
|
|
|
302
337
|
? theme.messageListStyles.outgoingMessageBubbleStyles
|
|
303
338
|
: theme.messageListStyles.incomingMessageBubbleStyles;
|
|
304
339
|
return (
|
|
305
|
-
<
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
340
|
+
<View style={_style.stickerBubbleStyles?.containerStyle}>
|
|
341
|
+
<CometChatStickerBubble
|
|
342
|
+
url={url}
|
|
343
|
+
name=''
|
|
344
|
+
style={{
|
|
345
|
+
...this.configuration?.style,
|
|
346
|
+
..._style.stickerBubbleStyles?.imageStyle,
|
|
347
|
+
}}
|
|
348
|
+
/>
|
|
349
|
+
</View>
|
|
313
350
|
);
|
|
314
351
|
}
|
|
315
352
|
|
|
@@ -337,6 +374,8 @@ export class StickersExtensionDecorator extends DataSourceDecorator {
|
|
|
337
374
|
id={id}
|
|
338
375
|
stickerIcon={additionalAuxiliaryParams?.stickerIcon}
|
|
339
376
|
stickerIconStyle={additionalAuxiliaryParams?.stickerIconStyle}
|
|
377
|
+
replyToMessage={additionalAuxiliaryParams?.replyToMessage}
|
|
378
|
+
closeReplyPreview={additionalAuxiliaryParams?.closeReplyPreview}
|
|
340
379
|
/>
|
|
341
380
|
);
|
|
342
381
|
return auxiliaryOptions;
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
CometChatBottomSheet,
|
|
15
15
|
CometChatBottomSheetInterface,
|
|
16
16
|
CometChatConfirmDialog,
|
|
17
|
+
CometChatReportDialog,
|
|
17
18
|
CometChatConfirmDialogInterface,
|
|
18
19
|
CometChatConversationEvents,
|
|
19
20
|
//Utils
|
|
@@ -123,6 +124,8 @@ import { CometChatAIAssistantChatHistory } from "./CometChatAIAssistantChatHisto
|
|
|
123
124
|
|
|
124
125
|
import { CometChatThreadHeader, CometChatThreadHeaderInterface } from "./CometChatThreadHeader";
|
|
125
126
|
|
|
127
|
+
import { CometChatSearch } from "./CometChatSearch";
|
|
128
|
+
|
|
126
129
|
import {
|
|
127
130
|
CallButtonStyle,
|
|
128
131
|
CallUIEvents,
|
|
@@ -190,6 +193,7 @@ export {
|
|
|
190
193
|
CometChatCollaborativeDocumentBubble,
|
|
191
194
|
CometChatCollaborativeWhiteBoardBubble,
|
|
192
195
|
CometChatConfirmDialog,
|
|
196
|
+
CometChatReportDialog,
|
|
193
197
|
CometChatConversationEvents,
|
|
194
198
|
//
|
|
195
199
|
CometChatConversationUtils,
|
|
@@ -234,6 +238,7 @@ export {
|
|
|
234
238
|
CometChatTextBubble,
|
|
235
239
|
CometChatTextFormatter,
|
|
236
240
|
CometChatThreadHeader,
|
|
241
|
+
CometChatSearch,
|
|
237
242
|
CometChatUIEventHandler,
|
|
238
243
|
CometChatUIEvents,
|
|
239
244
|
CometChatUIKit,
|
package/src/shared/base/Types.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { CometChatTextFormatter } from "../formatters";
|
|
|
3
3
|
import { CometChatTheme } from "../../theme/type";
|
|
4
4
|
import { DeepPartial } from "../helper/types";
|
|
5
5
|
import { JSX } from "react";
|
|
6
|
+
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
6
7
|
|
|
7
8
|
export type SelectionMode = "none" | "single" | "multiple";
|
|
8
9
|
|
|
@@ -17,6 +18,7 @@ export type MessageTimeAlignmentType = "top" | "bottom";
|
|
|
17
18
|
export type AdditionalParams = {
|
|
18
19
|
textFormatters?: CometChatTextFormatter[];
|
|
19
20
|
disableMentions?: boolean;
|
|
21
|
+
hideReplyOption?: boolean,
|
|
20
22
|
hideReplyInThreadOption?: boolean,
|
|
21
23
|
hideShareMessageOption?: boolean,
|
|
22
24
|
hideEditMessageOption?: boolean,
|
|
@@ -26,7 +28,9 @@ export type AdditionalParams = {
|
|
|
26
28
|
hideMessagePrivatelyOption?: boolean,
|
|
27
29
|
hideCopyMessageOption?: boolean,
|
|
28
30
|
hideMessageInfoOption?: boolean,
|
|
31
|
+
hideReportMessageOption?: boolean,
|
|
29
32
|
hideGroupActionMessages?: boolean,
|
|
33
|
+
onReplyClick?: (messageId: string) => void;
|
|
30
34
|
};
|
|
31
35
|
|
|
32
36
|
export type AdditionalAttachmentOptionsParams = {
|
|
@@ -38,6 +42,8 @@ export type AdditionalAttachmentOptionsParams = {
|
|
|
38
42
|
hidePollsAttachmentOption?: boolean;
|
|
39
43
|
hideCollaborativeDocumentOption?: boolean;
|
|
40
44
|
hideCollaborativeWhiteboardOption?: boolean;
|
|
45
|
+
replyToMessage?: CometChat.BaseMessage;
|
|
46
|
+
closeReplyPreview?: () => void;
|
|
41
47
|
};
|
|
42
48
|
|
|
43
49
|
export type AdditionalAuxiliaryOptionsParams = {
|
|
@@ -47,6 +53,8 @@ export type AdditionalAuxiliaryOptionsParams = {
|
|
|
47
53
|
};
|
|
48
54
|
stickerIcon?: JSX.Element | ImageSourcePropType;
|
|
49
55
|
hideStickersButton?: boolean;
|
|
56
|
+
replyToMessage?: CometChat.BaseMessage;
|
|
57
|
+
closeReplyPreview?: () => void;
|
|
50
58
|
};
|
|
51
59
|
|
|
52
60
|
export type AdditionalAuxiliaryHeaderOptionsParams = {
|
|
@@ -101,6 +101,7 @@ export const GroupMemberOptionConstants = {
|
|
|
101
101
|
export const ConversationOptionConstants = {
|
|
102
102
|
delete: "delete",
|
|
103
103
|
edit: "edit",
|
|
104
|
+
reply: "reply",
|
|
104
105
|
};
|
|
105
106
|
|
|
106
107
|
export const ConversationTypeConstants = {
|
|
@@ -234,6 +235,7 @@ export const MessageOptionConstants = {
|
|
|
234
235
|
// forwardMessage: "forwardMessage",
|
|
235
236
|
sendMessagePrivately: "sendMessagePrivately",
|
|
236
237
|
replyMessagePrivately: "replyMessagePrivately",
|
|
238
|
+
reportMessage: "reportMessage",
|
|
237
239
|
};
|
|
238
240
|
|
|
239
241
|
export const CometChatMessageTypes = Object.freeze({
|
|
@@ -26,6 +26,7 @@ export class CometChatMessageEvents {
|
|
|
26
26
|
static onMessageReaction = Symbol("onMessageReaction");
|
|
27
27
|
static onViewInformation = Symbol("onViewInformation");
|
|
28
28
|
static onMessageError = Symbol("onMessageError");
|
|
29
|
+
static ccReplyToMessage = Symbol("ccReplyToMessage");
|
|
29
30
|
|
|
30
31
|
static onMessageReactionError = Symbol("onMessageReactionError");
|
|
31
32
|
static previewMessageForEdit = Symbol("previewMessageForEdit");
|
|
@@ -34,9 +35,9 @@ export class CometChatMessageEvents {
|
|
|
34
35
|
static onAIAssistantMessageReceived = Symbol("onAIAssistantMessageReceived");
|
|
35
36
|
static onAIToolResultReceived = Symbol("onAIToolResultReceived");
|
|
36
37
|
static onAIToolArgumentsReceived = Symbol("onAIToolArgumentsReceived");
|
|
37
|
-
static _triggers = {};
|
|
38
|
+
static _triggers: { [event: string]: { [id: string]: (params: any) => void } } = {};
|
|
38
39
|
|
|
39
|
-
static emit = (...args) => {
|
|
40
|
+
static emit = (...args: any[]) => {
|
|
40
41
|
let event, params;
|
|
41
42
|
if (args.length === 2) {
|
|
42
43
|
[event, params] = args;
|
|
@@ -47,9 +48,9 @@ export class CometChatMessageEvents {
|
|
|
47
48
|
throw new Error("Invalid arguments");
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
if (CometChatMessageEvents._triggers[event]) {
|
|
51
|
-
for (const i in CometChatMessageEvents._triggers[event]) {
|
|
52
|
-
CometChatMessageEvents._triggers[event][i](params);
|
|
51
|
+
if (CometChatMessageEvents._triggers[event as string]) {
|
|
52
|
+
for (const i in CometChatMessageEvents._triggers[event as string]) {
|
|
53
|
+
CometChatMessageEvents._triggers[event as string][i](params);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
};
|
|
@@ -58,7 +59,7 @@ export class CometChatMessageEvents {
|
|
|
58
59
|
* @param {string} event
|
|
59
60
|
* @param {string} id
|
|
60
61
|
*/
|
|
61
|
-
static removeListener = (...args) => {
|
|
62
|
+
static removeListener = (...args: any[]) => {
|
|
62
63
|
let event, id;
|
|
63
64
|
if (args.length === 2) {
|
|
64
65
|
[event, id] = args;
|
|
@@ -79,7 +80,7 @@ export class CometChatMessageEvents {
|
|
|
79
80
|
* @param {string} id
|
|
80
81
|
* @param {func} callback
|
|
81
82
|
*/
|
|
82
|
-
static addListener = (...args) => {
|
|
83
|
+
static addListener = (...args: any[]) => {
|
|
83
84
|
let event, id, callback;
|
|
84
85
|
if (args.length === 3) {
|
|
85
86
|
[event, id, callback] = args;
|
|
@@ -38,6 +38,7 @@ type MessageUIEvents = {
|
|
|
38
38
|
onMessagesReadByAll?: Function;
|
|
39
39
|
onMessageModerated?: Function;
|
|
40
40
|
onAIAssistantMessageReceived?: Function;
|
|
41
|
+
onMessageReply?: Function;
|
|
41
42
|
};
|
|
42
43
|
export class MessageUIEventListener {
|
|
43
44
|
ccMessageSent?: Function = undefined;
|
|
@@ -68,6 +69,7 @@ export class MessageUIEventListener {
|
|
|
68
69
|
onMessagesReadByAll?: Function = undefined;
|
|
69
70
|
onMessageModerated?: Function = undefined;
|
|
70
71
|
onAIAssistantMessageReceived?: Function = undefined;
|
|
72
|
+
onMessageReply?: Function = undefined;
|
|
71
73
|
constructor({
|
|
72
74
|
ccMessageSent,
|
|
73
75
|
ccMessageEdited,
|
|
@@ -97,6 +99,7 @@ export class MessageUIEventListener {
|
|
|
97
99
|
onMessagesReadByAll,
|
|
98
100
|
onMessageModerated,
|
|
99
101
|
onAIAssistantMessageReceived,
|
|
102
|
+
onMessageReply,
|
|
100
103
|
}: MessageUIEvents) {
|
|
101
104
|
if (!isFalsy(ccMessageError)) this.ccMessageError = ccMessageError;
|
|
102
105
|
if (!isFalsy(ccMessageDelivered)) this.ccMessageDelivered = ccMessageDelivered;
|
|
@@ -132,6 +135,7 @@ export class MessageUIEventListener {
|
|
|
132
135
|
this.onMessagesDeliveredToAll = onMessagesDeliveredToAll;
|
|
133
136
|
if (!isFalsy(onMessagesReadByAll)) this.onMessagesReadByAll = onMessagesReadByAll;
|
|
134
137
|
if (!isFalsy(onAIAssistantMessageReceived)) this.onAIAssistantMessageReceived = onAIAssistantMessageReceived;
|
|
138
|
+
if (!isFalsy(onMessageReply)) this.onMessageReply = onMessageReply;
|
|
135
139
|
if (!isFalsy(onMessageModerated)) this.onMessageModerated = onMessageModerated;
|
|
136
140
|
}
|
|
137
141
|
}
|