@cometchat/chat-uikit-react-native 5.5.4 → 5.7.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.
- package/android/src/main/java/com/reactnativecometchatuikit/CometChatKeyboardModule.kt +101 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +78 -3
- package/android/src/main/java/com/reactnativecometchatuikit/KeyboardDirectionWatcher.kt +64 -0
- package/android/src/main/java/com/reactnativecometchatuikit/KeyboardLanguageDirection.kt +44 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +287 -49
- package/android/src/main/java/com/reactnativecometchatuikit/SafeFileName.java +78 -0
- package/ios/CCLocalFileGuard.h +19 -0
- package/ios/CCLocalFileGuard.m +34 -0
- package/ios/CometChatKeyboardModule.m +9 -0
- package/ios/CometChatKeyboardModule.swift +71 -0
- package/ios/FileManager.m +70 -6
- package/ios/KeyboardLanguageDirection.swift +24 -0
- package/ios/RichTextEditorView.swift +253 -51
- package/ios/RichTextEditorViewManager.m +1 -0
- package/ios/VideoManager.m +1 -1
- package/package.json +18 -3
- package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +41 -57
- package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +4 -1
- package/src/CometChatAIAssistantChatHistory/style.ts +5 -2
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +145 -63
- package/src/CometChatCompactMessageComposer/styles.ts +7 -7
- package/src/CometChatConversations/CometChatConversations.tsx +276 -147
- package/src/CometChatConversations/Skeleton.tsx +4 -1
- package/src/CometChatConversations/style.ts +1 -1
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +39 -18
- package/src/CometChatGroupMembers/Skeleton.tsx +4 -1
- package/src/CometChatGroupMembers/style.ts +6 -4
- package/src/CometChatGroups/CometChatGroups.tsx +74 -58
- package/src/CometChatGroups/GroupsStyle.ts +1 -1
- package/src/CometChatGroups/Skeleton.tsx +4 -1
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +190 -96
- package/src/CometChatMessageComposer/styles.tsx +1 -1
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +28 -15
- package/src/CometChatMessageHeader/listners.ts +76 -56
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -1
- package/src/CometChatMessageInformation/Skeleton.tsx +4 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +1465 -313
- package/src/CometChatMessageList/SwipeToReplyView.tsx +61 -0
- package/src/CometChatMessageList/style.ts +32 -32
- package/src/CometChatMessageList/swipeToReply.ts +25 -0
- package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +81 -10
- package/src/CometChatNotificationFeed/style.ts +1 -1
- package/src/CometChatNotificationFeed/utils.ts +17 -18
- package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +82 -3
- package/src/CometChatPinnedMessages/style.ts +5 -5
- package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +2 -0
- package/src/CometChatRichTextEditor/index.tsx +3 -0
- package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +83 -15
- package/src/CometChatSavedMessages/style.ts +3 -3
- package/src/CometChatSearch/CometChatSearch.tsx +391 -136
- package/src/CometChatSearch/Skeleton.tsx +4 -1
- package/src/CometChatSearch/searchLabels.ts +26 -0
- package/src/CometChatSearch/style.ts +7 -7
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +34 -8
- package/src/CometChatThreadHeader/Header.tsx +2 -2
- package/src/CometChatUsers/CometChatUsers.tsx +10 -1
- package/src/CometChatUsers/Skeleton.tsx +4 -1
- package/src/CometChatUsers/style.ts +1 -1
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +27 -1
- package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +16 -4
- package/src/calls/CometChatCallLogs/Skeleton.tsx +4 -1
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +11 -3
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +10 -2
- package/src/extensions/CollaborativeBubble/style.ts +4 -4
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +11 -6
- package/src/extensions/LinkPreview/style.ts +6 -6
- package/src/extensions/Polls/Header.tsx +1 -1
- package/src/extensions/Polls/Polls.tsx +25 -12
- package/src/extensions/Polls/PollsBubble.tsx +10 -6
- package/src/extensions/Polls/style.ts +4 -4
- package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +2 -2
- package/src/extensions/Stickers/CometChatStickerKeyboard/Skeleton.tsx +1 -1
- package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +1 -1
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +4 -2
- package/src/index.ts +11 -1
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +102 -2
- package/src/shared/CometChatUiKit/UIKitSettings.ts +28 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +10 -0
- package/src/shared/events/index.ts +4 -0
- package/src/shared/events/offline.ts +28 -0
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +18 -13
- package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +15 -7
- package/src/shared/formatters/CometChatTextFormatter.ts +11 -0
- package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +7 -4
- package/src/shared/framework/MessageDataSource.tsx +51 -108
- package/src/shared/helper/LocalizedDateHelper.ts +64 -4
- package/src/shared/helper/helperFunctions.ts +71 -4
- package/src/shared/helper/keyboardDirection.ts +54 -0
- package/src/shared/helper/layoutDirection.ts +205 -0
- package/src/shared/helper/pluralRules.ts +67 -0
- package/src/shared/helper/textDirection.ts +118 -0
- package/src/shared/icons/Icon.tsx +37 -2
- package/src/shared/icons/components/format-list-numbered-rtl.tsx +15 -0
- package/src/shared/index.ts +2 -0
- package/src/shared/offline/OfflineHub.ts +651 -0
- package/src/shared/offline/OfflineMediaBubble.tsx +49 -0
- package/src/shared/offline/OfflineViews.tsx +222 -0
- package/src/shared/offline/conversationPins.ts +137 -0
- package/src/shared/offline/conversations.ts +325 -0
- package/src/shared/offline/frameProbe.ts +24 -0
- package/src/shared/offline/gate.ts +94 -0
- package/src/shared/offline/groupActions.ts +81 -0
- package/src/shared/offline/identity.ts +162 -0
- package/src/shared/offline/index.ts +76 -0
- package/src/shared/offline/media.ts +247 -0
- package/src/shared/offline/notices.ts +84 -0
- package/src/shared/offline/reconcile.ts +296 -0
- package/src/shared/offline/searchOutcome.ts +62 -0
- package/src/shared/offline/send.ts +430 -0
- package/src/shared/offline/stateContract.ts +85 -0
- package/src/shared/offline/threadReplies.ts +125 -0
- package/src/shared/offline/twoPhase.ts +372 -0
- package/src/shared/offline/unsentActions.ts +168 -0
- package/src/shared/offline/useOfflineMediaUri.ts +87 -0
- package/src/shared/offline/useOfflineReconnect.ts +25 -0
- package/src/shared/offline/useOfflineSessionEnded.ts +22 -0
- package/src/shared/offline/useOfflineUploadTray.ts +76 -0
- package/src/shared/offline/usePresenceHidden.ts +33 -0
- package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +2 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/ar/translation.json +720 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +75 -4
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +75 -4
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +82 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +90 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +74 -3
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +74 -3
- package/src/shared/services/UploadQueueService.ts +106 -1
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +13 -12
- package/src/shared/utils/CometChatMessagePreview/style.ts +1 -1
- package/src/shared/utils/MessageReceiptUtils.ts +8 -0
- package/src/shared/utils/MessageUtils.tsx +14 -14
- package/src/shared/utils/PermissionUtil.ts +16 -5
- package/src/shared/utils/SavedMessagesHelper.ts +18 -1
- package/src/shared/utils/attachmentLimits.ts +3 -2
- package/src/shared/utils/catchUpCursor.ts +36 -0
- package/src/shared/utils/conversationUtils.ts +3 -5
- package/src/shared/utils/failedMessageRetry.ts +73 -0
- package/src/shared/utils/fileIconFontSize.ts +10 -0
- package/src/shared/utils/fileSizeLabel.ts +16 -0
- package/src/shared/utils/groupActionText.ts +75 -0
- package/src/shared/utils/messageIdentity.ts +38 -0
- package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +12 -8
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +1 -1
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +5 -3
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +22 -17
- package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +45 -12
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +16 -10
- package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +20 -8
- package/src/shared/views/CometChatBadge/CometChatBadge.tsx +8 -4
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +6 -2
- package/src/shared/views/CometChatComposerErrorBanner.tsx +3 -1
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +8 -3
- package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +2 -2
- package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +5 -3
- package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +8 -8
- package/src/shared/views/CometChatEmojiKeyboard/style.ts +2 -2
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +13 -27
- package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +65 -15
- package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +7 -3
- package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +56 -25
- package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +41 -21
- package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +7 -3
- package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +7 -3
- package/src/shared/views/CometChatList/CometChatList.tsx +478 -21
- package/src/shared/views/CometChatList/Header.tsx +5 -2
- package/src/shared/views/CometChatList/sectionLetter.ts +44 -0
- package/src/shared/views/CometChatList/styles.ts +7 -7
- package/src/shared/views/CometChatListItem/CometChatListItem.tsx +6 -4
- package/src/shared/views/CometChatMediaRecorder/CometChatAudioPlayer.tsx +16 -10
- package/src/shared/views/CometChatMediaRecorder/Timer.tsx +5 -1
- package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +43 -16
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +24 -4
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +19 -2
- package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +3 -2
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +59 -12
- package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +2 -2
- package/src/shared/views/CometChatReactionList/Skeleton.tsx +4 -1
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +6 -2
- package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +7 -3
- package/src/shared/views/CometChatReportDialog/style.ts +1 -1
- package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +1 -1
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +4 -0
- package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +20 -13
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -2
- package/src/shared/views/CometChatSuggestionList/Skeleton.tsx +1 -1
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +29 -3
- package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +20 -30
- package/src/shared/views/CometChatTooltipMenu/tooltipPosition.ts +43 -0
- package/src/shared/views/CometChatVideoBubble/style.ts +2 -2
- package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +4 -1
- package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +58 -24
- package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +24 -12
- package/src/shared/views/SenderLabel.tsx +41 -0
- package/src/theme/default/default.ts +1 -1
- package/src/theme/type.ts +17 -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/ios/VideoManager.m
CHANGED
|
@@ -16,7 +16,7 @@ RCT_EXPORT_MODULE(VideoManager);
|
|
|
16
16
|
QLPreviewController* previewCtrl = [[QLPreviewController alloc] init];
|
|
17
17
|
[previewCtrl setDataSource: self];
|
|
18
18
|
[[previewCtrl navigationController] setTitle:@""];
|
|
19
|
-
[previewCtrl setModalPresentationStyle:
|
|
19
|
+
[previewCtrl setModalPresentationStyle:UIModalPresentationFullScreen];
|
|
20
20
|
UIViewController *presentedViewController = RCTPresentedViewController();
|
|
21
21
|
[presentedViewController presentViewController:previewCtrl animated:YES completion:nil];
|
|
22
22
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cometchat/chat-uikit-react-native",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.0",
|
|
4
4
|
"description": "Ready-to-use Chat UI Components for React Native",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"module": "src/index",
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"test:native:ios": "cd ios-tests && UDID=$(xcrun simctl list devices available | grep -m1 iPhone | grep -oE '[0-9A-F-]{36}'); if [ -z \"$UDID\" ]; then echo \"No iPhone simulator is available. Install one via Xcode > Settings > Components.\" >&2; exit 1; fi; xcodebuild test -scheme RichTextEditorKit-Package -destination \"platform=iOS Simulator,id=$UDID\"",
|
|
29
29
|
"typescript": "tsc --noEmit",
|
|
30
30
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
31
|
+
"lint:offline": "eslint \"src/shared/offline/**/*.{ts,tsx}\"",
|
|
32
|
+
"api:check": "bash ./scripts/api-check.sh",
|
|
33
|
+
"sdk-floor:check": "bash ./scripts/sdk-floor-typecheck.sh",
|
|
34
|
+
"integrator:check": "bash ./scripts/integrator-compile-check.sh",
|
|
35
|
+
"probe:check": "bash ./scripts/probe-strip-check.sh",
|
|
31
36
|
"release": "release-it",
|
|
32
37
|
"format": "prettier --write ./src/**/*.{ts,tsx}"
|
|
33
38
|
},
|
|
@@ -87,15 +92,25 @@
|
|
|
87
92
|
"react-native-localize": "*",
|
|
88
93
|
"react-native-safe-area-context": "*",
|
|
89
94
|
"react-native-svg": "*",
|
|
90
|
-
"react-native-video": "*"
|
|
95
|
+
"react-native-video": "*",
|
|
96
|
+
"react-native-fs": "*"
|
|
97
|
+
},
|
|
98
|
+
"peerDependenciesMeta": {
|
|
99
|
+
"react-native-fs": {
|
|
100
|
+
"optional": true
|
|
101
|
+
}
|
|
91
102
|
},
|
|
92
103
|
"jest": {
|
|
93
104
|
"preset": "@react-native/jest-preset",
|
|
94
105
|
"modulePathIgnorePatterns": [
|
|
95
106
|
"<rootDir>/lib/"
|
|
96
107
|
],
|
|
108
|
+
"setupFiles": [
|
|
109
|
+
"<rootDir>/jest/setup.js"
|
|
110
|
+
],
|
|
97
111
|
"moduleNameMapper": {
|
|
98
|
-
"\\.(wav|mp3|m4a|aac|ogg)$": "<rootDir>/jest/assetMock.js"
|
|
112
|
+
"\\.(wav|mp3|m4a|aac|ogg)$": "<rootDir>/jest/assetMock.js",
|
|
113
|
+
"^@react-native-async-storage/async-storage$": "<rootDir>/jest/asyncStorageMock.js"
|
|
99
114
|
}
|
|
100
115
|
},
|
|
101
116
|
"commitlint": {
|
|
@@ -19,10 +19,15 @@ import { CometChatTooltipMenu } from "../shared/views/CometChatTooltipMenu";
|
|
|
19
19
|
import { CometChatConfirmDialog } from "../shared/views/CometChatConfirmDialog";
|
|
20
20
|
import Delete from "../shared/icons/components/delete";
|
|
21
21
|
import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
|
|
22
|
+
import { useLocalizedDate } from "../shared/helper/useLocalizedDateHook";
|
|
23
|
+
import { LocalizedDateHelper } from "../shared/helper/LocalizedDateHelper";
|
|
22
24
|
import { skipNextAgentAutoLoad } from "../CometChatMessageList/CometChatMessageList";
|
|
25
|
+
import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection } from "../shared/helper/layoutDirection";
|
|
23
26
|
|
|
24
27
|
|
|
25
28
|
interface CometChatAIAssistantChatHistoryProps {
|
|
29
|
+
/** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
|
|
30
|
+
layoutDirection?: "ltr" | "rtl";
|
|
26
31
|
/**
|
|
27
32
|
* A `CometChat.User` object representing the participant of the chat whose message history is displayed.
|
|
28
33
|
*/
|
|
@@ -86,9 +91,12 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
|
|
|
86
91
|
style = {},
|
|
87
92
|
LoadingStateView
|
|
88
93
|
} = props;
|
|
94
|
+
// ENG-41333: own setting → enclosing component → global; drives the root and the context.
|
|
95
|
+
const direction = useComponentLayoutDirection(props.layoutDirection);
|
|
89
96
|
|
|
90
97
|
const theme = useTheme();
|
|
91
98
|
const {t}=useCometChatTranslation();
|
|
99
|
+
const { formatDate } = useLocalizedDate();
|
|
92
100
|
|
|
93
101
|
// Create fallback styles if theme.chatHistoryStyles doesn't exist
|
|
94
102
|
const defaultStyles = useMemo(() => {
|
|
@@ -157,66 +165,33 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
|
|
|
157
165
|
/**
|
|
158
166
|
* Function to get formatted date label
|
|
159
167
|
*/
|
|
168
|
+
// Today / Yesterday / weekday / date in the kit language — the same labels as the message
|
|
169
|
+
// list's date separators (was hard-coded English and 'en-US' dates).
|
|
160
170
|
const getDateLabel = useCallback((timestamp: number): string => {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const yesterday = new Date(today);
|
|
164
|
-
yesterday.setDate(yesterday.getDate() - 1);
|
|
165
|
-
|
|
166
|
-
if (messageDate.toDateString() === today.toDateString()) {
|
|
167
|
-
return 'Today';
|
|
168
|
-
} else if (messageDate.toDateString() === yesterday.toDateString()) {
|
|
169
|
-
return 'Yesterday';
|
|
170
|
-
} else {
|
|
171
|
-
// Check if it's within the last week
|
|
172
|
-
const oneWeekAgo = new Date(today);
|
|
173
|
-
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
|
|
174
|
-
|
|
175
|
-
if (messageDate >= oneWeekAgo) {
|
|
176
|
-
return messageDate.toLocaleDateString('en-US', { weekday: 'long' });
|
|
177
|
-
} else {
|
|
178
|
-
return messageDate.toLocaleDateString('en-US', {
|
|
179
|
-
month: 'long',
|
|
180
|
-
day: 'numeric',
|
|
181
|
-
year: messageDate.getFullYear() !== today.getFullYear() ? 'numeric' : undefined
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}, []);
|
|
171
|
+
return formatDate(timestamp * 1000, LocalizedDateHelper.patterns.dayDateFormat);
|
|
172
|
+
}, [formatDate]);
|
|
186
173
|
|
|
187
174
|
/**
|
|
188
175
|
* Function to group messages by date
|
|
189
176
|
*/
|
|
190
177
|
const groupedMessages = useMemo((): GroupedMessage[] => {
|
|
191
178
|
const groups: { [key: string]: CometChat.TextMessage[] } = {};
|
|
192
|
-
|
|
179
|
+
const newest: { [key: string]: number } = {};
|
|
180
|
+
|
|
193
181
|
messageList.forEach(message => {
|
|
194
182
|
const label = getDateLabel(message.getSentAt());
|
|
195
183
|
if (!groups[label]) {
|
|
196
184
|
groups[label] = [];
|
|
185
|
+
newest[label] = 0;
|
|
197
186
|
}
|
|
198
187
|
groups[label].push(message);
|
|
188
|
+
newest[label] = Math.max(newest[label], message.getSentAt() ?? 0);
|
|
199
189
|
});
|
|
200
|
-
|
|
201
|
-
//
|
|
202
|
-
|
|
203
|
-
|
|
190
|
+
|
|
191
|
+
// Newest group first, by its newest message. The labels are translated now, so the old sort
|
|
192
|
+
// by English label text ('Today', 'Yesterday', 'Monday', …) no longer applies.
|
|
204
193
|
return Object.entries(groups)
|
|
205
|
-
.sort(([a], [b]) =>
|
|
206
|
-
const aIndex = sortOrder.indexOf(a);
|
|
207
|
-
const bIndex = sortOrder.indexOf(b);
|
|
208
|
-
|
|
209
|
-
if (aIndex !== -1 && bIndex !== -1) {
|
|
210
|
-
return aIndex - bIndex;
|
|
211
|
-
} else if (aIndex !== -1) {
|
|
212
|
-
return -1;
|
|
213
|
-
} else if (bIndex !== -1) {
|
|
214
|
-
return 1;
|
|
215
|
-
} else {
|
|
216
|
-
// Both are dates, sort by most recent first
|
|
217
|
-
return b.localeCompare(a);
|
|
218
|
-
}
|
|
219
|
-
})
|
|
194
|
+
.sort(([a], [b]) => newest[b] - newest[a])
|
|
220
195
|
.map(([title, data]) => ({ title, data }));
|
|
221
196
|
}, [messageList, getDateLabel]);
|
|
222
197
|
|
|
@@ -230,7 +205,14 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
|
|
|
230
205
|
// **bold**) so titles read cleanly instead of showing raw tags/markers.
|
|
231
206
|
return stripRichText(message.getText());
|
|
232
207
|
} else if (message instanceof CometChat.MediaMessage) {
|
|
233
|
-
|
|
208
|
+
const type = message.getType();
|
|
209
|
+
return t(
|
|
210
|
+
type === 'image' ? 'MESSAGE_IMAGE'
|
|
211
|
+
: type === 'video' ? 'MESSAGE_VIDEO'
|
|
212
|
+
: type === 'audio' ? 'MESSAGE_AUDIO'
|
|
213
|
+
: type === 'file' ? 'MESSAGE_FILE'
|
|
214
|
+
: 'MESSAGE'
|
|
215
|
+
);
|
|
234
216
|
} else if (message instanceof CometChat.CustomMessage) {
|
|
235
217
|
// Handle assistant messages
|
|
236
218
|
if (message.getType() === 'assistant' && message.getData()) {
|
|
@@ -241,17 +223,17 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
|
|
|
241
223
|
return stripRichText(data.text);
|
|
242
224
|
}
|
|
243
225
|
}
|
|
244
|
-
return '
|
|
226
|
+
return t('MESSAGE');
|
|
245
227
|
} else if (message.getType() === 'groupMember') {
|
|
246
|
-
return '
|
|
228
|
+
return t('MESSAGE');
|
|
247
229
|
} else {
|
|
248
|
-
return '
|
|
230
|
+
return t('MESSAGE');
|
|
249
231
|
}
|
|
250
232
|
} catch (error) {
|
|
251
233
|
errorHandler(error, "getMessageText");
|
|
252
|
-
return '
|
|
234
|
+
return t('MESSAGE');
|
|
253
235
|
}
|
|
254
|
-
}, [errorHandler]);
|
|
236
|
+
}, [errorHandler, t]);
|
|
255
237
|
|
|
256
238
|
/**
|
|
257
239
|
* Function to check if message can be deleted
|
|
@@ -532,7 +514,8 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
|
|
|
532
514
|
}, []);
|
|
533
515
|
|
|
534
516
|
return (
|
|
535
|
-
<
|
|
517
|
+
<LayoutDirectionContext.Provider value={direction}>
|
|
518
|
+
<View style={[mergedStyle.containerStyle, directionStyle(direction)]}>
|
|
536
519
|
{/* Tooltip Menu for Delete Option */}
|
|
537
520
|
{/* Only show tooltip menu if the message is deletable */}
|
|
538
521
|
{longPressedMessage.current && canDeleteMessage(longPressedMessage.current) && (
|
|
@@ -545,7 +528,7 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
|
|
|
545
528
|
nativeEvent: tooltipPosition.current,
|
|
546
529
|
}}
|
|
547
530
|
menuItems={[{
|
|
548
|
-
text: "
|
|
531
|
+
text: t("DELETE"),
|
|
549
532
|
onPress: () => {
|
|
550
533
|
setConfirmDelete(longPressedMessage.current?.getId());
|
|
551
534
|
setTooltipVisible(false);
|
|
@@ -564,11 +547,11 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
|
|
|
564
547
|
|
|
565
548
|
{/* Confirm Delete Dialog */}
|
|
566
549
|
<CometChatConfirmDialog
|
|
567
|
-
titleText="
|
|
550
|
+
titleText={t("DELETE_MESSAGE")}
|
|
568
551
|
icon={<Icon name='delete' size={theme.spacing.spacing.s12} color={theme.color.error} />}
|
|
569
|
-
cancelButtonText="
|
|
570
|
-
confirmButtonText="
|
|
571
|
-
messageText="
|
|
552
|
+
cancelButtonText={t("CANCEL")}
|
|
553
|
+
confirmButtonText={t("DELETE")}
|
|
554
|
+
messageText={t("DELETE_MESSAGE_CONFIRM")}
|
|
572
555
|
isOpen={confirmDelete !== undefined}
|
|
573
556
|
onCancel={() => setConfirmDelete(undefined)}
|
|
574
557
|
onConfirm={() => {
|
|
@@ -629,6 +612,7 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
|
|
|
629
612
|
/>
|
|
630
613
|
)}
|
|
631
614
|
</View>
|
|
615
|
+
</LayoutDirectionContext.Provider>
|
|
632
616
|
);
|
|
633
617
|
};
|
|
634
618
|
|
|
@@ -4,6 +4,7 @@ import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
|
|
|
4
4
|
import { useTheme } from "../theme";
|
|
5
5
|
import type { ColorValue } from "react-native";
|
|
6
6
|
import { CometChatTheme } from "../theme/type";
|
|
7
|
+
import { useRtlMirror } from "../shared/helper/layoutDirection";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Animated skeleton placeholder mimicking chat history in CometChat UI‑Kit.
|
|
@@ -116,6 +117,8 @@ const useHistoryElements = (fill: ColorValue) =>
|
|
|
116
117
|
|
|
117
118
|
export const Skeleton: React.FC<SkeletonProps> = ({ style }) => {
|
|
118
119
|
const theme = useTheme();
|
|
120
|
+
// ENG-41390: SVG shapes and the shimmer use fixed x positions; flip the whole skeleton in RTL.
|
|
121
|
+
const rtlMirror = useRtlMirror();
|
|
119
122
|
const get = <K extends keyof SkeletonStyle>(key: K) => getStyleValue(key, style, theme);
|
|
120
123
|
|
|
121
124
|
// Shimmer animation ------------------------------------------
|
|
@@ -150,7 +153,7 @@ export const Skeleton: React.FC<SkeletonProps> = ({ style }) => {
|
|
|
150
153
|
<ScrollView
|
|
151
154
|
scrollEnabled={false}
|
|
152
155
|
showsVerticalScrollIndicator={false}
|
|
153
|
-
style={{ backgroundColor: get("containerBackgroundColor") }}
|
|
156
|
+
style={[{ backgroundColor: get("containerBackgroundColor") }, rtlMirror]}
|
|
154
157
|
>
|
|
155
158
|
{/* Bottom layer (gradient fill) */}
|
|
156
159
|
<Svg
|
|
@@ -2,6 +2,7 @@ import { ColorValue, ViewStyle, TextStyle } from "react-native";
|
|
|
2
2
|
import { deepMerge } from "../shared/helper/helperFunctions";
|
|
3
3
|
import { CometChatTheme } from "../theme/type";
|
|
4
4
|
import { DeepPartial } from "../shared/helper/types";
|
|
5
|
+
import { TEXT_START } from "../shared/helper/layoutDirection";
|
|
5
6
|
|
|
6
7
|
export type ChatHistoryStyle = {
|
|
7
8
|
containerStyle: ViewStyle;
|
|
@@ -57,7 +58,7 @@ export const getChatHistoryStyleLight = (
|
|
|
57
58
|
fontSize: typography.heading4.medium.fontSize,
|
|
58
59
|
fontWeight: typography.heading4.medium.fontWeight,
|
|
59
60
|
color: color.textPrimary,
|
|
60
|
-
|
|
61
|
+
marginStart: spacing.margin.m2,
|
|
61
62
|
...typography.heading4.medium,
|
|
62
63
|
fontFamily: typography.heading4.medium.fontFamily,
|
|
63
64
|
},
|
|
@@ -81,7 +82,7 @@ export const getChatHistoryStyleLight = (
|
|
|
81
82
|
},
|
|
82
83
|
newChatTextStyle: {
|
|
83
84
|
fontSize: typography.body.regular.fontSize,
|
|
84
|
-
|
|
85
|
+
marginStart: spacing.margin.m3,
|
|
85
86
|
fontWeight: typography.body.regular.fontWeight,
|
|
86
87
|
color: color.textPrimary,
|
|
87
88
|
...typography.body.regular,
|
|
@@ -96,6 +97,7 @@ export const getChatHistoryStyleLight = (
|
|
|
96
97
|
borderBottomColor: color.borderLight,
|
|
97
98
|
},
|
|
98
99
|
sectionHeaderTextStyle: {
|
|
100
|
+
...TEXT_START,
|
|
99
101
|
fontSize: typography.caption1.medium.fontSize,
|
|
100
102
|
fontWeight: typography.caption1.medium.fontWeight,
|
|
101
103
|
textTransform: 'capitalize',
|
|
@@ -106,6 +108,7 @@ export const getChatHistoryStyleLight = (
|
|
|
106
108
|
paddingVertical: spacing.padding.p3,
|
|
107
109
|
},
|
|
108
110
|
messageTextStyle: {
|
|
111
|
+
...TEXT_START,
|
|
109
112
|
fontSize: typography.body.regular.fontSize,
|
|
110
113
|
lineHeight: 20,
|
|
111
114
|
color: color.textPrimary,
|