@cometchat/chat-uikit-react-native 5.0.0 → 5.0.2
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/FileManager.java +87 -49
- package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +10 -0
- package/ios/SoundPlayer.m +8 -0
- package/package.json +8 -9
- package/src/CometChatConversations/CometChatConversations.tsx +19 -14
- package/src/CometChatConversations/style.ts +6 -2
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +1 -0
- package/src/CometChatGroupMembers/style.ts +1 -0
- package/src/CometChatGroups/CometChatGroups.tsx +1 -0
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +227 -57
- package/src/CometChatMessageComposer/styles.tsx +3 -6
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +2 -2
- package/src/CometChatMessageHeader/styles.ts +1 -0
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +1 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +188 -111
- package/src/CometChatMessageList/style.ts +0 -16
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +1 -1
- package/src/CometChatUsers/CometChatUsers.tsx +1 -1
- package/src/calls/CallUtils.ts +18 -10
- package/src/calls/CallingExtensionDecorator.tsx +1 -1
- package/src/calls/CometChatCallBubble/CometChatCallBubble.tsx +8 -7
- package/src/calls/CometChatCallBubble/styles.ts +1 -0
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +6 -4
- package/src/calls/CometChatCallButtons/style.ts +2 -1
- package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +4 -3
- package/src/calls/CometChatCallLogs/style.ts +1 -0
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +4 -3
- package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +1 -0
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +3 -3
- package/src/calls/CometChatOutgoingCall/OutgoingCallConfiguration.ts +1 -0
- package/src/extensions/CollaborativeBubble/CometChatCollaborativeBubble.tsx +1 -1
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +15 -18
- package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +1 -1
- package/src/extensions/LinkPreview/style.ts +2 -2
- package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +20 -17
- package/src/extensions/Polls/Polls.tsx +45 -8
- package/src/extensions/Polls/PollsDecorator.tsx +1 -1
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -4
- package/src/extensions/Stickers/style.ts +3 -3
- package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +1 -1
- package/src/imageresolver.d.ts +4 -0
- package/src/index.ts +2 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +1 -2
- package/src/shared/base/Types.ts +1 -0
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +114 -32
- package/src/shared/formatters/CometChatTextFormatter.ts +1 -0
- package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +4 -4
- package/src/shared/framework/DataSource.ts +6 -2
- package/src/shared/framework/DataSourceDecorator.tsx +5 -4
- package/src/shared/framework/MessageDataSource.tsx +26 -28
- package/src/shared/helper/types/index.ts +1 -0
- package/src/shared/icons/Icon.tsx +1 -1
- package/src/shared/index.ts +41 -126
- package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +1 -1
- package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +4 -2
- package/src/shared/modals/CometChatMessageOption.ts +1 -0
- package/src/shared/modals/CometChatMessageTemplate.ts +1 -0
- package/src/shared/resources/CometChatSoundManager/index.ts +1 -0
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +0 -8
- package/src/shared/utils/CometChatMessagePreview/index.ts +1 -2
- package/src/shared/utils/CommonUtils.ts +2 -1
- package/src/shared/utils/MessageUtils.tsx +54 -62
- package/src/shared/utils/conversationUtils.ts +1 -0
- package/src/shared/utils/index.ts +1 -2
- package/src/shared/views/CometChatActionSheet/ActionItem.ts +1 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -1
- package/src/shared/views/CometChatAudioBubble/AnimatedAudioWaves.tsx +1 -1
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +9 -6
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +1 -1
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +1 -1
- package/src/shared/views/CometChatConfirmDialog/style.ts +1 -0
- package/src/shared/views/CometChatDeletedBubble/styles.ts +1 -0
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +1 -1
- package/src/shared/views/CometChatList/CometChatList.tsx +2 -2
- package/src/shared/views/CometChatList/Header.tsx +1 -1
- package/src/shared/views/CometChatMediaRecorder/AnimatingMic.tsx +2 -2
- package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +16 -10
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +7 -8
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +1 -1
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +84 -70
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +1 -1
- package/src/shared/views/CometChatReactions/style.ts +5 -4
- package/src/shared/views/CometChatReceipt/style.ts +1 -0
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +1 -1
- package/src/shared/views/CometChatSuggestionList/style.ts +3 -2
- package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +1 -1
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +24 -47
- package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +68 -73
- package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +1 -0
- package/src/theme/CometChatThemeHelper.ts +69 -58
- package/src/theme/context.ts +2 -2
- package/src/theme/default/default.ts +204 -0
- package/src/theme/default/index.ts +0 -238
- package/src/theme/provider.tsx +7 -7
- package/src/theme/type.ts +5 -7
- 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/src/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js +0 -42
|
@@ -2,6 +2,7 @@ import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
|
2
2
|
import Clipboard from "@react-native-clipboard/clipboard";
|
|
3
3
|
import React, {
|
|
4
4
|
forwardRef,
|
|
5
|
+
JSX,
|
|
5
6
|
memo,
|
|
6
7
|
useCallback,
|
|
7
8
|
useEffect,
|
|
@@ -15,6 +16,7 @@ import {
|
|
|
15
16
|
ActivityIndicator,
|
|
16
17
|
Dimensions,
|
|
17
18
|
FlatList,
|
|
19
|
+
Keyboard,
|
|
18
20
|
NativeModules,
|
|
19
21
|
Platform,
|
|
20
22
|
Pressable,
|
|
@@ -76,6 +78,7 @@ import { MessageSkeleton } from "./Skeleton";
|
|
|
76
78
|
import { ErrorEmptyView } from "../shared/views/ErrorEmptyView/ErrorEmptyView";
|
|
77
79
|
import { BubbleStyles, CometChatTheme } from "../theme/type";
|
|
78
80
|
import { ExtensionConstants } from "../extensions";
|
|
81
|
+
//@ts-ignore
|
|
79
82
|
import { getExtensionData } from "../shared/helper/functions";
|
|
80
83
|
import { DeepPartial } from "../shared/helper/types";
|
|
81
84
|
import { CometChatDateSeparator } from "../shared/views/CometChatDateSeperator";
|
|
@@ -451,7 +454,7 @@ export const CometChatMessageList = memo(
|
|
|
451
454
|
const messageEventListener = "messageEvent_" + new Date().getTime();
|
|
452
455
|
const groupEventListener = "groupEvent_" + new Date().getTime();
|
|
453
456
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
|
454
|
-
const deleteItem = useRef<CometChat.BaseMessage>();
|
|
457
|
+
const deleteItem = useRef<CometChat.BaseMessage>(undefined);
|
|
455
458
|
|
|
456
459
|
useLayoutEffect(() => {
|
|
457
460
|
if (user) {
|
|
@@ -639,13 +642,15 @@ export const CometChatMessageList = memo(
|
|
|
639
642
|
const messagesContentListRef = useRef<any[]>([]);
|
|
640
643
|
const temporaryMessageListRef = useRef<any[]>([]);
|
|
641
644
|
|
|
642
|
-
const msgRequestBuilder = useRef<CometChat.MessagesRequestBuilder>();
|
|
645
|
+
const msgRequestBuilder = useRef<CometChat.MessagesRequestBuilder>(undefined);
|
|
643
646
|
const lastMessageDate = useRef(new Date().getTime());
|
|
644
647
|
|
|
645
648
|
// states
|
|
646
649
|
const [messagesList, setMessagesList] = useState<any[]>([]);
|
|
647
650
|
const [listState, setListState] = useState("loading");
|
|
648
651
|
const [loadingMessages, setLoadingMessages] = useState(false);
|
|
652
|
+
/** this is required to prevent duplicate api calls. Cannot use state for this since this is being used in scrollHandler **/
|
|
653
|
+
const loadingMessagesRef = useRef(false);
|
|
649
654
|
const [unreadCount, setUnreadCount] = useState(0);
|
|
650
655
|
const [showMessageOptions, setShowMessageOptions] = useState<any[]>([]);
|
|
651
656
|
const [ExtensionsComponent, setExtensionsComponent] = useState<JSX.Element | null>(null);
|
|
@@ -658,7 +663,7 @@ export const CometChatMessageList = memo(
|
|
|
658
663
|
const [selectedEmoji, setSelectedEmoji] = useState<string | undefined>(undefined);
|
|
659
664
|
const [hideScrollToBottomButton, setHideScrollToBottomButton] = useState<boolean>(true);
|
|
660
665
|
|
|
661
|
-
const infoObject = useRef<CometChat.BaseMessage | null>();
|
|
666
|
+
const infoObject = useRef<CometChat.BaseMessage | null>(undefined);
|
|
662
667
|
const bottomSheetRef = useRef<any>(null);
|
|
663
668
|
const conversationId = useRef(null);
|
|
664
669
|
let lastID = useRef(0);
|
|
@@ -672,7 +677,7 @@ export const CometChatMessageList = memo(
|
|
|
672
677
|
setUnreadCount(0);
|
|
673
678
|
};
|
|
674
679
|
|
|
675
|
-
const newMsgIndicatorPressed = () => {
|
|
680
|
+
const newMsgIndicatorPressed = useCallback(() => {
|
|
676
681
|
messagesContentListRef.current = [
|
|
677
682
|
...temporaryMessageListRef.current,
|
|
678
683
|
...messagesContentListRef.current,
|
|
@@ -682,14 +687,17 @@ export const CometChatMessageList = memo(
|
|
|
682
687
|
temporaryMessageListRef.current = [];
|
|
683
688
|
scrollToBottom();
|
|
684
689
|
markUnreadMessageAsRead();
|
|
685
|
-
};
|
|
690
|
+
}, [onLoad]);
|
|
686
691
|
|
|
687
692
|
const getPreviousMessages = async () => {
|
|
688
693
|
if (reachedFirstMessage.current) {
|
|
689
694
|
return;
|
|
690
695
|
}
|
|
691
696
|
if (messagesList.length == 0) setListState("loading");
|
|
692
|
-
else
|
|
697
|
+
else {
|
|
698
|
+
setLoadingMessages(true);
|
|
699
|
+
loadingMessagesRef.current = true;
|
|
700
|
+
}
|
|
693
701
|
// TODO: this condition is applied because somewhere from whiteboard extention group scope is set to undefined.
|
|
694
702
|
if (group != undefined && group.getGuid() == undefined) {
|
|
695
703
|
let fetchedGroup: any = await CometChat.getGroup(group.getGuid()).catch((e: any) => {
|
|
@@ -760,12 +768,17 @@ export const CometChatMessageList = memo(
|
|
|
760
768
|
} else {
|
|
761
769
|
onLoad && onLoad([...messagesContentListRef.current].reverse());
|
|
762
770
|
setLoadingMessages(false);
|
|
771
|
+
loadingMessagesRef.current = false;
|
|
763
772
|
}
|
|
764
773
|
setListState("");
|
|
765
774
|
})
|
|
766
775
|
.catch((e: any) => {
|
|
767
776
|
if (messagesContentListRef.current.length == 0) setListState("error");
|
|
768
|
-
|
|
777
|
+
if (e?.code === "REQUEST_IN_PROGRESS") return;
|
|
778
|
+
else {
|
|
779
|
+
setLoadingMessages(false);
|
|
780
|
+
loadingMessagesRef.current = false;
|
|
781
|
+
}
|
|
769
782
|
onError && onError(e);
|
|
770
783
|
});
|
|
771
784
|
};
|
|
@@ -1444,6 +1457,7 @@ export const CometChatMessageList = memo(
|
|
|
1444
1457
|
callListenerId,
|
|
1445
1458
|
new CometChat.CallListener({
|
|
1446
1459
|
onIncomingCallReceived: (call: any) => {
|
|
1460
|
+
Platform.OS === 'ios' && Keyboard.dismiss();
|
|
1447
1461
|
newMessage(call);
|
|
1448
1462
|
},
|
|
1449
1463
|
onOutgoingCallAccepted: (call: any) => {
|
|
@@ -1629,32 +1643,35 @@ export const CometChatMessageList = memo(
|
|
|
1629
1643
|
messageEdited(modifiedMessage, false);
|
|
1630
1644
|
};
|
|
1631
1645
|
|
|
1632
|
-
const getCurrentBubbleStyle = (
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
if (item.getType() === MessageTypeConstants.text) {
|
|
1638
|
-
let linkData = getExtensionData(item, ExtensionConstants.linkPreview);
|
|
1639
|
-
if (linkData && linkData.links.length != 0) {
|
|
1640
|
-
return ExtensionConstants.linkPreview;
|
|
1646
|
+
const getCurrentBubbleStyle = useCallback(
|
|
1647
|
+
(item: CometChat.BaseMessage): BubbleStyles => {
|
|
1648
|
+
const type = (() => {
|
|
1649
|
+
if (item.getDeletedAt()) {
|
|
1650
|
+
return MessageTypeConstants.messageDeleted;
|
|
1641
1651
|
}
|
|
1652
|
+
if (item.getType() === MessageTypeConstants.text) {
|
|
1653
|
+
let linkData = getExtensionData(item, ExtensionConstants.linkPreview);
|
|
1654
|
+
if (linkData && linkData.links.length != 0) {
|
|
1655
|
+
return ExtensionConstants.linkPreview;
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
return item.getType();
|
|
1659
|
+
})();
|
|
1660
|
+
|
|
1661
|
+
if (item.getSender().getUid() != loggedInUser.current.getUid()) {
|
|
1662
|
+
return (
|
|
1663
|
+
overridenBubbleStyles.get(type)?.incoming ??
|
|
1664
|
+
mergedTheme.messageListStyles.incomingMessageBubbleStyles
|
|
1665
|
+
);
|
|
1642
1666
|
}
|
|
1643
|
-
return item.getType();
|
|
1644
|
-
})();
|
|
1645
1667
|
|
|
1646
|
-
if (item.getSender().getUid() != loggedInUser.current.getUid()) {
|
|
1647
1668
|
return (
|
|
1648
|
-
overridenBubbleStyles.get(type)?.
|
|
1649
|
-
mergedTheme.messageListStyles.
|
|
1669
|
+
overridenBubbleStyles.get(type)?.outgoing ??
|
|
1670
|
+
mergedTheme.messageListStyles.outgoingMessageBubbleStyles
|
|
1650
1671
|
);
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
overridenBubbleStyles.get(type)?.outgoing ??
|
|
1655
|
-
mergedTheme.messageListStyles.outgoingMessageBubbleStyles
|
|
1656
|
-
);
|
|
1657
|
-
};
|
|
1672
|
+
},
|
|
1673
|
+
[mergedTheme, overridenBubbleStyles]
|
|
1674
|
+
);
|
|
1658
1675
|
|
|
1659
1676
|
// functions returning view
|
|
1660
1677
|
const getLeadingView = useCallback((item: CometChat.BaseMessage): JSX.Element | undefined => {
|
|
@@ -1895,10 +1912,9 @@ export const CometChatMessageList = memo(
|
|
|
1895
1912
|
|
|
1896
1913
|
const openThreadView = (...params: any[]) => {
|
|
1897
1914
|
if (onThreadRepliesPress) {
|
|
1898
|
-
onThreadRepliesPress(
|
|
1899
|
-
params[0]
|
|
1900
|
-
|
|
1901
|
-
);
|
|
1915
|
+
onThreadRepliesPress(params[0], () => (
|
|
1916
|
+
<MessageView message={params[0]} isThreaded={true} showOptions={false} />
|
|
1917
|
+
));
|
|
1902
1918
|
}
|
|
1903
1919
|
setShowMessageOptions([]);
|
|
1904
1920
|
return onThreadRepliesPress;
|
|
@@ -2062,65 +2078,98 @@ export const CometChatMessageList = memo(
|
|
|
2062
2078
|
currentIndex?: number;
|
|
2063
2079
|
}) => {
|
|
2064
2080
|
const { message, showOptions = true, isThreaded = false, currentIndex } = params;
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
(template) =>
|
|
2069
|
-
template.type == message.getType() && template.category == message.getCategory()
|
|
2081
|
+
const hasTemplate = useMemo(() => {
|
|
2082
|
+
const defaultTemplate = templatesMap.get(
|
|
2083
|
+
`${message.getCategory()}_${message.getType()}`
|
|
2070
2084
|
);
|
|
2071
|
-
if (customTemplate) hasTemplate = customTemplate;
|
|
2072
|
-
}
|
|
2073
|
-
if (hasTemplate) {
|
|
2074
|
-
if (hasTemplate.BubbleView) return hasTemplate.BubbleView(message);
|
|
2075
2085
|
|
|
2076
|
-
|
|
2086
|
+
if (templates?.length > 0) {
|
|
2087
|
+
const customTemplate = templates.find(
|
|
2088
|
+
(template) =>
|
|
2089
|
+
template.type === message.getType() && template.category === message.getCategory()
|
|
2090
|
+
);
|
|
2091
|
+
return customTemplate ?? defaultTemplate;
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
return defaultTemplate;
|
|
2095
|
+
}, [message, templatesMap, templates]);
|
|
2096
|
+
|
|
2097
|
+
let bubbleAlignment: MessageBubbleAlignmentType = useMemo(() => {
|
|
2098
|
+
return getAlignment(message);
|
|
2099
|
+
}, [getAlignment]);
|
|
2100
|
+
|
|
2101
|
+
const ContentView = useMemo(() => {
|
|
2102
|
+
return hasTemplate?.ContentView?.(message, bubbleAlignment);
|
|
2103
|
+
}, [hasTemplate, message, bubbleAlignment]);
|
|
2104
|
+
|
|
2105
|
+
const HeaderView = useMemo(() => {
|
|
2106
|
+
return hasTemplate?.HeaderView
|
|
2107
|
+
? hasTemplate?.HeaderView(message, bubbleAlignment)
|
|
2108
|
+
: !isThreaded
|
|
2109
|
+
? getHeaderView(message)
|
|
2110
|
+
: undefined;
|
|
2111
|
+
}, [message, bubbleAlignment, hasTemplate, getHeaderView]);
|
|
2112
|
+
|
|
2113
|
+
const FooterView = useMemo(() => {
|
|
2114
|
+
return hasTemplate?.FooterView
|
|
2115
|
+
? hasTemplate?.FooterView(message, bubbleAlignment)
|
|
2116
|
+
: isThreaded
|
|
2117
|
+
? undefined
|
|
2118
|
+
: getFooterView(message, bubbleAlignment);
|
|
2119
|
+
}, [hasTemplate, isThreaded, getFooterView, message, bubbleAlignment]);
|
|
2120
|
+
|
|
2121
|
+
const ThreadedView = useMemo(() => {
|
|
2122
|
+
return !isThreaded
|
|
2123
|
+
? !message.getDeletedBy()
|
|
2124
|
+
? getThreadView(message, bubbleAlignment)
|
|
2125
|
+
: undefined
|
|
2126
|
+
: undefined;
|
|
2127
|
+
}, [isThreaded, message, getThreadView, bubbleAlignment]);
|
|
2128
|
+
|
|
2129
|
+
const LeadingView = useMemo(() => {
|
|
2130
|
+
return !isThreaded ? getLeadingView(message) : undefined;
|
|
2131
|
+
}, [isThreaded, message, getLeadingView]);
|
|
2132
|
+
|
|
2133
|
+
const BottomView = useMemo(() => {
|
|
2134
|
+
return hasTemplate?.BottomView && hasTemplate?.BottomView(message, bubbleAlignment);
|
|
2135
|
+
}, [hasTemplate, message, bubbleAlignment]);
|
|
2136
|
+
|
|
2137
|
+
const StatusInfoView = useMemo(() => {
|
|
2138
|
+
return hasTemplate?.StatusInfoView &&
|
|
2139
|
+
hasTemplate?.StatusInfoView(message, bubbleAlignment)
|
|
2140
|
+
? hasTemplate?.StatusInfoView(message, bubbleAlignment)
|
|
2141
|
+
: getStatusInfoView(message, bubbleAlignment, currentIndex);
|
|
2142
|
+
}, [hasTemplate, message, bubbleAlignment, currentIndex, getStatusInfoView]);
|
|
2143
|
+
|
|
2144
|
+
if (hasTemplate) {
|
|
2145
|
+
if (hasTemplate?.BubbleView) return hasTemplate?.BubbleView(message);
|
|
2077
2146
|
|
|
2078
|
-
const onLongPress = () => {
|
|
2147
|
+
const onLongPress = useCallback(() => {
|
|
2079
2148
|
if (message.getDeletedBy() != null) return;
|
|
2080
2149
|
setSelectedMessage(message);
|
|
2081
2150
|
hasTemplate && openOptionsForMessage(message, hasTemplate);
|
|
2082
|
-
};
|
|
2151
|
+
}, [hasTemplate, message, openOptionsForMessage]);
|
|
2152
|
+
|
|
2153
|
+
const onPress = useCallback(() => {
|
|
2154
|
+
Keyboard.dismiss();
|
|
2155
|
+
}, []);
|
|
2083
2156
|
|
|
2084
2157
|
return (
|
|
2085
2158
|
<TouchableOpacity
|
|
2086
2159
|
activeOpacity={1}
|
|
2160
|
+
onPress={Platform.OS === "ios" ? onPress : undefined}
|
|
2087
2161
|
onLongPress={() => (showOptions ? onLongPress() : undefined)}
|
|
2088
2162
|
>
|
|
2089
2163
|
<CometChatMessageBubble
|
|
2090
2164
|
id={`${message.getId()}`}
|
|
2091
|
-
LeadingView={
|
|
2092
|
-
HeaderView={
|
|
2093
|
-
|
|
2094
|
-
? hasTemplate.HeaderView(message, bubbleAlignment)
|
|
2095
|
-
: !isThreaded
|
|
2096
|
-
? getHeaderView(message)
|
|
2097
|
-
: undefined
|
|
2098
|
-
}
|
|
2099
|
-
FooterView={
|
|
2100
|
-
hasTemplate.FooterView
|
|
2101
|
-
? hasTemplate.FooterView(message, bubbleAlignment)
|
|
2102
|
-
: isThreaded
|
|
2103
|
-
? undefined
|
|
2104
|
-
: getFooterView(message, bubbleAlignment)
|
|
2105
|
-
}
|
|
2165
|
+
LeadingView={LeadingView}
|
|
2166
|
+
HeaderView={HeaderView}
|
|
2167
|
+
FooterView={FooterView}
|
|
2106
2168
|
alignment={isThreaded ? "left" : bubbleAlignment}
|
|
2107
|
-
ContentView={
|
|
2108
|
-
ThreadView={
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
? getThreadView(message, bubbleAlignment)
|
|
2112
|
-
: undefined
|
|
2113
|
-
: undefined
|
|
2114
|
-
}
|
|
2115
|
-
BottomView={
|
|
2116
|
-
hasTemplate.BottomView && hasTemplate.BottomView(message, bubbleAlignment)
|
|
2117
|
-
}
|
|
2118
|
-
StatusInfoView={
|
|
2119
|
-
hasTemplate.StatusInfoView &&
|
|
2120
|
-
hasTemplate.StatusInfoView(message, bubbleAlignment)
|
|
2121
|
-
? hasTemplate.StatusInfoView(message, bubbleAlignment)
|
|
2122
|
-
: getStatusInfoView(message, bubbleAlignment, currentIndex)
|
|
2123
|
-
}
|
|
2169
|
+
ContentView={ContentView}
|
|
2170
|
+
ThreadView={ThreadedView}
|
|
2171
|
+
BottomView={BottomView}
|
|
2172
|
+
StatusInfoView={StatusInfoView}
|
|
2124
2173
|
style={getCurrentBubbleStyle(message)}
|
|
2125
2174
|
/>
|
|
2126
2175
|
</TouchableOpacity>
|
|
@@ -2129,7 +2178,16 @@ export const CometChatMessageList = memo(
|
|
|
2129
2178
|
return null;
|
|
2130
2179
|
}
|
|
2131
2180
|
},
|
|
2132
|
-
[
|
|
2181
|
+
[
|
|
2182
|
+
mergedTheme,
|
|
2183
|
+
templates,
|
|
2184
|
+
templatesMap,
|
|
2185
|
+
getCurrentBubbleStyle,
|
|
2186
|
+
getThreadView,
|
|
2187
|
+
getFooterView,
|
|
2188
|
+
getLeadingView,
|
|
2189
|
+
getAlignment,
|
|
2190
|
+
]
|
|
2133
2191
|
);
|
|
2134
2192
|
|
|
2135
2193
|
const getSentAtTimestamp = useCallback((item: any) => {
|
|
@@ -2219,36 +2277,40 @@ export const CometChatMessageList = memo(
|
|
|
2219
2277
|
};
|
|
2220
2278
|
|
|
2221
2279
|
const RenderMessageItem = useCallback(
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
);
|
|
2227
|
-
const previousMessageDate = messagesContentListRef.current[index + 1]
|
|
2228
|
-
? new Date(getSentAtTimestamp(messagesContentListRef.current[index + 1]))
|
|
2229
|
-
: null;
|
|
2230
|
-
const currentMessageDate = new Date(getSentAtTimestamp(item));
|
|
2231
|
-
|
|
2232
|
-
const currentDate = isNaN(currentMessageDate.getDate())
|
|
2233
|
-
? undefined
|
|
2234
|
-
: `${currentMessageDate.getDate()}-${currentMessageDate.getMonth()}-${currentMessageDate.getFullYear()}`;
|
|
2235
|
-
|
|
2236
|
-
const previousDate = `${previousMessageDate?.getDate()}-${previousMessageDate?.getMonth()}-${previousMessageDate?.getFullYear()}`;
|
|
2237
|
-
|
|
2238
|
-
if (currentDate != undefined && previousDate !== currentDate) {
|
|
2239
|
-
separatorView = (
|
|
2240
|
-
<View style={{ marginBottom: 10 }}>
|
|
2241
|
-
<CometChatDateSeparator
|
|
2242
|
-
timeStamp={getSentAtTimestamp(item)}
|
|
2243
|
-
pattern={"dayDateFormat"}
|
|
2244
|
-
customDateString={
|
|
2245
|
-
dateSeparatorPattern ? dateSeparatorPattern(item.getSentAt()) : undefined
|
|
2246
|
-
}
|
|
2247
|
-
style={mergedTheme.messageListStyles.dateSeparatorStyle}
|
|
2248
|
-
/>
|
|
2249
|
-
</View>
|
|
2280
|
+
({ item, theme }: { item: CometChat.BaseMessage; theme: CometChatTheme }) => {
|
|
2281
|
+
const index = useMemo(() => {
|
|
2282
|
+
return messagesContentListRef.current.findIndex(
|
|
2283
|
+
(msg) => msg.getId() === item.getId() || msg.getMuid() === item.getMuid()
|
|
2250
2284
|
);
|
|
2251
|
-
}
|
|
2285
|
+
}, [item]);
|
|
2286
|
+
|
|
2287
|
+
const separatorView = useMemo(() => {
|
|
2288
|
+
const previousMessageDate = messagesContentListRef.current[index + 1]
|
|
2289
|
+
? new Date(getSentAtTimestamp(messagesContentListRef.current[index + 1]))
|
|
2290
|
+
: null;
|
|
2291
|
+
const currentMessageDate = new Date(getSentAtTimestamp(item));
|
|
2292
|
+
const currentDate = isNaN(currentMessageDate.getDate())
|
|
2293
|
+
? undefined
|
|
2294
|
+
: `${currentMessageDate.getDate()}-${currentMessageDate.getMonth()}-${currentMessageDate.getFullYear()}`;
|
|
2295
|
+
|
|
2296
|
+
const previousDate = `${previousMessageDate?.getDate()}-${previousMessageDate?.getMonth()}-${previousMessageDate?.getFullYear()}`;
|
|
2297
|
+
if (currentDate !== undefined && previousDate !== currentDate) {
|
|
2298
|
+
return (
|
|
2299
|
+
<View style={{ marginBottom: 10 }}>
|
|
2300
|
+
<CometChatDateSeparator
|
|
2301
|
+
timeStamp={getSentAtTimestamp(item)}
|
|
2302
|
+
pattern={"dayDateFormat"}
|
|
2303
|
+
customDateString={
|
|
2304
|
+
dateSeparatorPattern ? dateSeparatorPattern(item.getSentAt()) : undefined
|
|
2305
|
+
}
|
|
2306
|
+
style={theme.messageListStyles.dateSeparatorStyle}
|
|
2307
|
+
/>
|
|
2308
|
+
</View>
|
|
2309
|
+
);
|
|
2310
|
+
}
|
|
2311
|
+
return null;
|
|
2312
|
+
}, [item, dateSeparatorPattern, theme]);
|
|
2313
|
+
|
|
2252
2314
|
lastMessageDate.current = getSentAtTimestamp(item);
|
|
2253
2315
|
|
|
2254
2316
|
return (
|
|
@@ -2257,11 +2319,11 @@ export const CometChatMessageList = memo(
|
|
|
2257
2319
|
<MessageView message={item} currentIndex={index} />
|
|
2258
2320
|
</React.Fragment>
|
|
2259
2321
|
);
|
|
2260
|
-
}
|
|
2322
|
+
},
|
|
2261
2323
|
[mergedTheme]
|
|
2262
2324
|
);
|
|
2263
2325
|
|
|
2264
|
-
const keyExtractor = useCallback((item: any) => `${item
|
|
2326
|
+
const keyExtractor = useCallback((item: any) => `${item?.getId()}_${item.getMuid()}`, []);
|
|
2265
2327
|
|
|
2266
2328
|
const itemSeparator = useCallback(() => <View style={{ height: 8 }} />, []);
|
|
2267
2329
|
|
|
@@ -2320,6 +2382,9 @@ export const CometChatMessageList = memo(
|
|
|
2320
2382
|
}, []);
|
|
2321
2383
|
|
|
2322
2384
|
const handleScroll = (event: any) => {
|
|
2385
|
+
if (loadingMessagesRef.current) {
|
|
2386
|
+
return;
|
|
2387
|
+
}
|
|
2323
2388
|
const { layoutMeasurement, contentOffset, contentSize } = event.nativeEvent;
|
|
2324
2389
|
if (
|
|
2325
2390
|
Math.floor(contentOffset.y) >= Math.floor(contentSize.height - layoutMeasurement.height)
|
|
@@ -2375,10 +2440,14 @@ export const CometChatMessageList = memo(
|
|
|
2375
2440
|
messageListRef.current?.scrollToOffset({ offset: 0 });
|
|
2376
2441
|
}, []);
|
|
2377
2442
|
|
|
2443
|
+
// const windowSize = useMemo(() => {
|
|
2444
|
+
// return messagesList.length > 50 ? messagesList.length / 2 : 21;
|
|
2445
|
+
// }, [messagesList]);
|
|
2446
|
+
|
|
2378
2447
|
const memoizedRenderItem = useCallback(
|
|
2379
2448
|
({ item, index, separators }: any) => (
|
|
2380
2449
|
<View style={{ flex: 1, paddingHorizontal: 16, paddingVertical: 8 }}>
|
|
2381
|
-
<RenderMessageItem item={item} />
|
|
2450
|
+
<RenderMessageItem item={item} theme={mergedTheme} />
|
|
2382
2451
|
{itemSeparator()}
|
|
2383
2452
|
</View>
|
|
2384
2453
|
),
|
|
@@ -2416,15 +2485,19 @@ export const CometChatMessageList = memo(
|
|
|
2416
2485
|
)}
|
|
2417
2486
|
|
|
2418
2487
|
<FlatList
|
|
2488
|
+
showsVerticalScrollIndicator={false}
|
|
2419
2489
|
ref={messageListRef}
|
|
2420
2490
|
onMomentumScrollEnd={handleScroll}
|
|
2421
2491
|
onScroll={shouldShowScrollToBottomButton}
|
|
2422
2492
|
inverted={true}
|
|
2423
2493
|
scrollEventThrottle={16}
|
|
2424
|
-
keyboardShouldPersistTaps={Platform.OS === "ios" ? "
|
|
2494
|
+
keyboardShouldPersistTaps={Platform.OS === "ios" ? "handled" : "always"}
|
|
2425
2495
|
data={messagesList}
|
|
2426
|
-
keyExtractor={
|
|
2496
|
+
keyExtractor={keyExtractor}
|
|
2427
2497
|
renderItem={memoizedRenderItem}
|
|
2498
|
+
/**Please do not push changes to windowSize without testing infinite scroll and UI interactions and response time**/
|
|
2499
|
+
/**Test the same on release mode. Dev mode could be laggy**/
|
|
2500
|
+
windowSize={33}
|
|
2428
2501
|
/>
|
|
2429
2502
|
|
|
2430
2503
|
{CustomListHeader && <CustomListHeader />}
|
|
@@ -2584,6 +2657,10 @@ export const CometChatMessageList = memo(
|
|
|
2584
2657
|
selectedReaction={selectedEmoji}
|
|
2585
2658
|
onPress={onReactionListItemPressProp}
|
|
2586
2659
|
reactionsRequestBuilder={reactionsRequestBuilder}
|
|
2660
|
+
onListEmpty={() => {
|
|
2661
|
+
setShowReactionList(false);
|
|
2662
|
+
setSelectedEmoji(undefined);
|
|
2663
|
+
}}
|
|
2587
2664
|
/>
|
|
2588
2665
|
</CometChatBottomSheet>
|
|
2589
2666
|
</View>
|
|
@@ -245,14 +245,10 @@ export const getMessageListStylesLight = (
|
|
|
245
245
|
textStyle: {
|
|
246
246
|
...typography.body.bold,
|
|
247
247
|
color: color.receiveBubbleTextHighlight,
|
|
248
|
-
//backgroundColor: '#6852D633',
|
|
249
|
-
//paddingHorizontal: spacing.padding.p0_5
|
|
250
248
|
},
|
|
251
249
|
selfTextStyle: {
|
|
252
250
|
...typography.body.bold,
|
|
253
251
|
color: color.warning,
|
|
254
|
-
//backgroundColor: '#FFAB0033',
|
|
255
|
-
//paddingHorizontal: spacing.padding.p0_5
|
|
256
252
|
},
|
|
257
253
|
},
|
|
258
254
|
},
|
|
@@ -425,14 +421,10 @@ export const getMessageListStylesLight = (
|
|
|
425
421
|
textStyle: {
|
|
426
422
|
...typography.body.bold,
|
|
427
423
|
color: color.sendBubbleTextHighlight,
|
|
428
|
-
//backgroundColor: '#F9F8FD33',
|
|
429
|
-
//paddingHorizontal: spacing.padding.p0_5,
|
|
430
424
|
},
|
|
431
425
|
selfTextStyle: {
|
|
432
426
|
...typography.body.bold,
|
|
433
427
|
color: color.warning,
|
|
434
|
-
//backgroundColor: '#FFAB0033',
|
|
435
|
-
//paddingHorizontal: spacing.padding.p0_5
|
|
436
428
|
},
|
|
437
429
|
},
|
|
438
430
|
},
|
|
@@ -699,14 +691,10 @@ export const getMessageListStylesDark = (
|
|
|
699
691
|
textStyle: {
|
|
700
692
|
...typography.body.bold,
|
|
701
693
|
color: color.receiveBubbleTextHighlight,
|
|
702
|
-
//backgroundColor: '#6852D633',
|
|
703
|
-
//paddingHorizontal: spacing.padding.p0_5
|
|
704
694
|
},
|
|
705
695
|
selfTextStyle: {
|
|
706
696
|
...typography.body.bold,
|
|
707
697
|
color: color.warning,
|
|
708
|
-
//backgroundColor: '#FFAB0033',
|
|
709
|
-
//paddingHorizontal: spacing.padding.p0_5
|
|
710
698
|
},
|
|
711
699
|
},
|
|
712
700
|
},
|
|
@@ -879,14 +867,10 @@ export const getMessageListStylesDark = (
|
|
|
879
867
|
textStyle: {
|
|
880
868
|
...typography.body.bold,
|
|
881
869
|
color: color.sendBubbleTextHighlight,
|
|
882
|
-
//backgroundColor: '#F9F8FD33',
|
|
883
|
-
//paddingHorizontal: spacing.padding.p0_5
|
|
884
870
|
},
|
|
885
871
|
selfTextStyle: {
|
|
886
872
|
...typography.body.bold,
|
|
887
873
|
color: color.warning,
|
|
888
|
-
//backgroundColor: '#FFAB0033',
|
|
889
|
-
//paddingHorizontal: spacing.padding.p0_5
|
|
890
874
|
},
|
|
891
875
|
},
|
|
892
876
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
|
-
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import React, { JSX, useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { ColorValue, KeyboardAvoidingView, Platform, View } from "react-native";
|
|
4
4
|
import {
|
|
5
5
|
CometChatList,
|
package/src/calls/CallUtils.ts
CHANGED
|
@@ -81,8 +81,13 @@ export class CallUtils {
|
|
|
81
81
|
}
|
|
82
82
|
break;
|
|
83
83
|
case CALL_REJECTED:
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
if (this.isInitiator(initiator, loggedInUser)) {
|
|
85
|
+
callMessageText = `${localize("CALL_REJECTED")}`;
|
|
86
|
+
selectedIcon = call["type"] === "audio" ? "call" : "video-call";
|
|
87
|
+
} else {
|
|
88
|
+
callMessageText = `${localize("INCOMING_CALL")}`;
|
|
89
|
+
selectedIcon = call["type"] === "audio" ? "incoming-audio" : "incoming-video";
|
|
90
|
+
}
|
|
86
91
|
break;
|
|
87
92
|
case CALL_BUSY:
|
|
88
93
|
if (this.isInitiator(initiator, loggedInUser)) {
|
|
@@ -111,13 +116,16 @@ export class CallUtils {
|
|
|
111
116
|
* @param loggedInUser - The logged in user.
|
|
112
117
|
* @returns True if it's a missed call.
|
|
113
118
|
*/
|
|
114
|
-
static isMissedCall(call: CometChat.Call, loggedInUser: CometChat.User) {
|
|
119
|
+
static isMissedCall(call: CometChat.Call, loggedInUser: CometChat.User): boolean {
|
|
115
120
|
const callStatus: any = call.getStatus();
|
|
116
|
-
|
|
121
|
+
const iAmInitiator = this.isInitiator((call as any)?.getInitiator(), loggedInUser);
|
|
122
|
+
|
|
123
|
+
if (iAmInitiator) {
|
|
117
124
|
return callStatus === CALL_UNANSWERED;
|
|
118
|
-
} else {
|
|
119
|
-
return [CALL_BUSY, CALL_UNANSWERED, CALL_REJECTED, CALL_CANCELLED].includes(callStatus);
|
|
120
125
|
}
|
|
126
|
+
|
|
127
|
+
// Incoming calls: treat BUSY as missed as well
|
|
128
|
+
return [CALL_UNANSWERED, CALL_CANCELLED, CALL_BUSY].includes(callStatus);
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
/**
|
|
@@ -167,8 +175,8 @@ export class CallUtils {
|
|
|
167
175
|
return hoursString
|
|
168
176
|
? `${hoursString} ${minutesString} ${secondsString}`
|
|
169
177
|
: minutesString
|
|
170
|
-
|
|
171
|
-
|
|
178
|
+
? `${minutesString} ${secondsString}`
|
|
179
|
+
: secondsString;
|
|
172
180
|
}
|
|
173
181
|
|
|
174
182
|
/**
|
|
@@ -196,7 +204,7 @@ export class CallUtils {
|
|
|
196
204
|
return hoursString
|
|
197
205
|
? `${hoursString} ${minutesString} ${secondsString}`
|
|
198
206
|
: minutesString
|
|
199
|
-
|
|
200
|
-
|
|
207
|
+
? `${minutesString} ${secondsString}`
|
|
208
|
+
: secondsString;
|
|
201
209
|
}
|
|
202
210
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
|
-
import React from "react";
|
|
2
|
+
import React, { JSX } from "react";
|
|
3
3
|
import { Modal, View } from "react-native";
|
|
4
4
|
import { ChatConfigurator, CometChatUIEventHandler, CometChatUIKit } from "../shared";
|
|
5
5
|
import { AdditionalAuxiliaryHeaderOptionsParams, AdditionalParams } from "../shared/base/Types";
|
|
@@ -5,6 +5,7 @@ import { useTheme } from "../../theme";
|
|
|
5
5
|
import { localize } from "../../shared";
|
|
6
6
|
import { deepMerge } from "../../shared/helper/helperFunctions";
|
|
7
7
|
import { DeepPartial } from "../../shared/helper/types";
|
|
8
|
+
import { JSX } from "react";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Props for the CometChatMeetCallBubble component.
|
|
@@ -36,20 +37,20 @@ export const CometChatMeetCallBubble = (props: CometChatMeetCallBubbleInterface)
|
|
|
36
37
|
const { icon, titleText, subTitleText, buttonText, onClick, style } = props;
|
|
37
38
|
|
|
38
39
|
return (
|
|
39
|
-
<View style={style
|
|
40
|
+
<View style={style?.containerStyle}>
|
|
40
41
|
{/* Row container for icon and texts */}
|
|
41
42
|
<View style={styles.row}>
|
|
42
|
-
<View style={style
|
|
43
|
+
<View style={style?.iconContainerStyle}>{icon}</View>
|
|
43
44
|
<View style={styles.textContainer}>
|
|
44
|
-
<Text style={style
|
|
45
|
-
<Text style={style
|
|
45
|
+
<Text style={style?.titleStyle}>{titleText}</Text>
|
|
46
|
+
<Text style={style?.subtitleStyle}>{subTitleText}</Text>
|
|
46
47
|
</View>
|
|
47
48
|
</View>
|
|
48
49
|
{/* Divider */}
|
|
49
|
-
<View style={style
|
|
50
|
+
<View style={style?.dividerStyle} />
|
|
50
51
|
{/* Action button */}
|
|
51
|
-
<TouchableOpacity style={style
|
|
52
|
-
<Text style={style
|
|
52
|
+
<TouchableOpacity style={style?.buttonStyle} onPress={onClick}>
|
|
53
|
+
<Text style={style?.buttonTextStyle}>{buttonText}</Text>
|
|
53
54
|
</TouchableOpacity>
|
|
54
55
|
</View>
|
|
55
56
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ImageStyle, TextStyle, ViewStyle } from "react-native";
|
|
2
2
|
import { CometChatTheme } from "../../theme/type";
|
|
3
3
|
import { DeepPartial } from "../../shared/helper/types";
|
|
4
|
+
import { JSX } from "react";
|
|
4
5
|
|
|
5
6
|
export type GroupCallBubbleStyles = {
|
|
6
7
|
titleStyle: TextStyle;
|