@cometchat/chat-uikit-react-native 4.2.2 → 4.3.1
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/README.md +26 -67
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +2 -1
- package/android/src/main/java/com/reactnativecometchatuikit/ReactVideoView.java +796 -0
- package/android/src/main/java/com/reactnativecometchatuikit/ReactVideoViewManager.java +172 -0
- package/android/src/main/java/com/scalablevideoview/BuildConfig.java +10 -0
- package/android/src/main/java/com/scalablevideoview/PivotPoint.java +13 -0
- package/android/src/main/java/com/scalablevideoview/ScalableType.java +34 -0
- package/android/src/main/java/com/scalablevideoview/ScalableVideoView.java +255 -0
- package/android/src/main/java/com/scalablevideoview/ScaleManager.java +188 -0
- package/android/src/main/java/com/scalablevideoview/Size.java +20 -0
- package/android/src/main/java/com/zipfile/APEZProvider.java +287 -0
- package/android/src/main/java/com/zipfile/APKExpansionSupport.java +81 -0
- package/android/src/main/java/com/zipfile/ZipResourceFile.java +428 -0
- package/android/src/main/res/values/attrs.xml +37 -0
- package/ios/FileManager.m +75 -5
- package/ios/Video/CCRCTVideo.h +67 -0
- package/ios/Video/CCRCTVideo.m +2031 -0
- package/ios/Video/CCRCTVideoManager.h +6 -0
- package/ios/Video/CCRCTVideoManager.m +133 -0
- package/ios/Video/CCRCTVideoPlayerViewController.h +20 -0
- package/ios/Video/CCRCTVideoPlayerViewController.m +43 -0
- package/ios/Video/CCRCTVideoPlayerViewControllerDelegate.h +7 -0
- package/ios/Video/UIView+FindUIViewController.h +15 -0
- package/ios/Video/UIView+FindUIViewController.m +21 -0
- package/ios/VideoCaching/RCTVideoCache.h +38 -0
- package/ios/VideoCaching/RCTVideoCache.m +174 -0
- package/ios/VideoPickerModule.h +7 -0
- package/ios/VideoPickerModule.mm +95 -0
- package/package.json +3 -4
- package/react-native-cometchat-ui-kit.podspec +24 -10
- package/src/CometChatContacts/CometChatContacts.tsx +12 -9
- package/src/CometChatConversations/CometChatConversations.tsx +84 -64
- package/src/CometChatDetails/CometChatDetails.tsx +14 -12
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +8 -4
- package/src/CometChatGroupMembers/resources/check.png +0 -0
- package/src/CometChatGroupMembers/resources/index.ts +2 -0
- package/src/CometChatGroups/CometChatGroups.tsx +4 -4
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +57 -15
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +9 -2
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +1 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +596 -181
- package/src/CometChatMessageList/MessageListConfiguration.ts +55 -4
- package/src/CometChatMessageList/resources/index.ts +5 -1
- package/src/CometChatMessageList/resources/leftarrowcurve.png +0 -0
- package/src/CometChatMessageList/resources/rightarrowcurve.png +0 -0
- package/src/CometChatMessages/CometChatMessages.tsx +1 -1
- package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +4 -12
- package/src/CometChatThreadedMessages/style.ts +3 -1
- package/src/CometChatUsers/CometChatUsers.tsx +1 -1
- package/src/calls/CallUtils.ts +4 -8
- package/src/calls/CallingExtentionDecorator.tsx +5 -2
- package/src/calls/CometChatCallBubble/styles.ts +2 -1
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +14 -3
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +9 -9
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +80 -73
- package/src/extensions/CollaborativeBubble/styles.ts +2 -0
- package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +11 -0
- package/src/extensions/index.ts +0 -4
- package/src/index.ts +53 -8
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +14 -2
- package/src/shared/constants/UIKitConstants.ts +1 -0
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +6 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +8 -0
- package/src/shared/events/ListenerInitializer.ts +6 -0
- package/src/shared/events/messages.ts +2 -0
- package/src/shared/framework/MessageDataSource.tsx +29 -25
- package/src/shared/index.ts +49 -1
- package/src/shared/libs/VideoPlayer/DRMType.js +6 -0
- package/src/shared/libs/VideoPlayer/FilterType.js +18 -0
- package/src/shared/libs/VideoPlayer/TextTrackType.js +5 -0
- package/src/shared/libs/VideoPlayer/Video.js +519 -0
- package/src/shared/libs/VideoPlayer/VideoResizeMode.js +5 -0
- package/src/shared/libs/VideoPlayerControls/OSSupport/PlatformSupport.tsx +43 -0
- package/src/shared/libs/VideoPlayerControls/OSSupport/TVOSSupport.tsx +16 -0
- package/src/shared/libs/VideoPlayerControls/OSSupport/index.tsx +1 -0
- package/src/shared/libs/VideoPlayerControls/VideoPlayer.tsx +511 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/back.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/back@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/back@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/bottom-vignette@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/error-icon.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/error-icon@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/error-icon@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/expand.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/expand@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/expand@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/forward.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/forward@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/forward@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/loader-icon@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/pause.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/pause@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/pause@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/play.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/play@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/play@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/rewind.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/rewind@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/rewind@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/shrink.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/shrink@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/shrink@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/top-vignette@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/volume.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/volume@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/volume@3x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/components/Back/Back.tsx +28 -0
- package/src/shared/libs/VideoPlayerControls/components/Back/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/BottomControls.tsx +142 -0
- package/src/shared/libs/VideoPlayerControls/components/Control.tsx +45 -0
- package/src/shared/libs/VideoPlayerControls/components/Error/Error.tsx +22 -0
- package/src/shared/libs/VideoPlayerControls/components/Error/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Error/styles.ts +21 -0
- package/src/shared/libs/VideoPlayerControls/components/Fullscreen.tsx +36 -0
- package/src/shared/libs/VideoPlayerControls/components/Loader/Loader.tsx +15 -0
- package/src/shared/libs/VideoPlayerControls/components/Loader/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Loader/styles.ts +16 -0
- package/src/shared/libs/VideoPlayerControls/components/NullControl.tsx +7 -0
- package/src/shared/libs/VideoPlayerControls/components/Overlay.tsx +23 -0
- package/src/shared/libs/VideoPlayerControls/components/PlayPause/PlayPause.tsx +109 -0
- package/src/shared/libs/VideoPlayerControls/components/PlayPause/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/PlayPause/styles.ts +21 -0
- package/src/shared/libs/VideoPlayerControls/components/Seekbar/Seekbar.tsx +47 -0
- package/src/shared/libs/VideoPlayerControls/components/Seekbar/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Seekbar/styles.ts +37 -0
- package/src/shared/libs/VideoPlayerControls/components/Timer/Timer.tsx +28 -0
- package/src/shared/libs/VideoPlayerControls/components/Timer/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Timer/styles.ts +12 -0
- package/src/shared/libs/VideoPlayerControls/components/Title.tsx +35 -0
- package/src/shared/libs/VideoPlayerControls/components/TopControls.tsx +110 -0
- package/src/shared/libs/VideoPlayerControls/components/Volume/Volume.tsx +37 -0
- package/src/shared/libs/VideoPlayerControls/components/Volume/index.ts +1 -0
- package/src/shared/libs/VideoPlayerControls/components/Volume/styles.ts +31 -0
- package/src/shared/libs/VideoPlayerControls/components/index.ts +14 -0
- package/src/shared/libs/VideoPlayerControls/components/styles.ts +30 -0
- package/src/shared/libs/VideoPlayerControls/hooks/index.ts +3 -0
- package/src/shared/libs/VideoPlayerControls/hooks/useAnimations.ts +68 -0
- package/src/shared/libs/VideoPlayerControls/hooks/useControlTimeout.tsx +67 -0
- package/src/shared/libs/VideoPlayerControls/hooks/usePanResponders.tsx +96 -0
- package/src/shared/libs/VideoPlayerControls/index.ts +4 -0
- package/src/shared/libs/VideoPlayerControls/styles.ts +19 -0
- package/src/shared/libs/VideoPlayerControls/types.ts +290 -0
- package/src/shared/libs/VideoPlayerControls/utils.ts +76 -0
- package/src/shared/modals/CometChatMessageTemplate.ts +113 -9
- package/src/shared/modals/InteractiveData/InteractiveMessage/SchedulerMessage.ts +23 -21
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +6 -3
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +4 -1
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +4 -1
- package/src/shared/resources/CometChatTheme/Palette.ts +79 -45
- package/src/shared/resources/CometChatTheme/Typography.ts +18 -0
- package/src/shared/utils/CommonUtils.ts +71 -0
- package/src/shared/utils/PermissionUtilIOS.ts +104 -0
- package/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts +3 -1
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +6 -6
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +28 -5
- package/src/shared/views/CometChatAudioBubble/style.ts +4 -2
- package/src/shared/views/CometChatAvatar/AvatarStyle.ts +1 -1
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +4 -3
- package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +47 -31
- package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardConfiguration.ts +5 -5
- package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardStyle.ts +12 -13
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +52 -5
- package/src/shared/views/CometChatFileBubble/style.ts +4 -2
- package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +25 -2
- package/src/shared/views/CometChatList/CometChatList.tsx +2 -1
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +51 -2
- package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +76 -0
- package/src/shared/views/CometChatQuickReactions/QuickReactionsConfiguration.tsx +12 -0
- package/src/shared/views/CometChatQuickReactions/QuickReactionsStyle.tsx +35 -0
- package/src/shared/views/CometChatQuickReactions/index.ts +12 -0
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +166 -0
- package/src/shared/views/CometChatReactions/ReactionsConfiguration.tsx +12 -0
- package/src/shared/views/CometChatReactions/ReactionsStyle.tsx +43 -0
- package/src/shared/views/CometChatReactions/index.ts +12 -0
- package/src/{extensions/Reactions/CometChatMessageReactions → shared/views/CometChatReactions}/style.ts +7 -7
- package/src/shared/views/CometChatReactionsList/CometChatReactionsList.tsx +335 -0
- package/src/shared/views/CometChatReactionsList/ReactionsListConfiguration.tsx +14 -0
- package/src/shared/views/CometChatReactionsList/ReactionsListStyle.tsx +67 -0
- package/src/shared/views/CometChatReactionsList/index.ts +12 -0
- package/src/shared/views/CometChatReactionsList/resources/Spineer.png +0 -0
- package/src/shared/views/CometChatReactionsList/resources/index.ts +5 -0
- package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +21 -4
- package/src/shared/views/CometChatReceipt/MessageConfiguration.ts +12 -0
- package/src/shared/views/CometChatReceipt/resources/error.png +0 -0
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +1 -1
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +78 -12
- package/src/shared/views/CometChatVideoBubble/VideoBubbleStyle.ts +52 -2
- package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +134 -0
- package/src/shared/views/CometChatVideoPlayer/index.tsx +1 -0
- package/src/shared/views/index.ts +30 -0
- package/android/.gradle/7.4.2/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4.2/gc.properties +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.idea/gradle.xml +0 -13
- package/android/.idea/misc.xml +0 -8
- package/android/.idea/modules/android.iml +0 -18
- package/android/.idea/modules.xml +0 -8
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/src/extensions/Reactions/CometChatMessageReactions/CometChatMessageReactions.tsx +0 -249
- package/src/extensions/Reactions/CometChatMessageReactions/index.ts +0 -3
- package/src/extensions/Reactions/ReactionsDecorator.tsx +0 -164
- package/src/extensions/Reactions/ReactionsExtension.tsx +0 -48
- package/src/extensions/Reactions/index.ts +0 -4
- /package/src/{extensions/Reactions → shared/views/CometChatQuickReactions}/resources/AddReactions.png +0 -0
- /package/src/{extensions/Reactions → shared/views/CometChatQuickReactions}/resources/index.ts +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { forwardRef, useEffect, useRef, useState, useImperativeHandle, useContext, useCallback } from "react";
|
|
1
|
+
import React, { forwardRef, useEffect, useRef, useState, useImperativeHandle, useContext, useCallback, memo, useLayoutEffect } from "react";
|
|
2
2
|
import { View, FlatList, Text, Image, TouchableOpacity, ActivityIndicator, Modal, SafeAreaView, NativeModules, ScrollView, Dimensions, Platform } from "react-native";
|
|
3
3
|
//@ts-ignore
|
|
4
4
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
5
|
-
import {
|
|
5
|
+
import { LeftArrowCurve, RightArrowCurve } from "./resources";
|
|
6
6
|
import { BaseStyle, BaseStyleInterface, CometChatContext, CometChatLiveReactions, CometChatUIKit, ImageType } from "../shared";
|
|
7
7
|
import { MessageBubbleStyle, MessageBubbleStyleInterface } from "../shared/views/CometChatMessageBubble/MessageBubbleStyle";
|
|
8
8
|
import { AvatarStyle, AvatarStyleInterface } from "../shared";
|
|
@@ -23,11 +23,16 @@ import { DateStyleInterface } from "../shared/views/CometChatDate/DateStyle";
|
|
|
23
23
|
import { CometChatContextType } from "../shared/base/Types";
|
|
24
24
|
import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
|
|
25
25
|
import { ActionSheetStylesInterface } from "../shared/views/CometChatActionSheet/ActionSheetStyle";
|
|
26
|
-
import Clipboard from "@react-native-
|
|
26
|
+
import Clipboard from "@react-native-clipboard/clipboard";
|
|
27
27
|
import { CometChatMessageInformation } from "../CometChatMessageInformation/CometChatMessageInformation";
|
|
28
28
|
// import { CometChatContacts, ForwardMessageConfigurationInterface } from "../CometChatContacts";
|
|
29
29
|
import { MessageInformationConfigurationInterface } from "../CometChatMessageInformation";
|
|
30
30
|
import { InteractiveMessageUtils } from "../shared/utils/InteractiveMessageUtils";
|
|
31
|
+
import { CometChatEmojiKeyboard, EmojiKeyboardStyle } from "../shared/views/CometChatEmojiKeyboard";
|
|
32
|
+
import { CometChatReactionsList, ReactionsListConfigurationInterface } from "../shared/views/CometChatReactionsList";
|
|
33
|
+
import { CometChatQuickReactions, QuickReactionsConfigurationInterface } from "../shared/views/CometChatQuickReactions";
|
|
34
|
+
import { CometChatReactions, ReactionsConfigurationInterface } from "../shared/views/CometChatReactions";
|
|
35
|
+
import { CommonUtils } from "../shared/utils/CommonUtils";
|
|
31
36
|
|
|
32
37
|
let templatesMap = new Map<string, CometChatMessageTemplate>();
|
|
33
38
|
|
|
@@ -72,7 +77,31 @@ export interface CometChatMessageListProps {
|
|
|
72
77
|
onError?: (e: CometChat.CometChatException) => void,
|
|
73
78
|
onBack?: () => void,
|
|
74
79
|
// forwardMessageConfiguration?: ForwardMessageConfigurationInterface,
|
|
75
|
-
messageInformationConfiguration?: MessageInformationConfigurationInterface
|
|
80
|
+
messageInformationConfiguration?: MessageInformationConfigurationInterface,
|
|
81
|
+
/**
|
|
82
|
+
* Hide the header of the action sheet
|
|
83
|
+
*/
|
|
84
|
+
hideActionSheetHeader?: boolean,
|
|
85
|
+
/**
|
|
86
|
+
* Message Reaction Configuration @ReactionsConfigurationInterface
|
|
87
|
+
*/
|
|
88
|
+
reactionsConfiguration?: ReactionsConfigurationInterface,
|
|
89
|
+
/**
|
|
90
|
+
* Message Reaction List Configuration @ReactionsListConfigurationInterface
|
|
91
|
+
*/
|
|
92
|
+
reactionsListConfiguration?: ReactionsListConfigurationInterface,
|
|
93
|
+
/**
|
|
94
|
+
* Quick Reaction Configuration @QuickReactionsConfigurationInterface
|
|
95
|
+
*/
|
|
96
|
+
quickReactionConfiguration?: QuickReactionsConfigurationInterface,
|
|
97
|
+
/**
|
|
98
|
+
* Emoji Keyboard style @EmojiKeyboardStyle
|
|
99
|
+
*/
|
|
100
|
+
emojiKeyboardStyle?: EmojiKeyboardStyle,
|
|
101
|
+
/**
|
|
102
|
+
* Disables the reactions functionality
|
|
103
|
+
*/
|
|
104
|
+
disableReactions?: boolean,
|
|
76
105
|
}
|
|
77
106
|
|
|
78
107
|
export interface CometChatMessageListActionsInterface {
|
|
@@ -85,7 +114,7 @@ export interface CometChatMessageListActionsInterface {
|
|
|
85
114
|
updateMessageReceipt: (message: CometChat.BaseMessage) => void
|
|
86
115
|
}
|
|
87
116
|
|
|
88
|
-
export const CometChatMessageList = forwardRef<
|
|
117
|
+
export const CometChatMessageList = memo(forwardRef<
|
|
89
118
|
CometChatMessageListActionsInterface,
|
|
90
119
|
CometChatMessageListProps>
|
|
91
120
|
((props: CometChatMessageListProps, ref) => {
|
|
@@ -95,11 +124,11 @@ export const CometChatMessageList = forwardRef<
|
|
|
95
124
|
user,
|
|
96
125
|
group,
|
|
97
126
|
EmptyStateView,
|
|
98
|
-
emptyStateText,
|
|
127
|
+
emptyStateText = localize("NO_MESSAGES_FOUND"),
|
|
99
128
|
ErrorStateView,
|
|
100
|
-
errorStateText,
|
|
129
|
+
errorStateText = localize("SOMETHING_WRONG"),
|
|
101
130
|
LoadingStateView,
|
|
102
|
-
disableReceipt,
|
|
131
|
+
disableReceipt = false,
|
|
103
132
|
disableSoundForMessages,
|
|
104
133
|
customSoundForMessages,
|
|
105
134
|
readIcon,
|
|
@@ -107,12 +136,12 @@ export const CometChatMessageList = forwardRef<
|
|
|
107
136
|
sentIcon,
|
|
108
137
|
waitIcon,
|
|
109
138
|
errorIcon,
|
|
110
|
-
alignment,
|
|
111
|
-
showAvatar,
|
|
139
|
+
alignment = "standard",
|
|
140
|
+
showAvatar = true,
|
|
112
141
|
datePattern,
|
|
113
|
-
timeStampAlignment,
|
|
142
|
+
timeStampAlignment = "bottom",
|
|
114
143
|
dateSeperatorPattern,
|
|
115
|
-
templates,
|
|
144
|
+
templates = [],
|
|
116
145
|
messageRequestBuilder,
|
|
117
146
|
newMessageIndicatorText,
|
|
118
147
|
scrollToBottomOnNewMessages,
|
|
@@ -127,7 +156,13 @@ export const CometChatMessageList = forwardRef<
|
|
|
127
156
|
onError,
|
|
128
157
|
onBack,
|
|
129
158
|
// forwardMessageConfiguration
|
|
130
|
-
messageInformationConfiguration
|
|
159
|
+
messageInformationConfiguration,
|
|
160
|
+
hideActionSheetHeader,
|
|
161
|
+
reactionsConfiguration,
|
|
162
|
+
disableReactions,
|
|
163
|
+
reactionsListConfiguration,
|
|
164
|
+
quickReactionConfiguration,
|
|
165
|
+
emojiKeyboardStyle,
|
|
131
166
|
} = props;
|
|
132
167
|
|
|
133
168
|
const callListenerId = "call_" + new Date().getTime();
|
|
@@ -138,26 +173,56 @@ export const CometChatMessageList = forwardRef<
|
|
|
138
173
|
const uiEventListenerHide = "uiEvent_hide_" + new Date().getTime();
|
|
139
174
|
const connectionListenerId = 'connectionListener_' + new Date().getTime();
|
|
140
175
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
176
|
+
useLayoutEffect(() => {
|
|
177
|
+
if (user) {
|
|
178
|
+
_defaultRequestBuilder = new CometChat.MessagesRequestBuilder()
|
|
179
|
+
.setLimit(30)
|
|
180
|
+
.setTags([])
|
|
181
|
+
.setUID(user["uid"]);
|
|
182
|
+
}
|
|
183
|
+
else if (group) {
|
|
184
|
+
_defaultRequestBuilder = new CometChat.MessagesRequestBuilder()
|
|
185
|
+
.setLimit(30)
|
|
186
|
+
.setTags([])
|
|
187
|
+
.setGUID(group["guid"]);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
_defaultRequestBuilder.setTypes(ChatConfigurator.dataSource.getAllMessageTypes())
|
|
191
|
+
_defaultRequestBuilder.setCategories(ChatConfigurator.dataSource.getAllMessageCategories())
|
|
192
|
+
|
|
193
|
+
//updating users request builder
|
|
194
|
+
let _updatedCustomRequestBuilder = _defaultRequestBuilder;
|
|
195
|
+
if (messageRequestBuilder) {
|
|
196
|
+
_updatedCustomRequestBuilder = messageRequestBuilder;
|
|
197
|
+
}
|
|
198
|
+
_updatedCustomRequestBuilder.hideReplies(true);
|
|
199
|
+
if (user)
|
|
200
|
+
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setUID(user["uid"])
|
|
201
|
+
if (group)
|
|
202
|
+
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setGUID(group["guid"])
|
|
203
|
+
if (parentMessageId)
|
|
204
|
+
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setParentMessageId(parseInt(parentMessageId));
|
|
205
|
+
let types = [], categories = [];
|
|
206
|
+
if (templates.length) {
|
|
207
|
+
types = templates.map(template => template.type);
|
|
208
|
+
categories = templates.map(template => template.category);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
types = ChatConfigurator.dataSource.getAllMessageTypes();
|
|
212
|
+
categories = ChatConfigurator.dataSource.getAllMessageCategories();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setTypes(types);
|
|
216
|
+
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setCategories(categories);
|
|
153
217
|
|
|
154
|
-
|
|
155
|
-
|
|
218
|
+
msgRequestBuilder.current = _updatedCustomRequestBuilder;
|
|
219
|
+
|
|
220
|
+
}, []);
|
|
156
221
|
|
|
157
222
|
const { theme } = useContext<CometChatContextType>(CometChatContext);
|
|
158
223
|
|
|
159
224
|
// creating style based on styles from users
|
|
160
|
-
const _messageListStyle = new MessageListStyle({
|
|
225
|
+
const _messageListStyle = useRef(new MessageListStyle({
|
|
161
226
|
backgroundColor: theme?.palette.getBackgroundColor(),
|
|
162
227
|
emptyStateTextColor: theme?.palette.getError(),
|
|
163
228
|
emptyStateTextFont: theme?.typography.subtitle1,
|
|
@@ -173,28 +238,28 @@ export const CometChatMessageList = forwardRef<
|
|
|
173
238
|
timestampTextColor: theme?.palette.getAccent500(),
|
|
174
239
|
timestampTextFont: theme?.typography.caption1,
|
|
175
240
|
...messageListStyle
|
|
176
|
-
});
|
|
177
|
-
const _avatarStyle = new AvatarStyle({
|
|
178
|
-
backgroundColor: _messageListStyle.backgroundColor,
|
|
241
|
+
})).current;
|
|
242
|
+
const _avatarStyle = useRef(new AvatarStyle({
|
|
179
243
|
nameTextColor: _messageListStyle.nameTextColor,
|
|
180
244
|
nameTextFont: _messageListStyle.nameTextFont,
|
|
181
245
|
...avatarStyle
|
|
182
|
-
});
|
|
183
|
-
const _dateSeperatorStyle = new DateStyle({
|
|
246
|
+
})).current;
|
|
247
|
+
const _dateSeperatorStyle = useRef(new DateStyle({
|
|
184
248
|
textColor: _messageListStyle.timestampTextColor,
|
|
185
249
|
textFont: theme?.typography.title2,
|
|
186
250
|
...dateSeperatorStyle
|
|
187
|
-
});
|
|
188
|
-
const messageBubbleDateStyle = new DateStyle({
|
|
251
|
+
})).current;
|
|
252
|
+
const messageBubbleDateStyle = useRef(new DateStyle({
|
|
189
253
|
textColor: _messageListStyle.timestampTextColor,
|
|
190
254
|
textFont: _messageListStyle.timestampTextFont
|
|
191
|
-
});
|
|
192
|
-
const _actionStyle = new ActionSheetStyles({
|
|
255
|
+
})).current;
|
|
256
|
+
const _actionStyle = useRef(new ActionSheetStyles({
|
|
257
|
+
actionSheetSeparatorTint: 'transparent',
|
|
193
258
|
...actionSheetStyle
|
|
194
|
-
});
|
|
195
|
-
const _messageBubbleStyle = new MessageBubbleStyle({
|
|
259
|
+
})).current;
|
|
260
|
+
const _messageBubbleStyle = useRef(new MessageBubbleStyle({
|
|
196
261
|
...wrapperMessageBubbleStyle
|
|
197
|
-
});
|
|
262
|
+
})).current;
|
|
198
263
|
|
|
199
264
|
// refs
|
|
200
265
|
const currentScrollPosition = useRef({ y: null, scrollViewHeight: 0, layoutHeight: 0 });
|
|
@@ -204,33 +269,9 @@ export const CometChatMessageList = forwardRef<
|
|
|
204
269
|
const messageListRef = useRef<ScrollView>(null);
|
|
205
270
|
const loggedInUser = useRef<CometChat.User>(null);
|
|
206
271
|
const messageRequest = useRef<CometChat.MessagesRequest>(null);
|
|
272
|
+
const messagesContentListRef = useRef([]);
|
|
207
273
|
|
|
208
|
-
|
|
209
|
-
let _updatedCustomRequestBuilder = _defaultRequestBuilder;
|
|
210
|
-
if (messageRequestBuilder) {
|
|
211
|
-
_updatedCustomRequestBuilder = messageRequestBuilder;
|
|
212
|
-
}
|
|
213
|
-
_updatedCustomRequestBuilder.hideReplies(true);
|
|
214
|
-
if (user)
|
|
215
|
-
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setUID(user["uid"])
|
|
216
|
-
if (group)
|
|
217
|
-
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setGUID(group["guid"])
|
|
218
|
-
if (parentMessageId)
|
|
219
|
-
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setParentMessageId(parseInt(parentMessageId));
|
|
220
|
-
let types = [], categories = [];
|
|
221
|
-
if (templates.length) {
|
|
222
|
-
types = templates.map(template => template.type);
|
|
223
|
-
categories = templates.map(template => template.category);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
types = ChatConfigurator.dataSource.getAllMessageTypes();
|
|
227
|
-
categories = ChatConfigurator.dataSource.getAllMessageCategories();
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setTypes(types);
|
|
231
|
-
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setCategories(categories);
|
|
232
|
-
|
|
233
|
-
const msgRequestBuilder = useRef<CometChat.MessagesRequestBuilder>(_updatedCustomRequestBuilder);
|
|
274
|
+
const msgRequestBuilder = useRef<CometChat.MessagesRequestBuilder>();
|
|
234
275
|
const lastMessageDate = useRef(new Date().getTime());
|
|
235
276
|
|
|
236
277
|
// states
|
|
@@ -244,9 +285,14 @@ export const CometChatMessageList = forwardRef<
|
|
|
244
285
|
const [CustomListHeader, setCustomListHeader] = useState(null);
|
|
245
286
|
const [messageInfo, setMessageInfo] = useState(false);
|
|
246
287
|
const [ongoingCallView, setOngoingCallView] = useState(null);
|
|
288
|
+
const [selectedMessage, setSelectedMessage] = useState(null);
|
|
289
|
+
const [showEmojiKeyboard, setShowEmojiKeyboard] = useState(false);
|
|
290
|
+
const [showReactionsList, setShowReactionsList] = useState(false);
|
|
291
|
+
const [selectedEmoji, setSelectedEmoji] = useState(null);
|
|
247
292
|
// const [forwarding, setForwarding] = useState(false);
|
|
248
293
|
|
|
249
294
|
const infoObject = useRef<CometChat.BaseMessage>();
|
|
295
|
+
const inProgressMessages = useRef([]);
|
|
250
296
|
// const messageToForward = useRef<CometChat.BaseMessage>();
|
|
251
297
|
const bottomSheetRef = useRef(null)
|
|
252
298
|
const conversationId = useRef(null)
|
|
@@ -277,7 +323,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
277
323
|
|
|
278
324
|
const markUnreadMessageAsRead = () => {
|
|
279
325
|
for (let index = 0; index < unreadCount; index++) {
|
|
280
|
-
const message =
|
|
326
|
+
const message = messagesContentListRef.current[messagesContentListRef.current.length - (index + 1)];
|
|
281
327
|
if (index == 0)
|
|
282
328
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageRead, { message });
|
|
283
329
|
CometChat.markAsRead(message);
|
|
@@ -288,7 +334,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
288
334
|
const newMsgIndicatorPressed = () => {
|
|
289
335
|
scrollToBottom();
|
|
290
336
|
markUnreadMessageAsRead();
|
|
291
|
-
}
|
|
337
|
+
};
|
|
292
338
|
|
|
293
339
|
const getPreviousMessages = async () => {
|
|
294
340
|
|
|
@@ -334,7 +380,11 @@ export const CometChatMessageList = forwardRef<
|
|
|
334
380
|
return item;
|
|
335
381
|
}
|
|
336
382
|
})
|
|
337
|
-
reversed.length > 0
|
|
383
|
+
if (reversed.length > 0) {
|
|
384
|
+
let reversedData = [...reversed.reverse()];
|
|
385
|
+
messagesContentListRef.current = [...reversedData, ...messagesContentListRef.current];
|
|
386
|
+
setMessagesList([...reversedData, ...messagesList]);
|
|
387
|
+
}
|
|
338
388
|
if (messagesList.length == 0)
|
|
339
389
|
setListState("");
|
|
340
390
|
else
|
|
@@ -346,7 +396,6 @@ export const CometChatMessageList = forwardRef<
|
|
|
346
396
|
setListState("error");
|
|
347
397
|
else
|
|
348
398
|
setLoadingMessages(false);
|
|
349
|
-
console.log(e);
|
|
350
399
|
onError && onError(e)
|
|
351
400
|
})
|
|
352
401
|
}
|
|
@@ -365,6 +414,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
365
414
|
messagesRequest.build()
|
|
366
415
|
.fetchNext()
|
|
367
416
|
.then(updatedMessages => {
|
|
417
|
+
if (!updatedMessages.length) return;
|
|
368
418
|
let tmpList = [...messagesList];
|
|
369
419
|
for (let i = 0; i < updatedMessages.length; i++) {
|
|
370
420
|
let condition = (msg) => msg.getId() == updatedMessages[i]?.actionOn.getId()
|
|
@@ -409,6 +459,14 @@ export const CometChatMessageList = forwardRef<
|
|
|
409
459
|
return item;
|
|
410
460
|
}
|
|
411
461
|
})
|
|
462
|
+
if (inProgressMessages.current.length) {
|
|
463
|
+
const filteredInProgressMessages = inProgressMessages.current.filter(secondItem =>
|
|
464
|
+
!tmpList.some(firstItem => firstItem.muid === secondItem.muid)
|
|
465
|
+
);
|
|
466
|
+
const combinedArray = tmpList.concat(filteredInProgressMessages);
|
|
467
|
+
tmpList = combinedArray
|
|
468
|
+
}
|
|
469
|
+
messagesContentListRef.current = tmpList;
|
|
412
470
|
setMessagesList(tmpList);
|
|
413
471
|
markMessageAsRead(tmpList[0]);
|
|
414
472
|
if (newMessages.length === 30) {
|
|
@@ -418,16 +476,16 @@ export const CometChatMessageList = forwardRef<
|
|
|
418
476
|
.catch(e => console.log("error while fetching updated msgs", e))
|
|
419
477
|
}
|
|
420
478
|
|
|
421
|
-
const loadTemplates = () => {
|
|
479
|
+
const loadTemplates = useCallback(() => {
|
|
422
480
|
let templates: CometChatMessageTemplate[] = ChatConfigurator.dataSource.getAllMessageTemplates(theme);
|
|
423
481
|
templates.forEach(template => {
|
|
424
482
|
|
|
425
483
|
if (templatesMap.get(`${template.category}_${template.type}`)) return
|
|
426
484
|
templatesMap.set(`${template.category}_${template.type}`, template);
|
|
427
485
|
});
|
|
428
|
-
}
|
|
486
|
+
}, [])
|
|
429
487
|
|
|
430
|
-
const playNotificationSound = (message) => {
|
|
488
|
+
const playNotificationSound = useCallback((message) => {
|
|
431
489
|
|
|
432
490
|
if (disableSoundForMessages) return;
|
|
433
491
|
|
|
@@ -444,10 +502,10 @@ export const CometChatMessageList = forwardRef<
|
|
|
444
502
|
);
|
|
445
503
|
}
|
|
446
504
|
}
|
|
447
|
-
};
|
|
505
|
+
}, []);
|
|
448
506
|
|
|
449
|
-
const scrollToBottom = (scrollToFirstUnread = false) => {
|
|
450
|
-
if (messageListRef &&
|
|
507
|
+
const scrollToBottom = useCallback((scrollToFirstUnread = false) => {
|
|
508
|
+
if (messageListRef.current && messagesContentListRef.current.length > 0) {
|
|
451
509
|
let firstUnreadPosition = previousScrollPosition.current.scrollViewHeight;
|
|
452
510
|
if (scrollToFirstUnread) {
|
|
453
511
|
setTimeout(() => {
|
|
@@ -459,7 +517,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
459
517
|
}, 0)
|
|
460
518
|
}
|
|
461
519
|
}
|
|
462
|
-
};
|
|
520
|
+
}, []);
|
|
463
521
|
|
|
464
522
|
const markMessageAsRead = (message) => {
|
|
465
523
|
if (!disableReceipt && !message?.readAt) {
|
|
@@ -474,20 +532,20 @@ export const CometChatMessageList = forwardRef<
|
|
|
474
532
|
};
|
|
475
533
|
|
|
476
534
|
function checkMessageInSameConversation(message: CometChat.BaseMessage): boolean {
|
|
477
|
-
return (message
|
|
535
|
+
return (message?.getReceiverType() == ReceiverTypeConstants.user &&
|
|
478
536
|
user &&
|
|
479
537
|
user?.getUid() == message.getReceiver()?.['uid']) ||
|
|
480
|
-
(message
|
|
538
|
+
(message?.getReceiverType() == ReceiverTypeConstants.group &&
|
|
481
539
|
message.getReceiverId() &&
|
|
482
540
|
group &&
|
|
483
541
|
group?.getGuid() == message.getReceiverId());
|
|
484
542
|
}
|
|
485
543
|
|
|
486
544
|
function messageToSameConversation(message: CometChat.BaseMessage): boolean {
|
|
487
|
-
return (message
|
|
545
|
+
return (message?.getReceiverType() == ReceiverTypeConstants.user &&
|
|
488
546
|
user &&
|
|
489
547
|
user?.getUid() == message.getReceiverId()) ||
|
|
490
|
-
(message
|
|
548
|
+
(message?.getReceiverType() == ReceiverTypeConstants.group &&
|
|
491
549
|
message.getReceiverId() &&
|
|
492
550
|
group &&
|
|
493
551
|
group?.getGuid() == message.getReceiverId());
|
|
@@ -502,34 +560,45 @@ export const CometChatMessageList = forwardRef<
|
|
|
502
560
|
newMessage = InteractiveMessageUtils.convertInteractiveMessage(baseMessage);
|
|
503
561
|
}
|
|
504
562
|
if (checkSameConversation(baseMessage) || checkMessageInSameConversation(baseMessage) || messageToSameConversation(baseMessage)) {
|
|
505
|
-
//need to add
|
|
563
|
+
//need to add
|
|
506
564
|
if (baseMessage.getParentMessageId()) {
|
|
507
565
|
if (baseMessage.getParentMessageId() == parseInt(parentMessageId)) {
|
|
508
566
|
// add to list
|
|
509
|
-
|
|
567
|
+
messagesContentListRef.current = [...messagesContentListRef.current, newMessage];
|
|
568
|
+
inProgressMessages.current = [...inProgressMessages.current, newMessage]
|
|
569
|
+
setMessagesList(prev => [...prev, newMessage]);
|
|
510
570
|
} else {
|
|
511
571
|
//increase count
|
|
512
572
|
let index = messagesList.findIndex(msg => msg.id === newMessage.parentMessageId);
|
|
513
|
-
let oldMsg: CometChat.BaseMessage = messagesList[index];
|
|
573
|
+
let oldMsg: CometChat.BaseMessage = CommonUtils.clone(messagesList[index]);
|
|
514
574
|
oldMsg.setReplyCount(oldMsg.getReplyCount() ? oldMsg.getReplyCount() + 1 : 1);
|
|
575
|
+
// if ((newMessage?.sender?.uid !== loggedInUser.current?.['uid'])) {
|
|
576
|
+
// oldMsg.setUnreadReplyCount(oldMsg.getUnreadReplyCount() ? oldMsg.getUnreadReplyCount() + 1 : 1);
|
|
577
|
+
// }
|
|
515
578
|
let tmpList = [...messagesList];
|
|
516
579
|
tmpList[index] = oldMsg;
|
|
580
|
+
messagesContentListRef.current = tmpList;
|
|
517
581
|
setMessagesList(tmpList);
|
|
582
|
+
inProgressMessages.current = [...inProgressMessages.current, newMessage]
|
|
518
583
|
}
|
|
519
584
|
} else if (parentMessageId == undefined) {
|
|
520
|
-
|
|
585
|
+
messagesContentListRef.current = [...messagesContentListRef.current, newMessage];
|
|
586
|
+
inProgressMessages.current = [...inProgressMessages.current, newMessage]
|
|
587
|
+
setMessagesList(prev => [...prev, newMessage]);
|
|
521
588
|
}
|
|
522
589
|
// if scroll is not at bottom
|
|
523
|
-
if (!scrollToBottomOnNewMessages && (Math.round(currentScrollPosition.current.y) <= currentScrollPosition.current.scrollViewHeight)) {
|
|
524
|
-
if ((baseMessage.getSender()?.getUid() || baseMessage?.['sender']?.['uid']) == loggedInUser.current?.['uid']) {
|
|
590
|
+
if (!scrollToBottomOnNewMessages && currentScrollPosition.current.y && (Math.round(currentScrollPosition.current.y) <= currentScrollPosition.current.scrollViewHeight)) {
|
|
591
|
+
if ((parentMessageId && newMessage.parentMessageId == parseInt(parentMessageId)) || (!parentMessageId && !newMessage.parentMessageId && (baseMessage.getSender()?.getUid() || baseMessage?.['sender']?.['uid']) == loggedInUser.current?.['uid'])) {
|
|
525
592
|
scrollToBottom();
|
|
526
593
|
return;
|
|
527
594
|
}
|
|
528
595
|
CometChat.markAsDelivered(newMessage);
|
|
529
|
-
if (baseMessage
|
|
596
|
+
if (baseMessage?.getReceiverType() == ReceiverTypeConstants.user) {
|
|
530
597
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageDelivered, { message: newMessage });
|
|
531
598
|
}
|
|
532
|
-
|
|
599
|
+
if ((!parentMessageId && !(newMessage.parentMessageId)) || (parentMessageId && newMessage.parentMessageId == parseInt(parentMessageId))) {
|
|
600
|
+
setUnreadCount(unreadCount + 1);
|
|
601
|
+
}
|
|
533
602
|
} else {
|
|
534
603
|
scrollToBottom();
|
|
535
604
|
if (isReceived) {
|
|
@@ -541,10 +610,27 @@ export const CometChatMessageList = forwardRef<
|
|
|
541
610
|
playNotificationSound(newMessage);
|
|
542
611
|
}
|
|
543
612
|
|
|
613
|
+
const markParentMessageAsRead = (message: CometChat.BaseMessage) => {
|
|
614
|
+
let condition: (value: any, index: number, obj: any[]) => unknown;
|
|
615
|
+
condition = (msg) => msg.getId() == message?.['parentMessageId'];
|
|
616
|
+
let msgIndex = messagesList.findIndex(condition);
|
|
617
|
+
if (msgIndex > -1) {
|
|
618
|
+
let tmpList = [...messagesList];
|
|
619
|
+
if (message.getCategory() === MessageCategoryConstants.interactive) {
|
|
620
|
+
message = InteractiveMessageUtils.convertInteractiveMessage(message);
|
|
621
|
+
}
|
|
622
|
+
tmpList[msgIndex]?.setUnreadReplyCount(0);
|
|
623
|
+
messagesContentListRef.current = tmpList;
|
|
624
|
+
setMessagesList(tmpList);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
544
628
|
const messageEdited = (editedMessage: CometChat.BaseMessage, withMuid: boolean = false) => {
|
|
545
629
|
let condition: (value: any, index: number, obj: any[]) => unknown;
|
|
546
|
-
if (withMuid)
|
|
630
|
+
if (withMuid) {
|
|
547
631
|
condition = (msg) => msg['muid'] == editedMessage['muid']
|
|
632
|
+
inProgressMessages.current = inProgressMessages.current.filter(item => item.muid !== editedMessage['muid'])
|
|
633
|
+
}
|
|
548
634
|
else
|
|
549
635
|
condition = (msg) => msg.getId() == editedMessage.getId()
|
|
550
636
|
let msgIndex = messagesList.findIndex(condition);
|
|
@@ -553,7 +639,8 @@ export const CometChatMessageList = forwardRef<
|
|
|
553
639
|
if (editedMessage.getCategory() === MessageCategoryConstants.interactive) {
|
|
554
640
|
editedMessage = InteractiveMessageUtils.convertInteractiveMessage(editedMessage);
|
|
555
641
|
}
|
|
556
|
-
tmpList[msgIndex] = editedMessage;
|
|
642
|
+
tmpList[msgIndex] = CommonUtils.clone(editedMessage);
|
|
643
|
+
messagesContentListRef.current = tmpList;
|
|
557
644
|
setMessagesList(tmpList);
|
|
558
645
|
}
|
|
559
646
|
}
|
|
@@ -564,6 +651,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
564
651
|
|
|
565
652
|
let tmpList = [...messagesList];
|
|
566
653
|
tmpList.splice(msgIndex, 1);
|
|
654
|
+
messagesContentListRef.current = tmpList;
|
|
567
655
|
setMessagesList(tmpList);
|
|
568
656
|
}
|
|
569
657
|
|
|
@@ -579,7 +667,24 @@ export const CometChatMessageList = forwardRef<
|
|
|
579
667
|
})
|
|
580
668
|
}
|
|
581
669
|
|
|
670
|
+
function isLiveReactionOfThisList(transientMessage: any) {
|
|
671
|
+
const receiverType = transientMessage?.receiverType;
|
|
672
|
+
const receiverId = transientMessage?.receiverId;
|
|
673
|
+
if (user) {
|
|
674
|
+
if (receiverType === ReceiverTypeConstants.user && (receiverId === loggedInUser.current?.getUid())) {
|
|
675
|
+
return true
|
|
676
|
+
}
|
|
677
|
+
} else if (group) {
|
|
678
|
+
if (receiverType === ReceiverTypeConstants.group && (receiverId === group.getGuid())) {
|
|
679
|
+
return true
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return false
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
|
|
582
686
|
const showTransientMessage = (transientMessage) => {
|
|
687
|
+
if (!isLiveReactionOfThisList(transientMessage)) return;
|
|
583
688
|
setliveReaction(true);
|
|
584
689
|
setTimeout(() => {
|
|
585
690
|
setliveReaction(false);
|
|
@@ -596,7 +701,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
596
701
|
let tmpList = [...messagesList];
|
|
597
702
|
|
|
598
703
|
let tmpMsg = tmpList[index];
|
|
599
|
-
if ((tmpMsg as CometChat.BaseMessage)
|
|
704
|
+
if ((tmpMsg as CometChat.BaseMessage)?.getReceiverType() == ReceiverTypeConstants.group)
|
|
600
705
|
return;
|
|
601
706
|
if (tmpMsg.getCategory() === MessageCategoryConstants.interactive) {
|
|
602
707
|
tmpMsg = InteractiveMessageUtils.convertInteractiveMessage(tmpMsg);
|
|
@@ -609,14 +714,18 @@ export const CometChatMessageList = forwardRef<
|
|
|
609
714
|
}
|
|
610
715
|
tmpMsg['updatedAt'] = receipt['timestamp'];
|
|
611
716
|
|
|
717
|
+
messagesContentListRef.current = tmpList;
|
|
612
718
|
setMessagesList(tmpList);
|
|
613
719
|
}
|
|
614
720
|
|
|
615
721
|
const handlePannel = (item) => {
|
|
616
|
-
if
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
722
|
+
if(item.alignment === ViewAlignment.messageListBottom && CommonUtils.checkIdBelongsToThisComponent(item.id, user, group,parentMessageId) ){
|
|
723
|
+
if (item.child)
|
|
724
|
+
setCustomListHeader(() => item.child)
|
|
725
|
+
else
|
|
726
|
+
setCustomListHeader(null)
|
|
727
|
+
}
|
|
728
|
+
|
|
620
729
|
}
|
|
621
730
|
|
|
622
731
|
useEffect(() => {
|
|
@@ -668,6 +777,15 @@ export const CometChatMessageList = forwardRef<
|
|
|
668
777
|
useEffect(() => {
|
|
669
778
|
//add listeners
|
|
670
779
|
|
|
780
|
+
let reactionListeners = disableReactions ? {} : {
|
|
781
|
+
onMessageReactionAdded: (reaction: CometChat.ReactionEvent) => {
|
|
782
|
+
updateMessageReaction(reaction, true);
|
|
783
|
+
},
|
|
784
|
+
onMessageReactionRemoved: (reaction: CometChat.ReactionEvent) => {
|
|
785
|
+
updateMessageReaction(reaction, false);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
|
|
671
789
|
CometChat.addGroupListener(
|
|
672
790
|
groupListenerId,
|
|
673
791
|
new CometChat.GroupListener({
|
|
@@ -705,6 +823,9 @@ export const CometChatMessageList = forwardRef<
|
|
|
705
823
|
if (status == MessageStatusConstants.success) {
|
|
706
824
|
messageEdited(message, true);
|
|
707
825
|
}
|
|
826
|
+
if( status == MessageStatusConstants.error) {
|
|
827
|
+
messageEdited(message, true);
|
|
828
|
+
}
|
|
708
829
|
},
|
|
709
830
|
ccMessageEdited: ({ message, status }) => {
|
|
710
831
|
if (status == messageStatus.success)
|
|
@@ -713,6 +834,11 @@ export const CometChatMessageList = forwardRef<
|
|
|
713
834
|
ccMessageDeleted: ({ message }) => {
|
|
714
835
|
messageEdited(message, false);
|
|
715
836
|
},
|
|
837
|
+
ccMessageRead: ({ message }) => {
|
|
838
|
+
if (!parentMessageId && message.parentMessageId) {
|
|
839
|
+
// markParentMessageAsRead(message); //NOTE: uncomment this when want unread count in thread view
|
|
840
|
+
}
|
|
841
|
+
},
|
|
716
842
|
onTextMessageReceived: (textMessage) => {
|
|
717
843
|
newMessage(textMessage);
|
|
718
844
|
},
|
|
@@ -765,6 +891,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
765
891
|
messageEdited(editedMessage);
|
|
766
892
|
}
|
|
767
893
|
},
|
|
894
|
+
...reactionListeners
|
|
768
895
|
}
|
|
769
896
|
)
|
|
770
897
|
CometChatUIEventHandler.addGroupListener(
|
|
@@ -884,9 +1011,15 @@ export const CometChatMessageList = forwardRef<
|
|
|
884
1011
|
}, [messagesList, unreadCount, user, group]);
|
|
885
1012
|
|
|
886
1013
|
useEffect(() => {
|
|
887
|
-
prevMessagesLength.current = messagesLength.current ||
|
|
888
|
-
messagesLength.current =
|
|
889
|
-
}, [
|
|
1014
|
+
prevMessagesLength.current = messagesLength.current || messagesContentListRef.current.length;
|
|
1015
|
+
messagesLength.current = messagesContentListRef.current.length;
|
|
1016
|
+
}, [messagesContentListRef.current])
|
|
1017
|
+
|
|
1018
|
+
useEffect(() => {
|
|
1019
|
+
if (selectedEmoji) {
|
|
1020
|
+
setShowReactionsList(true);
|
|
1021
|
+
}
|
|
1022
|
+
}, [selectedEmoji])
|
|
890
1023
|
|
|
891
1024
|
useImperativeHandle(ref, () => {
|
|
892
1025
|
return {
|
|
@@ -901,12 +1034,72 @@ export const CometChatMessageList = forwardRef<
|
|
|
901
1034
|
}
|
|
902
1035
|
});
|
|
903
1036
|
|
|
1037
|
+
const getMessageById = (messageId: string): CometChat.BaseMessage => {
|
|
1038
|
+
const message = messagesList.find((message) => message.getId() === messageId);
|
|
1039
|
+
return message;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
function isReactionOfThisList(receipt: CometChat.ReactionEvent) {
|
|
1043
|
+
const receiverId = receipt?.getReceiverId();
|
|
1044
|
+
const receiverType = receipt?.getReceiverType();
|
|
1045
|
+
const reactedById = receipt?.getReaction()?.getReactedBy()?.getUid();
|
|
1046
|
+
const parentMessageId = receipt?.getParentMessageId();
|
|
1047
|
+
const listParentMessageId = parentMessageId && String(parentMessageId);
|
|
1048
|
+
if (listParentMessageId) {
|
|
1049
|
+
if (parentMessageId === listParentMessageId) {
|
|
1050
|
+
return true;
|
|
1051
|
+
} else {
|
|
1052
|
+
return false
|
|
1053
|
+
}
|
|
1054
|
+
} else {
|
|
1055
|
+
if (receipt.getParentMessageId()) {
|
|
1056
|
+
return false
|
|
1057
|
+
}
|
|
1058
|
+
if (user) {
|
|
1059
|
+
if (receiverType === ReceiverTypeConstants.user && (receiverId === user.getUid() || reactedById === user.getUid())) {
|
|
1060
|
+
return true
|
|
1061
|
+
}
|
|
1062
|
+
} else if (group) {
|
|
1063
|
+
if (receiverType === ReceiverTypeConstants.group && (receiverId === group.getGuid())) {
|
|
1064
|
+
return true
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
return false
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
const updateMessageReaction = (message: CometChat.ReactionEvent, isAdded: boolean): void => {
|
|
1072
|
+
let _isReactionOfThisList = isReactionOfThisList(message);
|
|
1073
|
+
if (!_isReactionOfThisList) return;
|
|
1074
|
+
|
|
1075
|
+
const messageId = message?.getReaction()?.getMessageId();
|
|
1076
|
+
const messageObject = getMessageById(messageId);
|
|
1077
|
+
if (!messageObject) return;
|
|
1078
|
+
|
|
1079
|
+
let action: any;
|
|
1080
|
+
if (isAdded) {
|
|
1081
|
+
action = CometChat.REACTION_ACTION.REACTION_ADDED;
|
|
1082
|
+
} else {
|
|
1083
|
+
action = CometChat.REACTION_ACTION.REACTION_REMOVED;
|
|
1084
|
+
}
|
|
1085
|
+
const modifiedMessage = CometChat.CometChatHelper.updateMessageWithReactionInfo(
|
|
1086
|
+
messageObject,
|
|
1087
|
+
message.getReaction(),
|
|
1088
|
+
action
|
|
1089
|
+
)
|
|
1090
|
+
if (modifiedMessage instanceof CometChat.CometChatException) {
|
|
1091
|
+
onError && onError(modifiedMessage);
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
messageEdited(modifiedMessage, false);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
904
1097
|
// functions returning view
|
|
905
1098
|
const getLeadingView = useCallback((item: CometChat.BaseMessage) => {
|
|
906
|
-
if (showAvatar && (item.getSender()?.getUid() || item?.['sender']?.['uid']) !== loggedInUser.current['uid'] && item['category'] != MessageCategoryConstants.action) {
|
|
1099
|
+
if (showAvatar && (alignment === "leftAligned" || (item.getSender()?.getUid() || item?.['sender']?.['uid']) !== loggedInUser.current['uid'] && item['category'] != MessageCategoryConstants.action)) {
|
|
907
1100
|
return <CometChatAvatar
|
|
908
|
-
image={item?.getSender()?.getAvatar ? { uri: item.getSender().getAvatar() } : undefined}
|
|
909
|
-
name={item?.getSender()?.getName ? item?.getSender()?.getName() : ""}
|
|
1101
|
+
image={(item?.getSender()?.getAvatar && item?.getSender()?.getAvatar()) ? { uri: item.getSender().getAvatar() } : undefined}
|
|
1102
|
+
name={(item?.getSender()?.getName && item?.getSender()?.getName()) ? item?.getSender()?.getName() : ""}
|
|
910
1103
|
style={_avatarStyle}
|
|
911
1104
|
/>
|
|
912
1105
|
}
|
|
@@ -915,7 +1108,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
915
1108
|
|
|
916
1109
|
const getHeaderView = useCallback((item: CometChat.BaseMessage) => {
|
|
917
1110
|
let senderName: string = "";
|
|
918
|
-
if ((item.getSender()?.getUid() || item?.['sender']?.['uid']) != loggedInUser.current['uid'])
|
|
1111
|
+
if (alignment === "leftAligned" || ((item.getSender()?.getUid() || item?.['sender']?.['uid']) != loggedInUser.current['uid']))
|
|
919
1112
|
senderName = item.getSender()?.getName ? item.getSender()?.getName() : "";
|
|
920
1113
|
|
|
921
1114
|
if (item.getCategory() == MessageCategoryConstants.action || item.getCategory() == MessageCategoryConstants.call)
|
|
@@ -942,9 +1135,9 @@ export const CometChatMessageList = forwardRef<
|
|
|
942
1135
|
)
|
|
943
1136
|
}, [])
|
|
944
1137
|
|
|
945
|
-
const
|
|
1138
|
+
const getStatusInfoView = useCallback((item: CometChat.TextMessage | CometChat.MediaMessage | CometChat.CustomMessage | CometChat.InteractiveMessage | CometChat.BaseMessage, bubbleAlignment: MessageBubbleAlignmentType): JSX.Element => {
|
|
946
1139
|
// return null if time alignment is top
|
|
947
|
-
if (timeStampAlignment == "top" || item['category'] == "action") return null
|
|
1140
|
+
if (timeStampAlignment == "top" || item['category'] == "action" || item['deletedAt']) return null
|
|
948
1141
|
|
|
949
1142
|
let isSender = (item.getSender()?.getUid() || item?.['sender']?.['uid']) == loggedInUser.current['uid'];
|
|
950
1143
|
let messageState;
|
|
@@ -954,34 +1147,77 @@ export const CometChatMessageList = forwardRef<
|
|
|
954
1147
|
messageState = "DELIVERED";
|
|
955
1148
|
else if (item.getSentAt())
|
|
956
1149
|
messageState = "SENT";
|
|
1150
|
+
else if(item?.data?.metaData?.error)
|
|
1151
|
+
messageState = "ERROR"
|
|
957
1152
|
else if (isSender)
|
|
958
1153
|
messageState = "WAIT";
|
|
959
1154
|
else
|
|
960
1155
|
messageState = "ERROR"
|
|
961
1156
|
|
|
962
|
-
|
|
1157
|
+
let isAudioVideo = (item?.getType() === "image" || item?.getType() === "video");
|
|
1158
|
+
return <View style={[
|
|
1159
|
+
isAudioVideo ? {
|
|
1160
|
+
flexDirection: "row", justifyContent: bubbleAlignment === "right" ? "flex-end" : "flex-start", alignSelf: "flex-end", paddingVertical: 2, paddingHorizontal: 5,
|
|
1161
|
+
position: "absolute", borderRadius: 10, backgroundColor: theme.palette.getAccent500("dark"), zIndex: 1, bottom: 5, right: 5,
|
|
1162
|
+
}
|
|
1163
|
+
:
|
|
1164
|
+
{ flexDirection: "row", justifyContent: bubbleAlignment === "right" ? "flex-end" : "flex-start", alignSelf: "flex-end", padding: 5 }
|
|
1165
|
+
]}>
|
|
963
1166
|
<CometChatDate
|
|
964
1167
|
timeStamp={((item.getDeletedAt() || item.getReadAt() || item.getDeliveredAt() || item.getSentAt()) * 1000) || getSentAtTimestamp(item)}
|
|
965
|
-
style={messageBubbleDateStyle}
|
|
1168
|
+
style={{ ...messageBubbleDateStyle, textFont: isAudioVideo ? theme.typography.caption3 : messageBubbleDateStyle.textFont }}
|
|
966
1169
|
pattern={"timeFormat"}
|
|
967
1170
|
customDateString={datePattern && datePattern(item)}
|
|
968
1171
|
dateAlignment="center"
|
|
969
1172
|
/>
|
|
970
1173
|
{
|
|
971
|
-
!disableReceipt && isSender ?
|
|
972
|
-
<
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1174
|
+
(!disableReceipt && alignment !== "leftAligned") && isSender ?
|
|
1175
|
+
<View style={{ marginLeft: 2, alignItems: "center", justifyContent: "center" }}>
|
|
1176
|
+
<CometChatReceipt
|
|
1177
|
+
receipt={messageState}
|
|
1178
|
+
deliveredIcon={deliveredIcon}
|
|
1179
|
+
readIcon={readIcon}
|
|
1180
|
+
sentIcon={sentIcon}
|
|
1181
|
+
waitIcon={waitIcon}
|
|
1182
|
+
errorIcon={errorIcon}
|
|
1183
|
+
style={{
|
|
1184
|
+
height: isAudioVideo && 8, width: isAudioVideo && 10,
|
|
1185
|
+
tintColor: (messageState === "READ" && item?.getType() === "text") ? theme.palette.getBackgroundColor() :
|
|
1186
|
+
messageState === "WAIT" ? theme?.palette?.getAccent400() : undefined
|
|
1187
|
+
}}
|
|
1188
|
+
/>
|
|
1189
|
+
</View>
|
|
1190
|
+
:
|
|
980
1191
|
null
|
|
981
1192
|
}
|
|
982
1193
|
</View>
|
|
983
1194
|
}, [])
|
|
984
1195
|
|
|
1196
|
+
const getFooterView = useCallback((
|
|
1197
|
+
messageObject: CometChat.BaseMessage,
|
|
1198
|
+
alignment: MessageBubbleAlignmentType
|
|
1199
|
+
) => {
|
|
1200
|
+
let hasReaction = messageObject?.getReactions && messageObject?.getReactions() && messageObject?.getReactions().length > 0;
|
|
1201
|
+
return (
|
|
1202
|
+
<View style={{
|
|
1203
|
+
minHeight: hasReaction ? 27 : 0,
|
|
1204
|
+
}}>
|
|
1205
|
+
<CometChatReactions
|
|
1206
|
+
messageObject={messageObject}
|
|
1207
|
+
onReactionPress={(reaction: CometChat.ReactionCount, messageObject: CometChat.BaseMessage) => reactToMessage(reaction.getReaction(), messageObject)}
|
|
1208
|
+
onReactionLongPress={(reaction: CometChat.ReactionCount, messageObject: CometChat.BaseMessage) => onReactionLongPress(reaction.getReaction(), messageObject)}
|
|
1209
|
+
alignment={alignment}
|
|
1210
|
+
{...reactionsConfiguration}
|
|
1211
|
+
/>
|
|
1212
|
+
</View>
|
|
1213
|
+
);
|
|
1214
|
+
}, [])
|
|
1215
|
+
|
|
1216
|
+
const onReactionLongPress = (emoji: string, messageObj?: CometChat.BaseMessage) => { //TODO: check useCallBAck
|
|
1217
|
+
setSelectedMessage(messageObj);
|
|
1218
|
+
setSelectedEmoji(emoji);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
985
1221
|
const getAlignment = useCallback((item: CometChat.BaseMessage): MessageBubbleAlignmentType => {
|
|
986
1222
|
if (item && item.getCategory() == MessageCategoryConstants.action)
|
|
987
1223
|
return "center";
|
|
@@ -1014,22 +1250,64 @@ export const CometChatMessageList = forwardRef<
|
|
|
1014
1250
|
setShowMessageOptions([]);
|
|
1015
1251
|
}
|
|
1016
1252
|
|
|
1017
|
-
const getThreadView = useCallback((item: CometChat.BaseMessage) => {
|
|
1253
|
+
const getThreadView = useCallback((item: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType) => {
|
|
1018
1254
|
let isThreaded = item.getReplyCount() > 0;
|
|
1019
1255
|
|
|
1020
|
-
let style = {
|
|
1021
|
-
color: theme?.palette.
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1256
|
+
let style = [{
|
|
1257
|
+
color: theme?.palette.getAccent900(),
|
|
1258
|
+
marginRight: alignment === "right" ? 3 : 0,
|
|
1259
|
+
marginLeft: alignment === "left" ? 3 : 0
|
|
1260
|
+
}, theme?.typography?.subtitle1];
|
|
1261
|
+
|
|
1262
|
+
// let unreadReplyCount = item?.getUnreadReplyCount && item?.getUnreadReplyCount();
|
|
1026
1263
|
|
|
1027
1264
|
return !isThreaded ? null :
|
|
1028
1265
|
<TouchableOpacity
|
|
1029
1266
|
onPress={() => openThreadView(item, null)}
|
|
1030
|
-
style={{
|
|
1031
|
-
|
|
1032
|
-
|
|
1267
|
+
style={{
|
|
1268
|
+
flexDirection: "row",
|
|
1269
|
+
marginRight: 4,
|
|
1270
|
+
paddingHorizontal: 4,
|
|
1271
|
+
marginTop: 2,
|
|
1272
|
+
alignSelf: alignment === "right" ? "flex-end" : "flex-start",
|
|
1273
|
+
}}
|
|
1274
|
+
>
|
|
1275
|
+
{alignment === "left" && <Image style={{ resizeMode: "contain", tintColor: theme?.palette.getAccent600() }} source={LeftArrowCurve} />}
|
|
1276
|
+
<Text style={style}>{`${item.getReplyCount()} ${item.getReplyCount() > 1 ? localize("REPLIES") : localize("REPLY")}`}</Text>
|
|
1277
|
+
|
|
1278
|
+
{/** NOTE: uncomment below code when want unread count in thread view **/}
|
|
1279
|
+
{/* {alignment === "left" && !!unreadReplyCount &&
|
|
1280
|
+
<View style={{
|
|
1281
|
+
borderRadius: 10, marginLeft: 3,
|
|
1282
|
+
paddingHorizontal: 7,
|
|
1283
|
+
alignment: "center", justifyContent: "center",
|
|
1284
|
+
backgroundColor: theme?.palette?.getPrimary()
|
|
1285
|
+
}}>
|
|
1286
|
+
<Text style={[theme?.typography?.subtitle4,
|
|
1287
|
+
{
|
|
1288
|
+
color: theme?.palette?.getBackgroundColor(),
|
|
1289
|
+
textAlign: "center"
|
|
1290
|
+
}]}
|
|
1291
|
+
>{unreadReplyCount}</Text>
|
|
1292
|
+
</View>
|
|
1293
|
+
} */}
|
|
1294
|
+
{/* {alignment === "right" && !!unreadReplyCount &&
|
|
1295
|
+
<View style={{
|
|
1296
|
+
borderRadius: 10, marginRight: 3, paddingVertical: 2, paddingHorizontal: 6,
|
|
1297
|
+
backgroundColor: theme?.palette?.getPrimary()
|
|
1298
|
+
}}>
|
|
1299
|
+
<Text style={[theme?.typography?.subtitle4,
|
|
1300
|
+
{ color: theme?.palette?.getBackgroundColor() }]}
|
|
1301
|
+
>{unreadReplyCount}</Text>
|
|
1302
|
+
</View>
|
|
1303
|
+
} */}
|
|
1304
|
+
{/** NOTE: uncomment above code when want unread count in thread view **/}
|
|
1305
|
+
|
|
1306
|
+
{alignment === "right" && <Image style={[{ resizeMode: "contain", tintColor: theme?.palette.getAccent600() },
|
|
1307
|
+
{
|
|
1308
|
+
transform: [{ scaleX: -1 }]
|
|
1309
|
+
}
|
|
1310
|
+
]} source={LeftArrowCurve} />}
|
|
1033
1311
|
</TouchableOpacity>
|
|
1034
1312
|
}, [])
|
|
1035
1313
|
|
|
@@ -1045,7 +1323,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
1045
1323
|
})
|
|
1046
1324
|
}
|
|
1047
1325
|
|
|
1048
|
-
const shareMedia = async (messageObject: CometChat.
|
|
1326
|
+
const shareMedia = async (messageObject: CometChat.MediaMessage) => {
|
|
1049
1327
|
let textMessage = messageObject.data.text;
|
|
1050
1328
|
let fileUrl = messageObject.data.url;
|
|
1051
1329
|
|
|
@@ -1059,7 +1337,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
1059
1337
|
"type": messageObject["type"],
|
|
1060
1338
|
"mediaName": getFileName(), // get File name
|
|
1061
1339
|
"fileUrl": fileUrl || "", // get File url
|
|
1062
|
-
"mimeType": messageObject["type"] === "text" ? "" : messageObject?.getAttachment()?.getMimeType(), // get Mime Type
|
|
1340
|
+
"mimeType": messageObject["type"] === "text" ? "" : (messageObject as CometChat.MediaMessage)?.getAttachment()?.getMimeType(), // get Mime Type
|
|
1063
1341
|
}
|
|
1064
1342
|
|
|
1065
1343
|
NativeModules.FileManager.shareMessage(shareObj, (callback) => {
|
|
@@ -1079,8 +1357,12 @@ export const CometChatMessageList = forwardRef<
|
|
|
1079
1357
|
}
|
|
1080
1358
|
}
|
|
1081
1359
|
|
|
1082
|
-
if ((item.getSender()?.getUid() || item?.['sender']?.['uid']) == loggedInUser.current?.['uid']
|
|
1083
|
-
_style.backgroundColor = theme?.palette.getPrimary();
|
|
1360
|
+
if ((item.getSender()?.getUid() || item?.['sender']?.['uid']) == loggedInUser.current?.['uid'])
|
|
1361
|
+
_style.backgroundColor = (alignment !== "leftAligned" && (item.getType() === MessageTypeConstants.text || item.getType() === MessageTypeConstants.meeting)) ? theme?.palette.getPrimary() : theme?.palette.getAccent50();
|
|
1362
|
+
|
|
1363
|
+
if(item?.getDeletedBy()) {
|
|
1364
|
+
_style.backgroundColor = 'transparent';
|
|
1365
|
+
}
|
|
1084
1366
|
|
|
1085
1367
|
return _style;
|
|
1086
1368
|
}, []);
|
|
@@ -1224,16 +1506,23 @@ export const CometChatMessageList = forwardRef<
|
|
|
1224
1506
|
|
|
1225
1507
|
let bubbleAlignment: MessageBubbleAlignmentType = getAlignment(message);
|
|
1226
1508
|
|
|
1227
|
-
|
|
1509
|
+
const onLongPress = () => {
|
|
1510
|
+
if (message.getDeletedBy() != null) return;
|
|
1511
|
+
setSelectedMessage(message)
|
|
1512
|
+
openOptionsForMessage(message, hasTemplate)
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
return <TouchableOpacity activeOpacity={1} onLongPress={() => showOptions ? onLongPress() : undefined} >
|
|
1228
1516
|
<CometChatMessageBubble
|
|
1229
1517
|
id={`${message.getId()}`}
|
|
1230
1518
|
LeadingView={() => !isThreaded && getLeadingView(message)}
|
|
1231
1519
|
HeaderView={() => !isThreaded && getHeaderView(message)}
|
|
1232
|
-
FooterView={() => getFooterView(message, bubbleAlignment)}
|
|
1520
|
+
FooterView={() => (disableReactions || isThreaded) ? null : getFooterView(message, bubbleAlignment)}
|
|
1233
1521
|
alignment={isThreaded ? "left" : bubbleAlignment}
|
|
1234
1522
|
ContentView={hasTemplate.ContentView?.bind(this, message, bubbleAlignment)}
|
|
1235
|
-
ThreadView={() => !isThreaded && getThreadView(message)}
|
|
1523
|
+
ThreadView={() => !isThreaded && getThreadView(message, bubbleAlignment)}
|
|
1236
1524
|
BottomView={() => ChatConfigurator.dataSource.getBottomView(message, bubbleAlignment)} // Note please rewrite this
|
|
1525
|
+
StatusInfoView={() => getStatusInfoView(message, bubbleAlignment)}
|
|
1237
1526
|
style={getStyle(message)}
|
|
1238
1527
|
/>
|
|
1239
1528
|
</TouchableOpacity>
|
|
@@ -1249,9 +1538,86 @@ export const CometChatMessageList = forwardRef<
|
|
|
1249
1538
|
return item['sentAt'] * 1000;
|
|
1250
1539
|
}, [])
|
|
1251
1540
|
|
|
1252
|
-
|
|
1541
|
+
|
|
1542
|
+
const reactToMessage = (emoji: string, messageObj?: CometChat.BaseMessage) => {
|
|
1543
|
+
|
|
1544
|
+
const msgObj = CommonUtils.clone(messageObj) || CommonUtils.clone(selectedMessage);
|
|
1545
|
+
|
|
1546
|
+
const messageId = msgObj?.getId();
|
|
1547
|
+
const reactions = msgObj?.getReactions() || [];
|
|
1548
|
+
const emojiObject = reactions?.find(
|
|
1549
|
+
(reaction: any) => {
|
|
1550
|
+
return reaction?.reaction == emoji;
|
|
1551
|
+
}
|
|
1552
|
+
);
|
|
1553
|
+
if (emojiObject && emojiObject?.getReactedByMe()) {
|
|
1554
|
+
const updatedReactions = [];
|
|
1555
|
+
reactions.forEach((reaction) => {
|
|
1556
|
+
if (reaction?.getReaction() == emoji) {
|
|
1557
|
+
if (reaction?.getCount() === 1) {
|
|
1558
|
+
return;
|
|
1559
|
+
} else {
|
|
1560
|
+
reaction.setCount(reaction?.getCount() - 1);
|
|
1561
|
+
reaction.setReactedByMe(false);
|
|
1562
|
+
updatedReactions.push(reaction);
|
|
1563
|
+
}
|
|
1564
|
+
} else {
|
|
1565
|
+
updatedReactions.push(reaction);
|
|
1566
|
+
}
|
|
1567
|
+
});
|
|
1568
|
+
|
|
1569
|
+
const newMessageObj = CommonUtils.clone(msgObj);
|
|
1570
|
+
newMessageObj.setReactions(updatedReactions);
|
|
1571
|
+
|
|
1572
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, { message: newMessageObj, status: messageStatus.success });
|
|
1573
|
+
CometChat.removeReaction(messageId, emoji).then((message) => {
|
|
1574
|
+
}).catch((error) => {
|
|
1575
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, { message: msgObj, status: messageStatus.success });
|
|
1576
|
+
console.log(error);
|
|
1577
|
+
});
|
|
1578
|
+
} else {
|
|
1579
|
+
const updatedReactions = [];
|
|
1580
|
+
const reactionAvailable = reactions.find((reaction) => {
|
|
1581
|
+
return reaction?.getReaction() == emoji;
|
|
1582
|
+
});
|
|
1583
|
+
reactions.forEach((reaction) => {
|
|
1584
|
+
if (reaction?.getReaction() == emoji) {
|
|
1585
|
+
reaction.setCount(reaction?.getCount() + 1);
|
|
1586
|
+
reaction.setReactedByMe(true);
|
|
1587
|
+
updatedReactions.push(reaction);
|
|
1588
|
+
} else {
|
|
1589
|
+
updatedReactions.push(reaction);
|
|
1590
|
+
}
|
|
1591
|
+
});
|
|
1592
|
+
if (!reactionAvailable) {
|
|
1593
|
+
const react: CometChat.ReactionCount = new CometChat.ReactionCount(emoji, 1, true);
|
|
1594
|
+
updatedReactions.push(react);
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
const newMessageObj = CommonUtils.clone(msgObj);
|
|
1598
|
+
|
|
1599
|
+
newMessageObj.setReactions(updatedReactions);
|
|
1600
|
+
|
|
1601
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, { message: newMessageObj, status: messageStatus.success });
|
|
1602
|
+
|
|
1603
|
+
CometChat.addReaction(messageId, emoji)
|
|
1604
|
+
.then((response: any) => {
|
|
1605
|
+
})
|
|
1606
|
+
.catch((error: any) => {
|
|
1607
|
+
console.log(error);
|
|
1608
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, { message: msgObj, status: messageStatus.success });
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
setShowMessageOptions([]);
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
const RenderMessageItem = useCallback(memo(function RenderMessageItem({ item, index }: {
|
|
1616
|
+
item: any;
|
|
1617
|
+
index: number;
|
|
1618
|
+
}) {
|
|
1253
1619
|
let seperatorView = null;
|
|
1254
|
-
const previousMessageDate =
|
|
1620
|
+
const previousMessageDate = messagesContentListRef.current[index - 1] ? new Date(getSentAtTimestamp(messagesContentListRef.current[index - 1])) : null;
|
|
1255
1621
|
const currentMessageDate = new Date(getSentAtTimestamp(item));
|
|
1256
1622
|
|
|
1257
1623
|
const currentDate = isNaN(currentMessageDate.getDate()) ? undefined : `${currentMessageDate.getDate()}-${currentMessageDate.getMonth()}-${currentMessageDate.getFullYear()}`;
|
|
@@ -1277,7 +1643,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
1277
1643
|
{seperatorView}
|
|
1278
1644
|
<MessageView message={item} />
|
|
1279
1645
|
</React.Fragment>
|
|
1280
|
-
};
|
|
1646
|
+
}), []);
|
|
1281
1647
|
|
|
1282
1648
|
const keyExtractor = useCallback((item) => `${item.id}_${item.muid}`, [])
|
|
1283
1649
|
|
|
@@ -1321,7 +1687,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
1321
1687
|
);
|
|
1322
1688
|
}, [])
|
|
1323
1689
|
|
|
1324
|
-
const getLoadingStateView = () => {
|
|
1690
|
+
const getLoadingStateView = useCallback(() => {
|
|
1325
1691
|
if (LoadingStateView)
|
|
1326
1692
|
return LoadingStateView;
|
|
1327
1693
|
|
|
@@ -1330,20 +1696,20 @@ export const CometChatMessageList = forwardRef<
|
|
|
1330
1696
|
<ActivityIndicator size="large" color={messageListStyle?.loadingIconTint} />
|
|
1331
1697
|
</View>
|
|
1332
1698
|
)
|
|
1333
|
-
}
|
|
1699
|
+
}, [])
|
|
1334
1700
|
|
|
1335
|
-
|
|
1701
|
+
const handleScroll = (event) => {
|
|
1336
1702
|
if (event.nativeEvent.contentOffset.y == 0) {
|
|
1337
1703
|
getPreviousMessages();
|
|
1338
1704
|
}
|
|
1339
1705
|
scrollHandler(event);
|
|
1340
1706
|
};
|
|
1341
1707
|
|
|
1342
|
-
|
|
1708
|
+
const onContentSizeChange = useCallback((contentWidth, contentHeight) => {
|
|
1343
1709
|
if (currentScrollPosition.current.y == 0 && currentScrollPosition.current.scrollViewHeight) {
|
|
1344
1710
|
let diff = contentHeight - currentScrollPosition.current.scrollViewHeight;
|
|
1345
1711
|
if (messagesLength.current > prevMessagesLength.current && diff > 0 && !(unreadCount > 0)) {
|
|
1346
|
-
messageListRef.current.scrollTo({ y:
|
|
1712
|
+
messageListRef.current.scrollTo({ y: diff, animated: false })
|
|
1347
1713
|
}
|
|
1348
1714
|
}
|
|
1349
1715
|
|
|
@@ -1357,7 +1723,7 @@ export const CometChatMessageList = forwardRef<
|
|
|
1357
1723
|
currentScrollPosition.current.scrollViewHeight = contentHeight;
|
|
1358
1724
|
}
|
|
1359
1725
|
}
|
|
1360
|
-
}
|
|
1726
|
+
}, [])
|
|
1361
1727
|
|
|
1362
1728
|
const {
|
|
1363
1729
|
height,
|
|
@@ -1401,33 +1767,31 @@ export const CometChatMessageList = forwardRef<
|
|
|
1401
1767
|
</View>
|
|
1402
1768
|
}
|
|
1403
1769
|
|
|
1404
|
-
<
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
)
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
</ScrollView>
|
|
1430
|
-
</SafeAreaView>
|
|
1770
|
+
<ScrollView
|
|
1771
|
+
ref={messageListRef}
|
|
1772
|
+
onScroll={handleScroll}
|
|
1773
|
+
scrollEventThrottle={16} // control how often the scroll event will be fired
|
|
1774
|
+
onLayout={() => {
|
|
1775
|
+
!currentScrollPosition.current.scrollViewHeight && messageListRef.current.scrollToEnd({ animated: false })
|
|
1776
|
+
}}
|
|
1777
|
+
onContentSizeChange={onContentSizeChange}
|
|
1778
|
+
>
|
|
1779
|
+
|
|
1780
|
+
{messagesList?.length ? (
|
|
1781
|
+
messagesList
|
|
1782
|
+
// .slice(0)
|
|
1783
|
+
// .reverse()
|
|
1784
|
+
.map((item, index) => (
|
|
1785
|
+
<View
|
|
1786
|
+
key={keyExtractor(item)}>
|
|
1787
|
+
<RenderMessageItem item={item} index={index} />
|
|
1788
|
+
{itemSeperator()}
|
|
1789
|
+
</View>
|
|
1790
|
+
))
|
|
1791
|
+
) : (
|
|
1792
|
+
getEmptyTextView()
|
|
1793
|
+
)}
|
|
1794
|
+
</ScrollView>
|
|
1431
1795
|
{CustomListHeader && <CustomListHeader />}
|
|
1432
1796
|
{ongoingCallView}
|
|
1433
1797
|
{
|
|
@@ -1509,6 +1873,8 @@ export const CometChatMessageList = forwardRef<
|
|
|
1509
1873
|
infoObject.current = null;
|
|
1510
1874
|
setMessageInfo(false);
|
|
1511
1875
|
}} isOpen={showMessageOptions.length > 0 || ExtensionsComponent || messageInfo}
|
|
1876
|
+
sliderMaxHeight={Dimensions.get('window').height * 0.5}
|
|
1877
|
+
sliderMinHeight={Dimensions.get('window').height * 0.5}
|
|
1512
1878
|
>
|
|
1513
1879
|
{
|
|
1514
1880
|
ExtensionsComponent ? ExtensionsComponent :
|
|
@@ -1526,19 +1892,68 @@ export const CometChatMessageList = forwardRef<
|
|
|
1526
1892
|
messageInformationConfiguration?.onBack && messageInformationConfiguration.onBack();
|
|
1527
1893
|
}}
|
|
1528
1894
|
/> :
|
|
1529
|
-
<
|
|
1895
|
+
<View>
|
|
1896
|
+
{!disableReactions && <CometChatQuickReactions
|
|
1897
|
+
// quickReactions={quickReactions}
|
|
1898
|
+
onReactionPress={reactToMessage}
|
|
1899
|
+
onAddReactionPress={() => {
|
|
1900
|
+
setShowMessageOptions([])
|
|
1901
|
+
setShowEmojiKeyboard(true)
|
|
1902
|
+
}}
|
|
1903
|
+
{...quickReactionConfiguration}
|
|
1904
|
+
/>}
|
|
1905
|
+
<View style={{
|
|
1906
|
+
maxHeight: (Dimensions.get('window').height * 0.5) - (disableReactions ? 0 : 100),
|
|
1907
|
+
minHeight: (Dimensions.get('window').height * 0.5) - (disableReactions ? 0 : 100),
|
|
1908
|
+
overflow: "scroll"
|
|
1909
|
+
}}>
|
|
1910
|
+
<CometChatActionSheet hideHeader={hideActionSheetHeader} actions={showMessageOptions} style={_actionStyle} />
|
|
1911
|
+
</View>
|
|
1912
|
+
</View>
|
|
1530
1913
|
}
|
|
1531
1914
|
</CometChatBottomSheet>
|
|
1915
|
+
<CometChatBottomSheet
|
|
1916
|
+
isOpen={showEmojiKeyboard}
|
|
1917
|
+
onClose={() => setShowEmojiKeyboard(false)}
|
|
1918
|
+
>
|
|
1919
|
+
<CometChatEmojiKeyboard
|
|
1920
|
+
onClick={(item) => {
|
|
1921
|
+
setShowEmojiKeyboard(false)
|
|
1922
|
+
reactToMessage(item, selectedMessage)
|
|
1923
|
+
}}
|
|
1924
|
+
style={{
|
|
1925
|
+
height: (Dimensions.get('window').height * 0.5) - 54,
|
|
1926
|
+
...emojiKeyboardStyle
|
|
1927
|
+
}}
|
|
1928
|
+
/>
|
|
1929
|
+
</CometChatBottomSheet>
|
|
1930
|
+
|
|
1931
|
+
<CometChatBottomSheet
|
|
1932
|
+
isOpen={showReactionsList}
|
|
1933
|
+
onClose={() => {
|
|
1934
|
+
setShowReactionsList(false);
|
|
1935
|
+
setSelectedEmoji(null);
|
|
1936
|
+
}}
|
|
1937
|
+
sliderMaxHeight={Dimensions.get('window').height * 0.5}
|
|
1938
|
+
sliderMinHeight={Dimensions.get('window').height * 0.5}
|
|
1939
|
+
>
|
|
1940
|
+
<CometChatReactionsList
|
|
1941
|
+
messageObject={selectedMessage}
|
|
1942
|
+
selectedReaction={selectedEmoji}
|
|
1943
|
+
{...reactionsListConfiguration}
|
|
1944
|
+
onPress={(messageReaction: CometChat.Reaction, messageObject: CometChat.BaseMessage) => {
|
|
1945
|
+
if (reactionsListConfiguration?.onPress) {
|
|
1946
|
+
reactionsListConfiguration.onPress(messageReaction, messageObject);
|
|
1947
|
+
return;
|
|
1948
|
+
}
|
|
1949
|
+
reactToMessage(messageReaction?.getReaction(), messageObject);
|
|
1950
|
+
if (messageObject?.getReactions()?.length === 1 && messageObject?.getReactions()?.[0]?.['count'] == 1) {
|
|
1951
|
+
setShowReactionsList(false);
|
|
1952
|
+
setSelectedEmoji(null);
|
|
1953
|
+
}
|
|
1954
|
+
}}
|
|
1955
|
+
/>
|
|
1956
|
+
</CometChatBottomSheet>
|
|
1532
1957
|
</View>
|
|
1533
1958
|
)
|
|
1534
|
-
});
|
|
1535
|
-
|
|
1536
|
-
CometChatMessageList.defaultProps = {
|
|
1537
|
-
timeStampAlignment: "bottom",
|
|
1538
|
-
templates: [],
|
|
1539
|
-
showAvatar: true,
|
|
1540
|
-
alignment: "standard",
|
|
1541
|
-
errorStateText: localize("SOMETHING_WRONG"),
|
|
1542
|
-
emptyStateText: localize("NO_MESSAGES_FOUND"),
|
|
1543
|
-
disableReceipt: false
|
|
1544
|
-
}
|
|
1959
|
+
}));
|