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