@cometchat/chat-uikit-react-native 4.3.16 → 4.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/AI/AIAssistBot/AIAssistBotDecorator.tsx +20 -15
- package/src/AI/AIAssistBot/AIAssistBotStyle.ts +2 -2
- package/src/AI/AIAssistBot/AIAssistBotView.tsx +16 -14
- package/src/AI/AIAssistBot/configuration.ts +8 -7
- package/src/AI/AIAssistBot/resources/index.ts +1 -0
- package/src/AI/AIBaseConfiguration.ts +1 -0
- package/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx +27 -26
- package/src/AI/AIConversationStarter/AIConversationStarterStyle.ts +1 -0
- package/src/AI/AIConversationStarter/style.ts +29 -31
- package/src/AI/AIConversationSummary/AIConversationSummaryDecorator.tsx +14 -13
- package/src/AI/AIConversationSummary/AIConversationSummaryView.tsx +5 -4
- package/src/AI/AIConversationSummary/resources/index.ts +1 -0
- package/src/AI/AIExtensionDataSource.ts +1 -0
- package/src/AI/AISmartReplies/AISmartRepliesDecorator.tsx +28 -27
- package/src/AI/AISmartReplies/configuration.ts +2 -0
- package/src/AI/CardView.tsx +5 -5
- package/src/AI/resources/index.ts +3 -0
- package/src/AI/style.ts +68 -80
- package/src/CometChatAddMembers/AddMembersConfiguration.tsx +1 -0
- package/src/CometChatAddMembers/CometChatAddMembers.tsx +14 -13
- package/src/CometChatAddMembers/index.ts +10 -8
- package/src/CometChatBannedMembers/BannedMembersConfiguration.tsx +1 -0
- package/src/CometChatBannedMembers/CometChatBannedMembers.tsx +11 -8
- package/src/CometChatBannedMembers/index.ts +12 -7
- package/src/CometChatBannedMembers/resources/index.ts +1 -0
- package/src/CometChatContacts/CometChatContacts.tsx +9 -9
- package/src/CometChatContacts/ContactsConfiguration.tsx +1 -0
- package/src/CometChatContacts/Header.tsx +4 -4
- package/src/CometChatContacts/index.ts +5 -3
- package/src/CometChatConversations/CometChatConversations.tsx +289 -221
- package/src/CometChatConversations/ConversationsConfiguration.ts +14 -0
- package/src/CometChatConversations/index.ts +21 -10
- package/src/CometChatConversations/resources/index.ts +14 -0
- package/src/CometChatConversationsWithMessages/CometChatConversationsWithMessages.tsx +7 -5
- package/src/CometChatConversationsWithMessages/index.ts +6 -5
- package/src/CometChatConversationsWithMessages/resources/index.ts +1 -0
- package/src/CometChatCreateGroup/CometChatCreateGroup.tsx +30 -30
- package/src/CometChatCreateGroup/CreateGroupConfiguration.ts +1 -0
- package/src/CometChatCreateGroup/Header.tsx +1 -1
- package/src/CometChatCreateGroup/index.ts +5 -6
- package/src/CometChatCreateGroup/resources/index.ts +3 -0
- package/src/CometChatDetails/CometChatDetails.tsx +29 -28
- package/src/CometChatDetails/DetailsConfiguration.tsx +1 -0
- package/src/CometChatDetails/Header.tsx +1 -1
- package/src/CometChatDetails/index.ts +17 -15
- package/src/CometChatDetails/listners.ts +16 -16
- package/src/CometChatDetails/resources/index.ts +5 -0
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +62 -52
- package/src/CometChatGroupMembers/GroupMemberConfiguration.ts +1 -1
- package/src/CometChatGroupMembers/GroupMemberStyle.ts +3 -3
- package/src/CometChatGroupMembers/index.ts +8 -16
- package/src/CometChatGroupMembers/resources/index.ts +5 -0
- package/src/CometChatGroups/CometChatGroups.tsx +46 -46
- package/src/CometChatGroups/GroupsConfiguration.ts +10 -9
- package/src/CometChatGroups/GroupsStyle.ts +1 -1
- package/src/CometChatGroups/index.ts +11 -10
- package/src/CometChatGroups/resources/index.ts +10 -0
- package/src/CometChatGroupsWithMessages/CometChatGroupsWithMessages.tsx +9 -8
- package/src/CometChatGroupsWithMessages/index.ts +6 -5
- package/src/CometChatGroupsWithMessages/resources/index.ts +1 -0
- package/src/CometChatJoinProtectedGroup/CometChatJoinProtectedGroup.tsx +22 -21
- package/src/CometChatJoinProtectedGroup/Header.tsx +1 -1
- package/src/CometChatJoinProtectedGroup/JoinProtectedGroupConfiguration.ts +1 -0
- package/src/CometChatJoinProtectedGroup/index.ts +5 -6
- package/src/CometChatJoinProtectedGroup/resources/index.ts +2 -0
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +62 -59
- package/src/CometChatMessageComposer/MessageComposerConfiguration.tsx +1 -0
- package/src/CometChatMessageComposer/index.ts +6 -7
- package/src/CometChatMessageComposer/resources/index.ts +10 -0
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +33 -31
- package/src/CometChatMessageHeader/MessageHeaderConfiguration.tsx +1 -0
- package/src/CometChatMessageHeader/index.ts +12 -13
- package/src/CometChatMessageHeader/listners.ts +18 -18
- package/src/CometChatMessageHeader/resources/index.ts +3 -0
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +28 -24
- package/src/CometChatMessageInformation/index.ts +8 -8
- package/src/CometChatMessageInformation/resources/index.ts +1 -0
- package/src/CometChatMessageList/CometChatMessageList.tsx +289 -227
- package/src/CometChatMessageList/MessageListConfiguration.ts +50 -25
- package/src/CometChatMessageList/index.ts +16 -18
- package/src/CometChatMessageList/resources/index.ts +7 -0
- package/src/CometChatMessages/CometChatMessages.tsx +29 -26
- package/src/CometChatMessages/MessagesConfiguration.ts +2 -0
- package/src/CometChatMessages/index.ts +8 -7
- package/src/CometChatMessages/resources/index.ts +1 -0
- package/src/CometChatTabs/CometChatTabs.tsx +13 -23
- package/src/CometChatTabs/CometChatTabsStyle.ts +2 -0
- package/src/CometChatTabs/index.ts +3 -8
- package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +37 -37
- package/src/CometChatThreadedMessages/Header.tsx +2 -2
- package/src/CometChatThreadedMessages/ThreadedMessagesConfiguration.ts +1 -0
- package/src/CometChatThreadedMessages/index.ts +11 -12
- package/src/CometChatThreadedMessages/resources/index.ts +6 -0
- package/src/CometChatTransferOwnership/CometChatTransferOwnership.tsx +5 -5
- package/src/CometChatTransferOwnership/TransferOwnershipConfiguration.ts +1 -0
- package/src/CometChatTransferOwnership/index.ts +10 -11
- package/src/CometChatUsers/CometChatUsers.tsx +11 -11
- package/src/CometChatUsers/UsersConfiguration.tsx +1 -0
- package/src/CometChatUsers/index.ts +8 -6
- package/src/CometChatUsersWithMessages/CometChatUsersWithMessages.tsx +6 -5
- package/src/CometChatUsersWithMessages/index.ts +6 -5
- package/src/calls/CallUtils.ts +4 -3
- package/src/calls/CallingDetailsUtils.tsx +9 -8
- package/src/calls/CallingExtension.tsx +2 -2
- package/src/calls/CallingExtentionDecorator.tsx +17 -17
- package/src/calls/CometChatCallBubble/CometChatCallBubble.tsx +3 -2
- package/src/calls/CometChatCallBubble/index.ts +14 -10
- package/src/calls/CometChatCallBubble/resources/index.ts +3 -0
- package/src/calls/CometChatCallButtons/CometChatCallButtonConfiguration.ts +1 -0
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +19 -18
- package/src/calls/CometChatCallButtons/index.ts +10 -8
- package/src/calls/CometChatCallButtons/resources/index.ts +2 -0
- package/src/calls/CometChatCallLogDetails/CallLogDetailsConfiguration.ts +2 -0
- package/src/calls/CometChatCallLogDetails/CometChatCallLogDetails.tsx +14 -13
- package/src/calls/CometChatCallLogDetails/index.ts +21 -10
- package/src/calls/CometChatCallLogDetails/resources/index.ts +1 -0
- package/src/calls/CometChatCallLogHistory/CallLogHistoryConfiguration.ts +3 -1
- package/src/calls/CometChatCallLogHistory/CometChatCallLogHistory.tsx +25 -24
- package/src/calls/CometChatCallLogHistory/index.ts +21 -10
- package/src/calls/CometChatCallLogHistory/resources/index.ts +13 -0
- package/src/calls/CometChatCallLogParticipants/CallLogParticipantsConfiguration.ts +4 -2
- package/src/calls/CometChatCallLogParticipants/CometChatCallLogParticipants.tsx +13 -12
- package/src/calls/CometChatCallLogParticipants/index.ts +21 -10
- package/src/calls/CometChatCallLogParticipants/resources/index.ts +1 -0
- package/src/calls/CometChatCallLogRecordings/CallLogRecordingsConfiguration.ts +5 -3
- package/src/calls/CometChatCallLogRecordings/CometChatCallLogRecordings.tsx +14 -13
- package/src/calls/CometChatCallLogRecordings/index.ts +21 -10
- package/src/calls/CometChatCallLogRecordings/resources/index.ts +2 -0
- package/src/calls/CometChatCallLogs/CallLogsConfiguration.ts +5 -3
- package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +37 -36
- package/src/calls/CometChatCallLogs/index.ts +14 -10
- package/src/calls/CometChatCallLogs/resources/index.ts +11 -0
- package/src/calls/CometChatCallLogsWithDetails/CallLogsWithDetailsConfiguration.ts +1 -0
- package/src/calls/CometChatCallLogsWithDetails/CometChatCallLogsWithDetails.tsx +3 -2
- package/src/calls/CometChatCallLogsWithDetails/index.ts +2 -4
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +19 -15
- package/src/calls/CometChatIncomingCall/index.ts +10 -8
- package/src/calls/CometChatIncomingCall/resources/index.ts +4 -0
- package/src/calls/CometChatIncomingCall/styles.ts +0 -1
- package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +5 -4
- package/src/calls/CometChatOngoingCall/index.ts +6 -6
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +15 -13
- package/src/calls/CometChatOutgoingCall/index.ts +8 -6
- package/src/calls/CometChatOutgoingCall/resources/index.ts +1 -0
- package/src/calls/index.ts +99 -60
- package/src/calls/resources/index.ts +3 -0
- package/src/extensions/CollaborativeBubble/CometChatCollaborativeBubble.tsx +1 -0
- package/src/extensions/CollaborativeBubble/resources/index.ts +1 -0
- package/src/extensions/CollaborativeBubble/styles.ts +1 -1
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentConfiguration.tsx +1 -1
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +10 -9
- package/src/extensions/CollaborativeDocument/index.ts +12 -9
- package/src/extensions/CollaborativeDocument/resources/index.ts +2 -0
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardConfiguration.tsx +1 -1
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +15 -14
- package/src/extensions/CollaborativeWhiteboard/index.ts +12 -9
- package/src/extensions/CollaborativeWhiteboard/resources/index.ts +2 -0
- package/src/extensions/ExtensionModerator.tsx +4 -4
- package/src/extensions/ImageModeration/ImageModerationDecorator.tsx +1 -1
- package/src/extensions/ImageModeration/ImageModerationFilter.tsx +2 -1
- package/src/extensions/ImageModeration/index.ts +15 -7
- package/src/extensions/ImageModeration/resources/index.ts +1 -0
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +8 -8
- package/src/extensions/LinkPreview/LinkPreviewExtention.tsx +1 -1
- package/src/extensions/LinkPreview/LinkPreviewExtentionDecorator.tsx +2 -1
- package/src/extensions/LinkPreview/index.ts +18 -10
- package/src/extensions/LinkPreview/resources/index.ts +1 -0
- package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +7 -7
- package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +19 -17
- package/src/extensions/MessageTranslation/index.ts +7 -7
- package/src/extensions/MessageTranslation/resources/index.ts +1 -0
- package/src/extensions/Polls/Header.tsx +8 -8
- package/src/extensions/Polls/Polls.tsx +38 -33
- package/src/extensions/Polls/PollsBubble.tsx +35 -33
- package/src/extensions/Polls/PollsDecorator.tsx +7 -7
- package/src/extensions/Polls/index.ts +4 -5
- package/src/extensions/Polls/resources/index.ts +5 -0
- package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +11 -11
- package/src/extensions/SmartReplies/SmartRepliesView.tsx +4 -3
- package/src/extensions/SmartReplies/index.ts +6 -2
- package/src/extensions/SmartReplies/resources/index.ts +1 -0
- package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +12 -10
- package/src/extensions/Stickers/CometChatStickerKeyboard/StickerKeyboardConfiguration.ts +2 -1
- package/src/extensions/Stickers/CometChatStickerKeyboard/hooks.ts +19 -17
- package/src/extensions/Stickers/StickersBubble.tsx +4 -4
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +11 -10
- package/src/extensions/Stickers/index.ts +13 -8
- package/src/extensions/Stickers/resources/index.ts +1 -0
- package/src/extensions/TextModeration/TextModerationConfiguration.tsx +1 -1
- package/src/extensions/TextModeration/TextModerationExtension.tsx +1 -0
- package/src/extensions/TextModeration/TextModerationExtensionDecorator.tsx +1 -0
- package/src/extensions/TextModeration/index.ts +5 -4
- package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +5 -5
- package/src/extensions/ThumbnailGeneration/index.ts +6 -2
- package/src/extensions/ThumbnailGeneration/resources/index.ts +1 -0
- package/src/extensions/index.ts +92 -47
- package/src/index.ts +225 -232
- package/src/shared/CometChatContext.tsx +1 -1
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +40 -36
- package/src/shared/CometChatUiKit/CometChatUIKitHelper.ts +1 -0
- package/src/shared/assets/images/index.ts +16 -0
- package/src/shared/assets/images/search.png +0 -0
- package/src/shared/base/FontStyle.ts +2 -2
- package/src/shared/base/index.ts +8 -11
- package/src/shared/base/vars.ts +2 -2
- package/src/shared/constants/UIKitConstants.ts +16 -1
- package/src/shared/events/CometChatMessageEvents/index.ts +6 -4
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +221 -219
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +39 -37
- package/src/shared/events/ListenerInitializer.ts +8 -1
- package/src/shared/events/messages.ts +2 -0
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +11 -15
- package/src/shared/formatters/CometChatTextFormatter.ts +6 -5
- package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +8 -10
- package/src/shared/framework/DataSource.ts +17 -17
- package/src/shared/framework/DataSourceDecorator.tsx +3 -2
- package/src/shared/framework/ExtensionsDataSource.tsx +1 -0
- package/src/shared/framework/MessageDataSource.tsx +125 -117
- package/src/shared/framework/index.ts +12 -6
- package/src/shared/framework/resources/index.ts +20 -0
- package/src/shared/helper/helperFunctions.ts +7 -5
- package/src/shared/index.ts +109 -100
- package/src/shared/libs/CometChatCalendar/Calendars/BaseCalendar.tsx +6 -3
- package/src/shared/libs/CometChatCalendar/Calendars/DateSelectionCalendar.tsx +2 -0
- package/src/shared/libs/CometChatCalendar/Calendars/MultiDateSelectionCalendar.tsx +2 -0
- package/src/shared/libs/CometChatCalendar/Components/Day.tsx +2 -0
- package/src/shared/libs/CometChatCalendar/Components/Days.tsx +1 -0
- package/src/shared/libs/CometChatCalendar/Components/Month.tsx +1 -0
- package/src/shared/libs/CometChatCalendar/Components/Months.tsx +1 -0
- package/src/shared/libs/CometChatCalendar/Components/Title.tsx +2 -0
- package/src/shared/libs/CometChatCalendar/Hooks/useSurroundingTimeUnits.ts +3 -0
- package/src/shared/libs/CometChatCalendar/Locales/index.ts +1 -0
- package/src/shared/libs/CometChatCalendar/Utils/dateRange.ts +1 -0
- package/src/shared/libs/CometChatCalendar/Utils/getExtraDays.ts +1 -0
- package/src/shared/libs/CometChatCalendar/Utils/getSurroundingTimeUnits.ts +1 -0
- package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +45 -42
- package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +13 -11
- package/src/shared/libs/ImageZoom/types/index.ts +12 -12
- package/src/shared/libs/VideoPlayerControls/OSSupport/TVOSSupport.tsx +1 -0
- package/src/shared/libs/VideoPlayerControls/VideoPlayer.tsx +1 -0
- package/src/shared/libs/datePickerModal/Modal.js +1 -1
- package/src/shared/modals/CometChatDetailsOption.ts +2 -2
- package/src/shared/modals/CometChatMessageTemplate.ts +13 -12
- package/src/shared/modals/InteractiveData/InteractiveElements/DateTimeElement.ts +7 -7
- package/src/shared/modals/InteractiveData/InteractiveMessage/CardMessage.ts +1 -0
- package/src/shared/modals/InteractiveData/InteractiveMessage/CustomInteractiveMessage.ts +1 -0
- package/src/shared/modals/InteractiveData/InteractiveMessage/FormMessage.ts +1 -0
- package/src/shared/modals/InteractiveData/InteractiveMessage/SchedulerMessage.ts +6 -7
- package/src/shared/modals/index.ts +37 -14
- package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +5 -5
- package/src/shared/resources/CometChatSoundManager/index.ts +1 -0
- package/src/shared/resources/CometChatTheme/Palette.ts +57 -55
- package/src/shared/resources/CometChatTheme/Typography.ts +30 -30
- package/src/shared/utils/CometChatLiveReactions/CometChatLiveReaction.tsx +17 -13
- package/src/shared/utils/CometChatLiveReactions/resources/index.ts +1 -0
- package/src/shared/utils/CometChatMessageHelper/index.ts +2 -2
- package/src/shared/utils/CometChatMessagePreview/{index.js → index.ts} +3 -0
- package/src/shared/utils/CometChatMessagePreview/resources/index.ts +1 -0
- package/src/shared/utils/CommonUtils.ts +85 -1
- package/src/shared/utils/DetailsUtils/DetailsUtils.tsx +3 -2
- package/src/shared/utils/DetailsUtils/resources/index.ts +7 -0
- package/src/shared/utils/InteractiveMessageUtils.ts +6 -5
- package/src/shared/utils/MessageUtils.tsx +108 -18
- package/src/shared/utils/NetworkUtils.tsx +1 -1
- package/src/shared/utils/PermissionUtil.ts +7 -6
- package/src/shared/utils/SchedulerUtils.ts +8 -6
- package/src/shared/utils/TypeUtils.ts +3 -0
- package/src/shared/utils/conversationUtils.ts +7 -5
- package/src/shared/utils/index.ts +2 -0
- package/src/shared/views/CometChatAICard/CometChatAICard.tsx +7 -6
- package/src/shared/views/CometChatAICard/resources/index.ts +2 -0
- package/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts +3 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +5 -5
- package/src/shared/views/CometChatActionSheet/hooks.ts +2 -2
- package/src/shared/views/CometChatActionSheet/index.ts +5 -3
- package/src/shared/views/CometChatActionSheet/resources/index.ts +2 -0
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +6 -6
- package/src/shared/views/CometChatAudioBubble/index.ts +8 -12
- package/src/shared/views/CometChatAudioBubble/resources/index.ts +2 -0
- package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +6 -5
- package/src/shared/views/CometChatAvatar/index.ts +7 -9
- package/src/shared/views/CometChatBadge/CometChatBadge.tsx +3 -3
- package/src/shared/views/CometChatBadge/index.ts +7 -9
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +51 -48
- package/src/shared/views/CometChatBottomSheet/index.ts +6 -2
- package/src/shared/views/CometChatButton/CometChatButton.tsx +5 -5
- package/src/shared/views/CometChatButton/index.ts +4 -14
- package/src/shared/views/CometChatCard/CometChatCard.tsx +3 -3
- package/src/shared/views/CometChatCard/index.ts +6 -7
- package/src/shared/views/CometChatCardBubble/CometChatCardBubble.tsx +11 -10
- package/src/shared/views/CometChatCardBubble/index.tsx +2 -1
- package/src/shared/views/CometChatCheckBox/CometChatCheckBox.tsx +6 -6
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +9 -9
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialogStyle.ts +1 -0
- package/src/shared/views/CometChatConfirmDialog/index.ts +9 -6
- package/src/shared/views/CometChatDate/CometChatDate.tsx +2 -2
- package/src/shared/views/CometChatDate/index.ts +12 -11
- package/src/shared/views/CometChatDateTimePicker/CometChatDateTimePicker.tsx +20 -17
- package/src/shared/views/CometChatDateTimePicker/index.ts +3 -5
- package/src/shared/views/CometChatDropDown/CometChatDropDown.tsx +8 -7
- package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +24 -33
- package/src/shared/views/CometChatEmojiKeyboard/Emoji.ts +1 -1
- package/src/shared/views/CometChatEmojiKeyboard/EmojiCategory.ts +1 -1
- package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardConfiguration.ts +2 -1
- package/src/shared/views/CometChatEmojiKeyboard/EmojiKeyboardStyle.ts +2 -1
- package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +8 -0
- package/src/shared/views/CometChatEmojiKeyboard/resources/index.ts +8 -0
- package/src/shared/views/CometChatEmojiKeyboard/style.ts +2 -2
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +3 -3
- package/src/shared/views/CometChatFileBubble/FileBubbleStyle.ts +1 -1
- package/src/shared/views/CometChatFileBubble/index.ts +7 -8
- package/src/shared/views/CometChatFileBubble/resources/index.ts +2 -0
- package/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx +33 -29
- package/src/shared/views/CometChatFormBubble/index.tsx +2 -1
- package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +63 -17
- package/src/shared/views/CometChatImageBubble/ImageBubbleStyle.ts +1 -1
- package/src/shared/views/CometChatImageBubble/assets/default_image.png +0 -0
- package/src/shared/views/CometChatImageBubble/assets/index.ts +3 -0
- package/src/shared/views/CometChatImageBubble/index.ts +10 -8
- package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +1 -1
- package/src/shared/views/CometChatImageViewerModal/resources/index.ts +1 -0
- package/src/shared/views/CometChatLabel/CometChatLabel.tsx +2 -2
- package/src/shared/views/CometChatList/CometChatList.tsx +46 -42
- package/src/shared/views/CometChatList/index.ts +3 -3
- package/src/shared/views/CometChatList/resources/index.ts +5 -0
- package/src/shared/views/CometChatListItem/CometChatListItem.tsx +18 -13
- package/src/shared/views/CometChatListItem/ListItemConfiguration.tsx +1 -0
- package/src/shared/views/CometChatListItem/index.ts +8 -7
- package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +34 -31
- package/src/shared/views/CometChatMediaRecorder/index.ts +8 -9
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +22 -15
- package/src/shared/views/CometChatMessageBubble/MessageBubbleStyle.ts +4 -0
- package/src/shared/views/CometChatMessageBubble/index.ts +6 -5
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +10 -9
- package/src/shared/views/CometChatMessageInput/index.ts +2 -1
- package/src/shared/views/CometChatPanel/CometChatPanel.tsx +3 -3
- package/src/shared/views/CometChatPanel/resources/index.ts +1 -0
- package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +4 -4
- package/src/shared/views/CometChatQuickReactions/QuickReactionsConfiguration.tsx +1 -0
- package/src/shared/views/CometChatQuickReactions/index.ts +3 -7
- package/src/shared/views/CometChatQuickReactions/resources/index.ts +1 -0
- package/src/shared/views/CometChatQuickView/CometChatQuickView.tsx +6 -6
- package/src/shared/views/CometChatRadioButton/CometChatRadioButton.tsx +4 -4
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +29 -28
- package/src/shared/views/CometChatReactionList/ReactionListConfiguration.tsx +1 -0
- package/src/shared/views/CometChatReactionList/index.ts +3 -7
- package/src/shared/views/CometChatReactionList/resources/index.ts +1 -0
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +14 -14
- package/src/shared/views/CometChatReactions/ReactionsConfiguration.tsx +1 -0
- package/src/shared/views/CometChatReactions/index.ts +15 -11
- package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +5 -5
- package/src/shared/views/CometChatReceipt/index.ts +10 -8
- package/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx +59 -53
- package/src/shared/views/CometChatSchedulerBubble/index.ts +3 -5
- package/src/shared/views/CometChatSchedulerBubble/styles.ts +1 -1
- package/src/shared/views/CometChatSingleSelect/CometChatSingleSelect.tsx +4 -4
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +4 -4
- package/src/shared/views/CometChatStatusIndicator/StatusIndicatorConfiguration.ts +2 -2
- package/src/shared/views/CometChatStatusIndicator/index.ts +21 -10
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +1 -1
- package/src/shared/views/CometChatSuggestionList/SuggestionItem.ts +5 -5
- package/src/shared/views/CometChatSuggestionList/SuggestionListConfiguration.ts +3 -3
- package/src/shared/views/CometChatSuggestionList/index.ts +14 -10
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +6 -5
- package/src/shared/views/CometChatTextBubble/index.ts +6 -7
- package/src/shared/views/CometChatTextInput/CometChatTextInput.tsx +2 -2
- package/src/shared/views/CometChatTimeSlotSelector/CometChatTimeSlotSelector.tsx +5 -5
- package/src/shared/views/CometChatTimeSlotSelector/index.ts +3 -5
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +9 -8
- package/src/shared/views/CometChatVideoBubble/index.ts +10 -8
- package/src/shared/views/CometChatVideoBubble/resources/index.ts +2 -0
- package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +1 -1
- package/src/shared/views/SwipeRow/SwipeRow.tsx +4 -3
- package/src/shared/views/index.ts +151 -86
- package/ios/CometchatUiKit.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/CometchatUiKit.xcodeproj/xcuserdata/admin.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/src/shared/libs/CometChatCalendar/Components/Arrow.test.tsx +0 -112
- package/src/shared/libs/CometChatCalendar/Components/Day.test.tsx +0 -396
- package/src/shared/libs/CometChatCalendar/Components/Days.test.tsx +0 -216
- package/src/shared/libs/CometChatCalendar/Components/Month.test.tsx +0 -160
- package/src/shared/libs/CometChatCalendar/Components/Months.test.tsx +0 -262
- package/src/shared/libs/CometChatCalendar/Components/Title.test.tsx +0 -111
- package/src/shared/libs/CometChatCalendar/Components/Weekdays.test.tsx +0 -69
- package/src/shared/libs/CometChatCalendar/Hooks/useSurroundingTimeUnits.test.ts +0 -44
- package/src/shared/libs/CometChatCalendar/Utils/addOpacity.test.ts +0 -49
- package/src/shared/libs/CometChatCalendar/Utils/clamp.test.ts +0 -39
- package/src/shared/libs/CometChatCalendar/Utils/dateRange.test.ts +0 -20
- package/src/shared/libs/CometChatCalendar/Utils/getExtraDays.test.ts +0 -48
- package/src/shared/libs/CometChatCalendar/Utils/getSurroundingTimeUnits.test.ts +0 -60
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { forwardRef, useEffect, useRef, useState, useImperativeHandle, useContext, useCallback, memo, useLayoutEffect } from "react";
|
|
2
|
-
import { View, FlatList, Text, Image, TouchableOpacity, ActivityIndicator, Modal, SafeAreaView, NativeModules, ScrollView, Dimensions, Platform, Keyboard } from "react-native";
|
|
2
|
+
import { View, FlatList, Text, Image, TouchableOpacity, ActivityIndicator, Modal, SafeAreaView, NativeModules, ScrollView, Dimensions, Platform, Keyboard, TextStyle, ViewProps } from "react-native";
|
|
3
3
|
//@ts-ignore
|
|
4
4
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
5
5
|
import { LeftArrowCurve, RightArrowCurve } from "./resources";
|
|
6
|
-
import {
|
|
6
|
+
import { CometChatContext, CometChatMentionsFormatter, CometChatTextFormatter, CometChatUIKit, CometChatUiKitConstants, CometChatUrlsFormatter, ImageType, SuggestionItem } from "../shared";
|
|
7
7
|
import { MessageBubbleStyle, MessageBubbleStyleInterface } from "../shared/views/CometChatMessageBubble/MessageBubbleStyle";
|
|
8
8
|
import { AvatarStyle, AvatarStyleInterface } from "../shared";
|
|
9
9
|
import { CometChatAvatar, CometChatDate, CometChatReceipt, DateStyle } from "../shared";
|
|
@@ -20,7 +20,7 @@ import { ChatConfigurator } from "../shared/framework/ChatConfigurator";
|
|
|
20
20
|
import { CometChatActionSheet, ActionSheetStyles, CometChatBottomSheet } from "../shared";
|
|
21
21
|
import { getUnixTimestamp, messageStatus } from "../shared/utils/CometChatMessageHelper";
|
|
22
22
|
import { DateStyleInterface } from "../shared/views/CometChatDate/DateStyle";
|
|
23
|
-
import { CometChatContextType, MessageBubbleAlignmentType, MessageListAlignmentType, MessageTimeAlignmentType } from "../shared/base/Types";
|
|
23
|
+
import { CometChatContextType, MessageBubbleAlignmentType, MessageListAlignmentType, MessageReceipt, MessageTimeAlignmentType } from "../shared/base/Types";
|
|
24
24
|
import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
|
|
25
25
|
import { ActionSheetStylesInterface } from "../shared/views/CometChatActionSheet/ActionSheetStyle";
|
|
26
26
|
import { CometChatMessageInformation } from "../CometChatMessageInformation/CometChatMessageInformation";
|
|
@@ -32,8 +32,10 @@ import { CometChatReactionList, ReactionListConfigurationInterface } from "../sh
|
|
|
32
32
|
import { CometChatQuickReactions, QuickReactionsConfigurationInterface } from "../shared/views/CometChatQuickReactions";
|
|
33
33
|
import { CometChatReactions, ReactionsConfigurationInterface } from "../shared/views/CometChatReactions";
|
|
34
34
|
import { CommonUtils } from "../shared/utils/CommonUtils";
|
|
35
|
+
//@ts-ignore
|
|
35
36
|
import Clipboard from "@react-native-clipboard/clipboard";
|
|
36
37
|
import { commonVars } from "../shared/base/vars";
|
|
38
|
+
import { anyObject } from "../shared/utils";
|
|
37
39
|
|
|
38
40
|
let templatesMap = new Map<string, CometChatMessageTemplate>();
|
|
39
41
|
|
|
@@ -50,7 +52,13 @@ export interface CometChatMessageListProps {
|
|
|
50
52
|
errorStateText?: String,
|
|
51
53
|
hideError?: boolean,
|
|
52
54
|
LoadingStateView?: () => JSX.Element,
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated
|
|
57
|
+
*
|
|
58
|
+
* This property is deprecated as of version 4.3.18 due to newer property 'hideReceipt'. It will be removed in subsequent versions.
|
|
59
|
+
*/
|
|
53
60
|
disableReceipt?: boolean,
|
|
61
|
+
hideReceipt?: boolean,
|
|
54
62
|
disableSoundForMessages?: boolean,
|
|
55
63
|
customSoundForMessages?: string,
|
|
56
64
|
readIcon?: ImageType,
|
|
@@ -74,7 +82,7 @@ export interface CometChatMessageListProps {
|
|
|
74
82
|
newMessageIndicatorText?: string,
|
|
75
83
|
scrollToBottomOnNewMessages?: boolean,
|
|
76
84
|
// threadholdValue?: number,
|
|
77
|
-
onThreadRepliesPress?: (messageObject: CometChat.BaseMessage, messageBubbleView: () => JSX.Element) => void,
|
|
85
|
+
onThreadRepliesPress?: (messageObject: CometChat.BaseMessage, messageBubbleView: () => JSX.Element | null) => void,
|
|
78
86
|
HeaderView?: ({ user, group, id }: { user?: CometChat.User, group?: CometChat.Group, id?: { uid?: string, guid?: string, parentMessageId?: string } }) => JSX.Element,
|
|
79
87
|
FooterView?: ({ user, group, id }: { user?: CometChat.User, group?: CometChat.Group, id?: { uid?: string, guid?: string, parentMessageId?: string } }) => JSX.Element,
|
|
80
88
|
wrapperMessageBubbleStyle?: MessageBubbleStyleInterface,
|
|
@@ -144,6 +152,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
144
152
|
hideError,
|
|
145
153
|
LoadingStateView,
|
|
146
154
|
disableReceipt = false,
|
|
155
|
+
hideReceipt= false,
|
|
147
156
|
disableSoundForMessages,
|
|
148
157
|
customSoundForMessages,
|
|
149
158
|
readIcon,
|
|
@@ -197,13 +206,13 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
197
206
|
_defaultRequestBuilder = new CometChat.MessagesRequestBuilder()
|
|
198
207
|
.setLimit(30)
|
|
199
208
|
.setTags([])
|
|
200
|
-
.setUID(user
|
|
209
|
+
.setUID(user.getUid());
|
|
201
210
|
}
|
|
202
211
|
else if (group) {
|
|
203
212
|
_defaultRequestBuilder = new CometChat.MessagesRequestBuilder()
|
|
204
213
|
.setLimit(30)
|
|
205
214
|
.setTags([])
|
|
206
|
-
.setGUID(group
|
|
215
|
+
.setGUID(group.getGuid());
|
|
207
216
|
}
|
|
208
217
|
|
|
209
218
|
_defaultRequestBuilder.setTypes(ChatConfigurator.dataSource.getAllMessageTypes())
|
|
@@ -214,18 +223,18 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
214
223
|
if (messageRequestBuilder) {
|
|
215
224
|
_updatedCustomRequestBuilder = messageRequestBuilder;
|
|
216
225
|
if (user)
|
|
217
|
-
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setUID(user
|
|
226
|
+
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setUID(user.getUid())
|
|
218
227
|
if (group)
|
|
219
|
-
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setGUID(group
|
|
228
|
+
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setGUID(group.getGuid())
|
|
220
229
|
} else {
|
|
221
230
|
_updatedCustomRequestBuilder.hideReplies(true);
|
|
222
231
|
if (user)
|
|
223
|
-
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setUID(user
|
|
232
|
+
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setUID(user.getUid())
|
|
224
233
|
if (group)
|
|
225
|
-
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setGUID(group
|
|
234
|
+
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setGUID(group.getGuid())
|
|
226
235
|
if (parentMessageId)
|
|
227
236
|
_updatedCustomRequestBuilder = _updatedCustomRequestBuilder.setParentMessageId(parseInt(parentMessageId));
|
|
228
|
-
let types = [], categories = [];
|
|
237
|
+
let types: any[] = [], categories: any[] = [];
|
|
229
238
|
if (templates.length) {
|
|
230
239
|
types = templates.map(template => template.type);
|
|
231
240
|
categories = templates.map(template => template.category);
|
|
@@ -288,42 +297,52 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
288
297
|
})).current;
|
|
289
298
|
|
|
290
299
|
// refs
|
|
291
|
-
const currentScrollPosition = useRef({ y: null, scrollViewHeight: 0, layoutHeight: 0 });
|
|
300
|
+
const currentScrollPosition = useRef({ y: null, scrollViewHeight: 0, layoutHeight: 0, contentHeight: 0 });
|
|
292
301
|
const previousScrollPosition = useRef({ y: 0, scrollViewHeight: 0 });
|
|
293
302
|
const messagesLength = useRef(0);
|
|
294
303
|
const prevMessagesLength = useRef(0);
|
|
295
|
-
const messageListRef = useRef<ScrollView>(null);
|
|
296
|
-
const loggedInUser = useRef<CometChat.User>(null);
|
|
297
|
-
const messageRequest = useRef<CometChat.MessagesRequest>(null);
|
|
298
|
-
const messagesContentListRef = useRef([]);
|
|
304
|
+
const messageListRef = useRef<ScrollView | null>(null);
|
|
305
|
+
const loggedInUser = useRef<CometChat.User | null | any>(null);
|
|
306
|
+
const messageRequest = useRef<CometChat.MessagesRequest | null>(null);
|
|
307
|
+
const messagesContentListRef = useRef<any[]>([]);
|
|
299
308
|
|
|
300
309
|
const msgRequestBuilder = useRef<CometChat.MessagesRequestBuilder>();
|
|
301
310
|
const lastMessageDate = useRef(new Date().getTime());
|
|
302
311
|
|
|
303
312
|
// states
|
|
304
|
-
const [messagesList, setMessagesList] = useState([]);
|
|
313
|
+
const [messagesList, setMessagesList] = useState<any[]>([]);
|
|
305
314
|
const [listState, setListState] = useState("loading");
|
|
306
315
|
const [loadingMessages, setLoadingMessages] = useState(false);
|
|
307
316
|
const [unreadCount, setUnreadCount] = useState(0);
|
|
308
|
-
const [showMessageOptions, setShowMessageOptions] = useState([]);
|
|
309
|
-
const [ExtensionsComponent, setExtensionsComponent] = useState(null);
|
|
310
|
-
const [CustomListHeader, setCustomListHeader] = useState(null);
|
|
317
|
+
const [showMessageOptions, setShowMessageOptions] = useState<any[]>([]);
|
|
318
|
+
const [ExtensionsComponent, setExtensionsComponent] = useState<JSX.Element | null>(null);
|
|
319
|
+
const [CustomListHeader, setCustomListHeader] = useState<any>(null);
|
|
311
320
|
const [messageInfo, setMessageInfo] = useState(false);
|
|
312
321
|
const [ongoingCallView, setOngoingCallView] = useState(null);
|
|
313
|
-
const [selectedMessage, setSelectedMessage] = useState(null);
|
|
322
|
+
const [selectedMessage, setSelectedMessage] = useState<any>(null);
|
|
314
323
|
const [showEmojiKeyboard, setShowEmojiKeyboard] = useState(false);
|
|
315
324
|
const [showReactionList, setShowReactionList] = useState(false);
|
|
316
|
-
const [selectedEmoji, setSelectedEmoji] = useState(
|
|
325
|
+
const [selectedEmoji, setSelectedEmoji] = useState<string | undefined>(undefined);
|
|
317
326
|
// const [forwarding, setForwarding] = useState(false);
|
|
318
327
|
|
|
319
|
-
const infoObject = useRef<CometChat.BaseMessage>();
|
|
320
|
-
const inProgressMessages = useRef([]);
|
|
328
|
+
const infoObject = useRef<CometChat.BaseMessage | null>();
|
|
329
|
+
const inProgressMessages = useRef<any[]>([]);
|
|
321
330
|
// const messageToForward = useRef<CometChat.BaseMessage>();
|
|
322
|
-
const bottomSheetRef = useRef(null)
|
|
331
|
+
const bottomSheetRef = useRef<any>(null)
|
|
323
332
|
const conversationId = useRef(null)
|
|
324
333
|
let lastID = useRef(0);
|
|
325
334
|
|
|
326
|
-
const scrollHandler = (event) => {
|
|
335
|
+
const scrollHandler = (event: any) => {
|
|
336
|
+
/********************************************************************************
|
|
337
|
+
* layoutMeasurement.height: The height of the visible area within the ScrollView.
|
|
338
|
+
* contentOffset.y: The current vertical scroll position (distance from the top of the content).
|
|
339
|
+
The y value in contentOffset indicates how far the top edge of the visible area is from the top of the scrollable content.
|
|
340
|
+
The x value (if applicable) indicates how far the left edge of the visible area is from the left of the scrollable content.
|
|
341
|
+
For example:
|
|
342
|
+
If contentOffset.y is 0, the top of the visible area is aligned with the top of the content.
|
|
343
|
+
If contentOffset.y is 50, the top of the visible area is 50 units (pixels) below the top of the content.
|
|
344
|
+
* contentSize.height: The total height of the scrollable content.
|
|
345
|
+
*********************************************************************************/
|
|
327
346
|
const { layoutMeasurement, contentOffset, contentSize } = event.nativeEvent;
|
|
328
347
|
const screenHeight = Dimensions.get('window').height;
|
|
329
348
|
|
|
@@ -332,6 +351,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
332
351
|
const scrollEndPosition = contentSize.height - screenHeight;
|
|
333
352
|
|
|
334
353
|
currentScrollPosition.current.y = contentOffset.y;
|
|
354
|
+
currentScrollPosition.current.contentHeight = contentSize.height;
|
|
335
355
|
|
|
336
356
|
if (currentScrollPosition.current.layoutHeight != layoutMeasurement.height) {
|
|
337
357
|
currentScrollPosition.current.layoutHeight = layoutMeasurement.height;
|
|
@@ -368,15 +388,15 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
368
388
|
else
|
|
369
389
|
setLoadingMessages(true);
|
|
370
390
|
// TODO: this condition is applied because somewhere from whiteboard extention group scope is set to undefined.
|
|
371
|
-
if (group != undefined && group
|
|
372
|
-
let fetchedGroup = await CometChat.getGroup(group
|
|
391
|
+
if (group != undefined && group.getGuid() == undefined) {
|
|
392
|
+
let fetchedGroup: any = await CometChat.getGroup(group.getGuid()).catch((e: any) => {
|
|
373
393
|
console.log("Error: fetching group", e);
|
|
374
394
|
onError && onError(e)
|
|
375
395
|
})
|
|
376
|
-
group
|
|
396
|
+
group.setScope(fetchedGroup['scope']);
|
|
377
397
|
}
|
|
378
|
-
messageRequest.current
|
|
379
|
-
.then(msgs => {
|
|
398
|
+
messageRequest.current?.fetchPrevious()
|
|
399
|
+
.then((msgs: any[]) => {
|
|
380
400
|
let reversed = msgs.reverse();
|
|
381
401
|
if (messagesList.length === 0 && msgs?.length > 0) {
|
|
382
402
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccActiveChatChanged, { message: reversed[0], user: user, group: group, theme: theme, parentMessageId: parentMessageId });
|
|
@@ -391,14 +411,14 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
391
411
|
|
|
392
412
|
for (let index = 0; index < reversed.length; index++) {
|
|
393
413
|
const message: CometChat.BaseMessage = reversed[index];
|
|
394
|
-
if (message && !disableReceipt && !message.hasOwnProperty("readAt") && loggedInUser.current
|
|
414
|
+
if (message && !disableReceipt && !message.hasOwnProperty("readAt") && loggedInUser.current?.getUid() != message?.getSender()?.getUid()) {
|
|
395
415
|
CometChat.markAsRead(message);
|
|
396
416
|
if (index == 0)
|
|
397
417
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageRead, { message });
|
|
398
418
|
} else
|
|
399
419
|
break;
|
|
400
420
|
}
|
|
401
|
-
reversed = reversed.map((item: CometChat.BaseMessage, index) => {
|
|
421
|
+
reversed = reversed.map((item: CometChat.BaseMessage, index: any) => {
|
|
402
422
|
if (item.getCategory() === MessageCategoryConstants.interactive) {
|
|
403
423
|
return InteractiveMessageUtils.convertInteractiveMessage(item);
|
|
404
424
|
} else {
|
|
@@ -416,7 +436,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
416
436
|
setLoadingMessages(false);
|
|
417
437
|
|
|
418
438
|
})
|
|
419
|
-
.catch(e => {
|
|
439
|
+
.catch((e: any) => {
|
|
420
440
|
if (messagesList.length == 0)
|
|
421
441
|
setListState("error");
|
|
422
442
|
else
|
|
@@ -428,9 +448,9 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
428
448
|
const getUpdatedPreviousMessages = () => {
|
|
429
449
|
let messagesRequest = new CometChat.MessagesRequestBuilder().setLimit(50)
|
|
430
450
|
if (user)
|
|
431
|
-
messagesRequest = messagesRequest.setUID(user
|
|
451
|
+
messagesRequest = messagesRequest.setUID(user.getUid())
|
|
432
452
|
if (group)
|
|
433
|
-
messagesRequest = messagesRequest.setGUID(group
|
|
453
|
+
messagesRequest = messagesRequest.setGUID(group.getGuid())
|
|
434
454
|
|
|
435
455
|
messagesRequest.setTypes([MessageCategoryConstants.message]);
|
|
436
456
|
messagesRequest.setCategories([MessageCategoryConstants.action]);
|
|
@@ -438,10 +458,10 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
438
458
|
|
|
439
459
|
messagesRequest.build()
|
|
440
460
|
.fetchNext()
|
|
441
|
-
.then(updatedMessages => {
|
|
461
|
+
.then((updatedMessages: string | any[]) => {
|
|
442
462
|
let tmpList = [...messagesContentListRef.current];
|
|
443
463
|
for (let i = 0; i < updatedMessages.length; i++) {
|
|
444
|
-
let condition = (msg) => msg.getId() == updatedMessages[i]?.actionOn.getId()
|
|
464
|
+
let condition = (msg: any) => msg.getId() == updatedMessages[i]?.actionOn.getId()
|
|
445
465
|
let msgIndex = messagesContentListRef.current.findIndex(condition);
|
|
446
466
|
if (msgIndex > -1) {
|
|
447
467
|
tmpList[msgIndex] = updatedMessages[i]?.actionOn;
|
|
@@ -451,21 +471,19 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
451
471
|
// setMessagesList(tmpList);
|
|
452
472
|
getNewMessages(tmpList);
|
|
453
473
|
})
|
|
454
|
-
.catch(e => console.log("error while fetching updated msgs", e))
|
|
474
|
+
.catch((e: any) => console.log("error while fetching updated msgs", e))
|
|
455
475
|
}
|
|
456
476
|
|
|
457
|
-
const getNewMessages = (updatedList) => {
|
|
477
|
+
const getNewMessages = (updatedList: any[]) => {
|
|
458
478
|
|
|
459
479
|
let newRequestBuilder = msgRequestBuilder.current;
|
|
460
|
-
newRequestBuilder
|
|
480
|
+
newRequestBuilder?.setMessageId(lastID.current)
|
|
461
481
|
|
|
462
|
-
newRequestBuilder
|
|
482
|
+
newRequestBuilder?.build()
|
|
463
483
|
.fetchNext()
|
|
464
|
-
.then(newMessages => {
|
|
484
|
+
.then((newMessages: any[]) => {
|
|
465
485
|
let cleanUpdatedList = [...updatedList];
|
|
466
|
-
|
|
467
|
-
let finalOutput = CommonUtils.mergeArrays(cleanUpdatedList, newMessages, "muid");
|
|
468
|
-
|
|
486
|
+
let finalOutput = CommonUtils.mergeArrays(cleanUpdatedList, newMessages, "id");
|
|
469
487
|
let tmpList = [...finalOutput];
|
|
470
488
|
tmpList = tmpList.map((item: CometChat.BaseMessage, index) => {
|
|
471
489
|
if (item.getCategory() === MessageCategoryConstants.interactive) {
|
|
@@ -483,13 +501,18 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
483
501
|
}
|
|
484
502
|
messagesContentListRef.current = tmpList;
|
|
485
503
|
setMessagesList(tmpList);
|
|
486
|
-
|
|
504
|
+
for(let i = newMessages.length - 1; i >= 0; i--) {
|
|
505
|
+
if(newMessages[i].getSender().getUid() !== loggedInUser.current.getUid()) {
|
|
506
|
+
bottomHandler(newMessages[i], true);
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
487
510
|
if (newMessages.length === 30) {
|
|
488
511
|
getNewMessages(tmpList);
|
|
489
512
|
}
|
|
490
|
-
newRequestBuilder
|
|
513
|
+
newRequestBuilder?.setMessageId(undefined)
|
|
491
514
|
})
|
|
492
|
-
.catch(e => console.log("error while fetching updated msgs", e))
|
|
515
|
+
.catch((e: any) => console.log("error while fetching updated msgs", e))
|
|
493
516
|
}
|
|
494
517
|
|
|
495
518
|
const loadTemplates = useCallback(() => {
|
|
@@ -514,7 +537,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
514
537
|
let _plainString = underlyingText;
|
|
515
538
|
|
|
516
539
|
let regexes: Array<RegExp> = []
|
|
517
|
-
let users:
|
|
540
|
+
let users: any = {};
|
|
518
541
|
|
|
519
542
|
|
|
520
543
|
let edits: Array<{
|
|
@@ -528,11 +551,11 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
528
551
|
let mentionsTextFormatter = ChatConfigurator.getDataSource().getMentionsFormatter(loggedInUser.current);
|
|
529
552
|
allFormatters.push(mentionsTextFormatter);
|
|
530
553
|
|
|
531
|
-
allFormatters.forEach((formatter
|
|
554
|
+
allFormatters.forEach((formatter, key) => {
|
|
532
555
|
regexes.push(formatter.getRegexPattern());
|
|
533
556
|
let suggestionUsers = formatter.getSuggestionItems();
|
|
534
557
|
if (formatter instanceof CometChatMentionsFormatter) {
|
|
535
|
-
let mentionUsers = (messageObject?.getMentionedUsers && messageObject?.getMentionedUsers()).map(item => new SuggestionItem({
|
|
558
|
+
let mentionUsers = (messageObject?.getMentionedUsers && messageObject?.getMentionedUsers()).map((item: { getUid: () => any; getName: () => string; }) => new SuggestionItem({
|
|
536
559
|
id: item.getUid(),
|
|
537
560
|
name: item.getName(),
|
|
538
561
|
promptText: "@" + item.getName(),
|
|
@@ -543,7 +566,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
543
566
|
})) || [];
|
|
544
567
|
suggestionUsers = [...suggestionUsers, ...mentionUsers];
|
|
545
568
|
}
|
|
546
|
-
suggestionUsers?.length > 0 && suggestionUsers.forEach(item => users[item.underlyingText] = item);
|
|
569
|
+
suggestionUsers?.length > 0 && suggestionUsers.forEach((item: any) => users[item.underlyingText] = item);
|
|
547
570
|
})
|
|
548
571
|
|
|
549
572
|
regexes.forEach(regex => {
|
|
@@ -581,20 +604,20 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
581
604
|
|
|
582
605
|
}
|
|
583
606
|
|
|
584
|
-
const playNotificationSound = useCallback((message) => {
|
|
607
|
+
const playNotificationSound = useCallback((message: any) => {
|
|
585
608
|
|
|
586
609
|
if (disableSoundForMessages) return;
|
|
587
610
|
|
|
588
611
|
if (message?.category === MessageCategoryConstants.message) {
|
|
589
612
|
if (customSoundForMessages) {
|
|
590
613
|
CometChatSoundManager.play(
|
|
591
|
-
loggedInUser.current
|
|
614
|
+
loggedInUser.current?.getUid() == message['sender']['uid'] ? "outgoingMessage" : "incomingMessage",
|
|
592
615
|
customSoundForMessages
|
|
593
616
|
);
|
|
594
617
|
} else {
|
|
595
618
|
CometChatSoundManager.play(
|
|
596
619
|
// "incomingMessage"
|
|
597
|
-
loggedInUser.current
|
|
620
|
+
loggedInUser.current?.getUid() == message['sender']['uid'] ? "outgoingMessage" : "incomingMessage"
|
|
598
621
|
);
|
|
599
622
|
}
|
|
600
623
|
}
|
|
@@ -605,21 +628,21 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
605
628
|
let firstUnreadPosition = previousScrollPosition.current.scrollViewHeight;
|
|
606
629
|
if (scrollToFirstUnread) {
|
|
607
630
|
setTimeout(() => {
|
|
608
|
-
messageListRef.current
|
|
631
|
+
messageListRef.current?.scrollTo({ x: 0, y: firstUnreadPosition, animated: false });
|
|
609
632
|
}, 0)
|
|
610
633
|
} else {
|
|
611
634
|
setTimeout(() => {
|
|
612
|
-
messageListRef.current
|
|
635
|
+
messageListRef.current?.scrollToEnd({ animated: true });
|
|
613
636
|
}, 0)
|
|
614
637
|
}
|
|
615
638
|
}
|
|
616
639
|
}, []);
|
|
617
640
|
|
|
618
|
-
const markMessageAsRead = (message) => {
|
|
641
|
+
const markMessageAsRead = (message: any) => {
|
|
619
642
|
if (!disableReceipt && !message?.readAt) {
|
|
620
643
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageRead, { message });
|
|
621
644
|
CometChat.markAsRead(message)
|
|
622
|
-
.catch((error) => {
|
|
645
|
+
.catch((error: any) => {
|
|
623
646
|
console.log("Error", error);
|
|
624
647
|
onError && onError(error);
|
|
625
648
|
// errorHandler(error);
|
|
@@ -627,14 +650,14 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
627
650
|
}
|
|
628
651
|
};
|
|
629
652
|
|
|
630
|
-
function checkMessageInSameConversation(message: CometChat.BaseMessage): boolean {
|
|
653
|
+
function checkMessageInSameConversation(message: CometChat.BaseMessage | any): boolean {
|
|
631
654
|
return (message?.getReceiverType() == ReceiverTypeConstants.user &&
|
|
632
655
|
user &&
|
|
633
656
|
user?.getUid() == message.getReceiver()?.['uid']) ||
|
|
634
657
|
(message?.getReceiverType() == ReceiverTypeConstants.group &&
|
|
635
658
|
message.getReceiverId() &&
|
|
636
659
|
group &&
|
|
637
|
-
group?.getGuid() == message.getReceiverId());
|
|
660
|
+
group?.getGuid() == message.getReceiverId() || false);
|
|
638
661
|
}
|
|
639
662
|
|
|
640
663
|
function messageToSameConversation(message: CometChat.BaseMessage): boolean {
|
|
@@ -644,14 +667,15 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
644
667
|
(message?.getReceiverType() == ReceiverTypeConstants.group &&
|
|
645
668
|
message.getReceiverId() &&
|
|
646
669
|
group &&
|
|
647
|
-
group?.getGuid() == message.getReceiverId());
|
|
670
|
+
group?.getGuid() == message.getReceiverId() || false);
|
|
648
671
|
}
|
|
649
672
|
function checkSameConversation(message: CometChat.BaseMessage): boolean {
|
|
650
|
-
return
|
|
673
|
+
return message.getConversationId() == conversationId.current ||
|
|
674
|
+
(message.getSender()?.['uid'] === user?.getUid() && message.getReceiverType() == CometChatUiKitConstants.ReceiverTypeConstants.user);
|
|
651
675
|
}
|
|
652
676
|
|
|
653
677
|
function isNearBottom() {
|
|
654
|
-
const { layoutHeight, scrollViewHeight, y } = currentScrollPosition.current;
|
|
678
|
+
const { layoutHeight, scrollViewHeight, y }: any = currentScrollPosition.current;
|
|
655
679
|
|
|
656
680
|
let scrollPos = scrollViewHeight - (layoutHeight + y);
|
|
657
681
|
let scrollPosFromBottomInPercentage = (scrollPos / layoutHeight) * 100;
|
|
@@ -663,18 +687,20 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
663
687
|
|
|
664
688
|
}
|
|
665
689
|
|
|
666
|
-
const newMessage = (newMessage, isReceived = true) => {
|
|
690
|
+
const newMessage = (newMessage: any, isReceived = true) => {
|
|
667
691
|
let baseMessage = newMessage as CometChat.BaseMessage;
|
|
668
692
|
if (baseMessage.getCategory() === MessageCategoryConstants.interactive) {
|
|
669
693
|
newMessage = InteractiveMessageUtils.convertInteractiveMessage(baseMessage);
|
|
670
694
|
}
|
|
671
695
|
if (checkSameConversation(baseMessage) || checkMessageInSameConversation(baseMessage) || messageToSameConversation(baseMessage)) {
|
|
696
|
+
if(!disableReceipt) {
|
|
697
|
+
CometChat.markAsDelivered(newMessage);
|
|
698
|
+
}
|
|
672
699
|
//need to add
|
|
673
700
|
if (newMessage.getParentMessageId()) {
|
|
674
|
-
if (newMessage.getParentMessageId() == parseInt(parentMessageId)) {
|
|
701
|
+
if (parentMessageId && newMessage.getParentMessageId() == parseInt(parentMessageId)) {
|
|
675
702
|
// add to list
|
|
676
703
|
messagesContentListRef.current = [...messagesContentListRef.current, newMessage];
|
|
677
|
-
inProgressMessages.current = [...inProgressMessages.current, newMessage]
|
|
678
704
|
setMessagesList(prev => [...prev, newMessage]);
|
|
679
705
|
} else {
|
|
680
706
|
//increase count
|
|
@@ -688,11 +714,10 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
688
714
|
tmpList[index] = oldMsg;
|
|
689
715
|
messagesContentListRef.current = tmpList;
|
|
690
716
|
setMessagesList(tmpList);
|
|
691
|
-
|
|
717
|
+
return;
|
|
692
718
|
}
|
|
693
719
|
} else if (parentMessageId == undefined) {
|
|
694
720
|
messagesContentListRef.current = [...messagesContentListRef.current, newMessage];
|
|
695
|
-
inProgressMessages.current = [...inProgressMessages.current, newMessage]
|
|
696
721
|
setMessagesList(prev => [...prev, newMessage]);
|
|
697
722
|
}
|
|
698
723
|
bottomHandler(newMessage, isReceived);
|
|
@@ -701,32 +726,45 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
701
726
|
playNotificationSound(newMessage);
|
|
702
727
|
}
|
|
703
728
|
|
|
704
|
-
const
|
|
729
|
+
const isAtBottom = () => {
|
|
730
|
+
if(
|
|
731
|
+
[null, undefined].includes(currentScrollPosition.current.y)
|
|
732
|
+
|| !currentScrollPosition.current.layoutHeight
|
|
733
|
+
|| !currentScrollPosition.current.contentHeight
|
|
734
|
+
) {
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
else if (currentScrollPosition.current.layoutHeight + currentScrollPosition.current.y! >= currentScrollPosition.current.contentHeight) {
|
|
738
|
+
return true;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
705
743
|
|
|
706
|
-
|
|
707
|
-
if (
|
|
708
|
-
if ((parentMessageId && newMessage.parentMessageId == parseInt(parentMessageId)) || (!parentMessageId && !newMessage.parentMessageId && (newMessage.getSender()?.getUid() || newMessage?.['sender']?.['uid']) == loggedInUser.current?.['uid'])) {
|
|
709
|
-
scrollToBottom();
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
CometChat.markAsDelivered(newMessage);
|
|
713
|
-
if (newMessage?.getReceiverType() == ReceiverTypeConstants.user) {
|
|
714
|
-
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageDelivered, { message: newMessage });
|
|
715
|
-
}
|
|
716
|
-
if (isNearBottom()) {
|
|
717
|
-
scrollToBottom();
|
|
718
|
-
if (isReceived) {
|
|
719
|
-
markMessageAsRead(newMessage);
|
|
720
|
-
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageRead, { message: newMessage });
|
|
721
|
-
}
|
|
722
|
-
} else if ((!parentMessageId && !(newMessage.parentMessageId)) || (parentMessageId && newMessage.parentMessageId == parseInt(parentMessageId))) {
|
|
723
|
-
setUnreadCount(unreadCount + 1);
|
|
724
|
-
}
|
|
725
|
-
} else {
|
|
744
|
+
const bottomHandler = (newMessage: CometChat.BaseMessage | any, isReceived?: boolean) => {
|
|
745
|
+
if ((newMessage.getSender()?.getUid() || newMessage?.['sender']?.['uid']) == loggedInUser.current?.['uid']) {
|
|
726
746
|
scrollToBottom();
|
|
727
|
-
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
if(!isReceived) {
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
if (
|
|
753
|
+
(!parentMessageId && newMessage.getParentMessageId())
|
|
754
|
+
|| (parentMessageId && !newMessage.getParentMessageId())
|
|
755
|
+
|| (parentMessageId && newMessage.getParentMessageId() && parentMessageId != newMessage.getParentMessageId())
|
|
756
|
+
) {
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
if (isAtBottom() || isNearBottom()) {
|
|
760
|
+
scrollToBottom();
|
|
761
|
+
markMessageAsRead(newMessage)
|
|
762
|
+
} else {
|
|
763
|
+
if(scrollToBottomOnNewMessages) {
|
|
764
|
+
scrollToBottom();
|
|
728
765
|
markMessageAsRead(newMessage);
|
|
729
|
-
|
|
766
|
+
} else {
|
|
767
|
+
setUnreadCount(unreadCount + 1);
|
|
730
768
|
}
|
|
731
769
|
}
|
|
732
770
|
}
|
|
@@ -750,7 +788,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
750
788
|
let condition: (value: any, index: number, obj: any[]) => unknown;
|
|
751
789
|
if (withMuid) {
|
|
752
790
|
condition = (msg) => msg['muid'] == editedMessage['muid']
|
|
753
|
-
inProgressMessages.current = inProgressMessages.current.filter(item => item.muid !== editedMessage['muid'])
|
|
791
|
+
inProgressMessages.current = inProgressMessages.current.filter((item: anyObject) => item.muid !== editedMessage['muid'])
|
|
754
792
|
}
|
|
755
793
|
else
|
|
756
794
|
condition = (msg) => msg.getId() == editedMessage.getId()
|
|
@@ -778,11 +816,11 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
778
816
|
|
|
779
817
|
const deleteMessage = (message: CometChat.BaseMessage) => {
|
|
780
818
|
CometChat.deleteMessage(message.getId().toString())
|
|
781
|
-
.then(res => {
|
|
819
|
+
.then((res: any) => {
|
|
782
820
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageDeleted, { message: res });
|
|
783
821
|
setShowMessageOptions([]);
|
|
784
822
|
})
|
|
785
|
-
.catch(rej => {
|
|
823
|
+
.catch((rej: any) => {
|
|
786
824
|
console.log(rej);
|
|
787
825
|
onError && onError(rej);
|
|
788
826
|
})
|
|
@@ -790,21 +828,23 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
790
828
|
|
|
791
829
|
const createActionMessage = () => { }
|
|
792
830
|
|
|
793
|
-
const updateMessageReceipt = (receipt) => {
|
|
831
|
+
const updateMessageReceipt = (receipt: any) => {
|
|
832
|
+
if(receipt?.getReceiverType() === ReceiverTypeConstants.group && ![receipt.RECEIPT_TYPE.DELIVERED_TO_ALL_RECEIPT, receipt.RECEIPT_TYPE.READ_BY_ALL_RECEIPT].includes(receipt?.getReceiptType())) {
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
794
835
|
let index = messagesContentListRef.current.findIndex((msg, index) => msg['id'] == receipt['messageId'] || msg['messageId'] == receipt['messageId']);
|
|
836
|
+
|
|
795
837
|
if (index == -1) return;
|
|
796
838
|
|
|
797
839
|
let tmpList: Array<CometChat.BaseMessage> = [...messagesContentListRef.current];
|
|
798
840
|
|
|
799
|
-
for (let i = index; i
|
|
841
|
+
for (let i = index; i >= 0; i--) {
|
|
800
842
|
|
|
801
843
|
if (tmpList[i]?.getReadAt && tmpList[i]?.getReadAt()) break;
|
|
802
844
|
|
|
803
845
|
let tmpMsg = tmpList[i];
|
|
804
846
|
if (!Number.isNaN(Number(tmpMsg.getId()))) {
|
|
805
847
|
|
|
806
|
-
if ((tmpMsg as CometChat.BaseMessage)?.getReceiverType() == ReceiverTypeConstants.group)
|
|
807
|
-
return;
|
|
808
848
|
if (tmpMsg.getCategory() === MessageCategoryConstants.interactive) {
|
|
809
849
|
tmpMsg = InteractiveMessageUtils.convertInteractiveMessage(tmpMsg);
|
|
810
850
|
}
|
|
@@ -823,8 +863,8 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
823
863
|
setMessagesList(tmpList);
|
|
824
864
|
}
|
|
825
865
|
|
|
826
|
-
const handlePannel = (item) => {
|
|
827
|
-
if (item.alignment === ViewAlignment.messageListBottom && CommonUtils.checkIdBelongsToThisComponent(item.id, user, group, parentMessageId)) {
|
|
866
|
+
const handlePannel = (item: any) => {
|
|
867
|
+
if (item.alignment === ViewAlignment.messageListBottom && user && group && CommonUtils.checkIdBelongsToThisComponent(item.id, user, group, parentMessageId || '')) {
|
|
828
868
|
if (item.child)
|
|
829
869
|
setCustomListHeader(() => item.child)
|
|
830
870
|
else
|
|
@@ -859,13 +899,13 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
859
899
|
},
|
|
860
900
|
});
|
|
861
901
|
CometChat.getLoggedinUser()
|
|
862
|
-
.then(u => {
|
|
902
|
+
.then((u: any) => {
|
|
863
903
|
loggedInUser.current = u;
|
|
864
|
-
messageRequest.current = msgRequestBuilder.current
|
|
904
|
+
messageRequest.current = msgRequestBuilder.current?.build() || null;
|
|
865
905
|
getPreviousMessages();
|
|
866
906
|
loadTemplates();
|
|
867
907
|
})
|
|
868
|
-
.catch(e => {
|
|
908
|
+
.catch((e: any) => {
|
|
869
909
|
console.log("Error while getting loggedInUser");
|
|
870
910
|
onError && onError(e);
|
|
871
911
|
loggedInUser.current = null;
|
|
@@ -896,24 +936,25 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
896
936
|
CometChat.addGroupListener(
|
|
897
937
|
groupListenerId,
|
|
898
938
|
new CometChat.GroupListener({
|
|
899
|
-
onGroupMemberScopeChanged: (message) => {
|
|
939
|
+
onGroupMemberScopeChanged: (message: any) => {
|
|
900
940
|
newMessage(message);
|
|
901
941
|
},
|
|
902
|
-
onGroupMemberLeft: (message) => {
|
|
942
|
+
onGroupMemberLeft: (message: any) => {
|
|
903
943
|
newMessage(message);
|
|
904
944
|
},
|
|
905
|
-
onGroupMemberKicked: (message) => {
|
|
945
|
+
onGroupMemberKicked: (message: any) => {
|
|
906
946
|
newMessage(message);
|
|
907
947
|
},
|
|
908
|
-
onGroupMemberBanned: (message) => {
|
|
948
|
+
onGroupMemberBanned: (message: any) => {
|
|
909
949
|
newMessage(message);
|
|
910
950
|
},
|
|
911
|
-
onGroupMemberUnbanned: (message) => {
|
|
951
|
+
onGroupMemberUnbanned: (message: any) => {
|
|
952
|
+
newMessage(message);
|
|
912
953
|
},
|
|
913
|
-
onMemberAddedToGroup: (message) => {
|
|
954
|
+
onMemberAddedToGroup: (message: any) => {
|
|
914
955
|
newMessage(message);
|
|
915
956
|
},
|
|
916
|
-
onGroupMemberJoined: (message) => {
|
|
957
|
+
onGroupMemberJoined: (message: any) => {
|
|
917
958
|
newMessage(message);
|
|
918
959
|
},
|
|
919
960
|
})
|
|
@@ -922,8 +963,9 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
922
963
|
CometChatUIEventHandler.addMessageListener(
|
|
923
964
|
messageEventListener,
|
|
924
965
|
{
|
|
925
|
-
ccMessageSent: ({ message, status }) => {
|
|
966
|
+
ccMessageSent: ({ message, status }: any) => {
|
|
926
967
|
if (status == MessageStatusConstants.inprogress) {
|
|
968
|
+
inProgressMessages.current = [...inProgressMessages.current, message]
|
|
927
969
|
newMessage(message, false);
|
|
928
970
|
}
|
|
929
971
|
|
|
@@ -934,49 +976,49 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
934
976
|
messageEdited(message, true);
|
|
935
977
|
}
|
|
936
978
|
},
|
|
937
|
-
ccMessageEdited: ({ message, status }) => {
|
|
979
|
+
ccMessageEdited: ({ message, status }: any) => {
|
|
938
980
|
if (status == messageStatus.success)
|
|
939
981
|
messageEdited(message, false);
|
|
940
982
|
},
|
|
941
|
-
ccMessageDeleted: ({ message }) => {
|
|
983
|
+
ccMessageDeleted: ({ message }: any) => {
|
|
942
984
|
messageEdited(message, false);
|
|
943
985
|
},
|
|
944
|
-
ccMessageRead: ({ message }) => {
|
|
986
|
+
ccMessageRead: ({ message }: any) => {
|
|
945
987
|
if (!parentMessageId && message.parentMessageId) {
|
|
946
988
|
// markParentMessageAsRead(message); //NOTE: uncomment this when want unread count in thread view
|
|
947
989
|
}
|
|
948
990
|
},
|
|
949
|
-
onTextMessageReceived: (textMessage) => {
|
|
991
|
+
onTextMessageReceived: (textMessage: any) => {
|
|
950
992
|
newMessage(textMessage);
|
|
951
993
|
},
|
|
952
|
-
onMediaMessageReceived: (mediaMessage) => {
|
|
994
|
+
onMediaMessageReceived: (mediaMessage: any) => {
|
|
953
995
|
newMessage(mediaMessage);
|
|
954
996
|
},
|
|
955
|
-
onCustomMessageReceived: (customMessage) => {
|
|
997
|
+
onCustomMessageReceived: (customMessage: any) => {
|
|
956
998
|
newMessage(customMessage);
|
|
957
999
|
},
|
|
958
|
-
onMessagesDelivered: (messageReceipt) => {
|
|
1000
|
+
onMessagesDelivered: (messageReceipt: any) => {
|
|
959
1001
|
updateMessageReceipt(messageReceipt);
|
|
960
1002
|
},
|
|
961
|
-
onMessagesRead: (messageReceipt) => {
|
|
1003
|
+
onMessagesRead: (messageReceipt: any) => {
|
|
962
1004
|
updateMessageReceipt(messageReceipt);
|
|
963
1005
|
},
|
|
964
|
-
onMessageDeleted: (deletedMessage) => {
|
|
1006
|
+
onMessageDeleted: (deletedMessage: any) => {
|
|
965
1007
|
messageEdited(deletedMessage);
|
|
966
1008
|
},
|
|
967
|
-
onMessageEdited: (editedMessage) => {
|
|
1009
|
+
onMessageEdited: (editedMessage: any) => {
|
|
968
1010
|
messageEdited(editedMessage);
|
|
969
1011
|
},
|
|
970
|
-
onFormMessageReceived: (formMessage) => {
|
|
1012
|
+
onFormMessageReceived: (formMessage: any) => {
|
|
971
1013
|
newMessage(formMessage);
|
|
972
1014
|
},
|
|
973
|
-
onCardMessageReceived: (cardMessage) => {
|
|
1015
|
+
onCardMessageReceived: (cardMessage: any) => {
|
|
974
1016
|
newMessage(cardMessage);
|
|
975
1017
|
},
|
|
976
|
-
onSchedulerMessageReceived: (schedulerMessage) => {
|
|
1018
|
+
onSchedulerMessageReceived: (schedulerMessage: any) => {
|
|
977
1019
|
newMessage(schedulerMessage);
|
|
978
1020
|
},
|
|
979
|
-
onCustomInteractiveMessageReceived: (customInteractiveMessage) => {
|
|
1021
|
+
onCustomInteractiveMessageReceived: (customInteractiveMessage: any) => {
|
|
980
1022
|
newMessage(customInteractiveMessage);
|
|
981
1023
|
},
|
|
982
1024
|
onInteractionGoalCompleted: (interactionReceipt: CometChat.InteractionReceipt) => {
|
|
@@ -989,39 +1031,46 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
989
1031
|
console.log("msgIndex", msgIndex)
|
|
990
1032
|
if (msgIndex === -1) return;
|
|
991
1033
|
const interaction = interactionReceipt.getInteractions() || [];
|
|
992
|
-
let editedMessage = messagesList[msgIndex];
|
|
1034
|
+
let editedMessage: any = messagesList[msgIndex];
|
|
993
1035
|
editedMessage = InteractiveMessageUtils.convertInteractiveMessage(editedMessage);
|
|
994
1036
|
editedMessage.setInteractions(interaction);
|
|
995
1037
|
messageEdited(editedMessage);
|
|
996
1038
|
}
|
|
997
1039
|
},
|
|
998
|
-
...reactionListeners
|
|
1040
|
+
...reactionListeners,
|
|
1041
|
+
onMessagesDeliveredToAll: (messageReceipt: CometChat.MessageReceipt) => {
|
|
1042
|
+
updateMessageReceipt(messageReceipt);
|
|
1043
|
+
},
|
|
1044
|
+
onMessagesReadByAll: (messageReceipt: CometChat.MessageReceipt) => {
|
|
1045
|
+
updateMessageReceipt(messageReceipt);
|
|
1046
|
+
},
|
|
999
1047
|
}
|
|
1000
1048
|
)
|
|
1001
1049
|
CometChatUIEventHandler.addGroupListener(
|
|
1002
1050
|
groupEventListener,
|
|
1003
1051
|
{
|
|
1004
|
-
ccGroupMemberUnBanned: ({ message }) => {
|
|
1052
|
+
ccGroupMemberUnBanned: ({ message }: any) => {
|
|
1005
1053
|
newMessage(message, false)
|
|
1006
1054
|
},
|
|
1007
|
-
ccGroupMemberBanned: ({ message }) => {
|
|
1055
|
+
ccGroupMemberBanned: ({ message }: any) => {
|
|
1008
1056
|
newMessage(message, false)
|
|
1009
1057
|
},
|
|
1010
|
-
ccGroupMemberAdded: ({ message, usersAdded, userAddedIn }) => {
|
|
1011
|
-
usersAdded.forEach(user => {
|
|
1012
|
-
message['message'] = `${loggedInUser.current
|
|
1058
|
+
ccGroupMemberAdded: ({ message, usersAdded, userAddedIn }: any) => {
|
|
1059
|
+
usersAdded.forEach((user: any) => {
|
|
1060
|
+
message['message'] = `${loggedInUser.current?.getName()} added ${user.name}`;
|
|
1013
1061
|
message['muid'] = String(getUnixTimestamp());
|
|
1014
1062
|
message['sentAt'] = getUnixTimestamp();
|
|
1063
|
+
message['actionOn'] = user;
|
|
1015
1064
|
newMessage(message, false);
|
|
1016
1065
|
})
|
|
1017
1066
|
},
|
|
1018
|
-
ccGroupMemberKicked: ({ message }) => {
|
|
1067
|
+
ccGroupMemberKicked: ({ message }: any) => {
|
|
1019
1068
|
newMessage(message, false)
|
|
1020
1069
|
},
|
|
1021
|
-
ccGroupMemberScopeChanged: ({ action, updatedUser, scopeChangedTo, scopeChangedFrom, group }) => {
|
|
1070
|
+
ccGroupMemberScopeChanged: ({ action, updatedUser, scopeChangedTo, scopeChangedFrom, group }: any) => {
|
|
1022
1071
|
newMessage(action, false);
|
|
1023
1072
|
},
|
|
1024
|
-
ccOwnershipChanged: ({ group, message }) => {
|
|
1073
|
+
ccOwnershipChanged: ({ group, message }: any) => {
|
|
1025
1074
|
// newMessage(message, false); removed after discussion.
|
|
1026
1075
|
}
|
|
1027
1076
|
}
|
|
@@ -1030,16 +1079,16 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1030
1079
|
CometChat.addCallListener(
|
|
1031
1080
|
callListenerId,
|
|
1032
1081
|
new CometChat.CallListener({
|
|
1033
|
-
onIncomingCallReceived: (call) => {
|
|
1082
|
+
onIncomingCallReceived: (call: any) => {
|
|
1034
1083
|
newMessage(call);
|
|
1035
1084
|
},
|
|
1036
|
-
onOutgoingCallAccepted: (call) => {
|
|
1085
|
+
onOutgoingCallAccepted: (call: any) => {
|
|
1037
1086
|
newMessage(call);
|
|
1038
1087
|
},
|
|
1039
|
-
onOutgoingCallRejected: (call) => {
|
|
1088
|
+
onOutgoingCallRejected: (call: any) => {
|
|
1040
1089
|
newMessage(call);
|
|
1041
1090
|
},
|
|
1042
|
-
onIncomingCallCancelled: (call) => {
|
|
1091
|
+
onIncomingCallCancelled: (call: any) => {
|
|
1043
1092
|
newMessage(call);
|
|
1044
1093
|
}
|
|
1045
1094
|
})
|
|
@@ -1048,27 +1097,27 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1048
1097
|
CometChatUIEventHandler.addCallListener(
|
|
1049
1098
|
callEventListener,
|
|
1050
1099
|
{
|
|
1051
|
-
ccCallInitiated: ({ call }) => {
|
|
1100
|
+
ccCallInitiated: ({ call }: any) => {
|
|
1052
1101
|
if (call['type'] == CallTypeConstants.audio || call['type'] == CallTypeConstants.video) {
|
|
1053
1102
|
newMessage(call);
|
|
1054
1103
|
}
|
|
1055
1104
|
},
|
|
1056
|
-
ccOutgoingCall: ({ call }) => {
|
|
1105
|
+
ccOutgoingCall: ({ call }: any) => {
|
|
1057
1106
|
if (call['type'] == CallTypeConstants.audio || call['type'] == CallTypeConstants.video) {
|
|
1058
1107
|
newMessage(call);
|
|
1059
1108
|
}
|
|
1060
1109
|
},
|
|
1061
|
-
ccCallAccepted: ({ call }) => {
|
|
1110
|
+
ccCallAccepted: ({ call }: any) => {
|
|
1062
1111
|
if (call['type'] == CallTypeConstants.audio || call['type'] == CallTypeConstants.video) {
|
|
1063
1112
|
newMessage(call);
|
|
1064
1113
|
}
|
|
1065
1114
|
},
|
|
1066
|
-
ccCallRejected: ({ call }) => {
|
|
1115
|
+
ccCallRejected: ({ call }: any) => {
|
|
1067
1116
|
if (call['type'] == CallTypeConstants.audio || call['type'] == CallTypeConstants.video) {
|
|
1068
1117
|
newMessage(call);
|
|
1069
1118
|
}
|
|
1070
1119
|
},
|
|
1071
|
-
ccCallEnded: ({ call }) => {
|
|
1120
|
+
ccCallEnded: ({ call }: any) => {
|
|
1072
1121
|
if (call['type'] == CallTypeConstants.audio || call['type'] == CallTypeConstants.video) {
|
|
1073
1122
|
newMessage(call);
|
|
1074
1123
|
}
|
|
@@ -1083,7 +1132,9 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1083
1132
|
connectionListenerId,
|
|
1084
1133
|
new CometChat.ConnectionListener({
|
|
1085
1134
|
onConnected: () => {
|
|
1086
|
-
|
|
1135
|
+
if(lastID.current) {
|
|
1136
|
+
getUpdatedPreviousMessages();
|
|
1137
|
+
}
|
|
1087
1138
|
},
|
|
1088
1139
|
inConnecting: () => {
|
|
1089
1140
|
},
|
|
@@ -1125,7 +1176,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1125
1176
|
setShowReactionList(true);
|
|
1126
1177
|
}
|
|
1127
1178
|
}, [selectedEmoji])
|
|
1128
|
-
|
|
1179
|
+
//@ts-ignore
|
|
1129
1180
|
useImperativeHandle(ref, () => {
|
|
1130
1181
|
return {
|
|
1131
1182
|
addMessage: newMessage,
|
|
@@ -1141,12 +1192,12 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1141
1192
|
|
|
1142
1193
|
const onKeyboardVisibiltyChange = (isVisible: boolean, keyboardHeight?: number | undefined) => {
|
|
1143
1194
|
if (messageListRef.current) {
|
|
1144
|
-
if (isVisible) {
|
|
1195
|
+
if (isVisible && currentScrollPosition.current.y && keyboardHeight) {
|
|
1145
1196
|
Keyboard_Height = keyboardHeight;
|
|
1146
|
-
scrollPos = (currentScrollPosition.current.y + Keyboard_Height) - (commonVars.safeAreaInsets.top / 2);
|
|
1197
|
+
scrollPos = (currentScrollPosition.current.y + Keyboard_Height) - ((commonVars.safeAreaInsets.top as number) / 2);
|
|
1147
1198
|
messageListRef.current.scrollTo({ y: scrollPos, animated: false })
|
|
1148
1199
|
} else {
|
|
1149
|
-
messageListRef.current.scrollTo({ y: scrollPos - Keyboard_Height + (commonVars.safeAreaInsets.top / 2), animated: false })
|
|
1200
|
+
messageListRef.current.scrollTo({ y: scrollPos - Keyboard_Height + ((commonVars.safeAreaInsets.top as number) / 2), animated: false })
|
|
1150
1201
|
}
|
|
1151
1202
|
}
|
|
1152
1203
|
}
|
|
@@ -1212,8 +1263,8 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1212
1263
|
}
|
|
1213
1264
|
|
|
1214
1265
|
// functions returning view
|
|
1215
|
-
const getLeadingView = useCallback((item: CometChat.BaseMessage) => {
|
|
1216
|
-
if (showAvatar && (alignment === "leftAligned" || (item.getSender()?.getUid() || item?.['sender']?.['uid']) !== loggedInUser.current
|
|
1266
|
+
const getLeadingView = useCallback((item: CometChat.BaseMessage | any) => {
|
|
1267
|
+
if (showAvatar && (alignment === "leftAligned" || (item.getSender()?.getUid() || item?.['sender']?.['uid']) !== loggedInUser.current?.getUid() && item['category'] != MessageCategoryConstants.action)) {
|
|
1217
1268
|
return <CometChatAvatar
|
|
1218
1269
|
image={(item?.getSender()?.getAvatar && item?.getSender()?.getAvatar()) ? { uri: item.getSender().getAvatar() } : undefined}
|
|
1219
1270
|
name={(item?.getSender()?.getName && item?.getSender()?.getName()) ? item?.getSender()?.getName() : ""}
|
|
@@ -1223,10 +1274,10 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1223
1274
|
return null
|
|
1224
1275
|
}, [])
|
|
1225
1276
|
|
|
1226
|
-
const getHeaderView = useCallback((item: CometChat.BaseMessage) => {
|
|
1277
|
+
const getHeaderView = useCallback((item: CometChat.BaseMessage | any) => {
|
|
1227
1278
|
let senderName: string = "";
|
|
1228
|
-
if (alignment === "leftAligned" || ((item.getSender()?.getUid() || item?.['sender']?.['uid']) != loggedInUser.current
|
|
1229
|
-
senderName =
|
|
1279
|
+
if (alignment === "leftAligned" || ((item.getSender()?.getUid() || item?.['sender']?.['uid']) != loggedInUser.current?.getUid()))
|
|
1280
|
+
senderName = (item.getSender()?.getName() || "").trim();
|
|
1230
1281
|
|
|
1231
1282
|
if (item.getCategory() == MessageCategoryConstants.action || item.getCategory() == MessageCategoryConstants.call)
|
|
1232
1283
|
return null;
|
|
@@ -1236,7 +1287,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1236
1287
|
{Boolean(senderName) && <Text style={[Style.nameStyle, {
|
|
1237
1288
|
color: _messageListStyle.nameTextColor,
|
|
1238
1289
|
..._messageListStyle.nameTextFont,
|
|
1239
|
-
}]} numberOfLines={1} ellipsizeMode={"tail"}>{senderName}</Text>}
|
|
1290
|
+
}] as TextStyle} numberOfLines={1} ellipsizeMode={"tail"} >{senderName}</Text>}
|
|
1240
1291
|
{
|
|
1241
1292
|
timeStampAlignment == "bottom" || item['category'] == "action" ?
|
|
1242
1293
|
null :
|
|
@@ -1252,11 +1303,11 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1252
1303
|
)
|
|
1253
1304
|
}, [])
|
|
1254
1305
|
|
|
1255
|
-
const getStatusInfoView = useCallback((item: CometChat.TextMessage | CometChat.MediaMessage | CometChat.CustomMessage | CometChat.InteractiveMessage | CometChat.BaseMessage, bubbleAlignment: MessageBubbleAlignmentType, currentIndex?: number): JSX.Element => {
|
|
1306
|
+
const getStatusInfoView = useCallback((item: CometChat.TextMessage | CometChat.MediaMessage | CometChat.CustomMessage | CometChat.InteractiveMessage | CometChat.BaseMessage | any, bubbleAlignment: MessageBubbleAlignmentType, currentIndex?: number): JSX.Element | null => {
|
|
1256
1307
|
// return null if time alignment is top
|
|
1257
1308
|
if (timeStampAlignment == "top" || item['category'] == "action" || item['deletedAt']) return null
|
|
1258
1309
|
|
|
1259
|
-
let isSender = (item.getSender()?.getUid() || item?.['sender']?.['uid']) == loggedInUser.current
|
|
1310
|
+
let isSender = (item.getSender()?.getUid() || item?.['sender']?.['uid']) == loggedInUser.current?.getUid();
|
|
1260
1311
|
let messageState;
|
|
1261
1312
|
const nextItemIsRead = messagesContentListRef.current[currentIndex + 1] && messagesContentListRef.current[currentIndex + 1].getReadAt();
|
|
1262
1313
|
const nextItemIsDelivered = messagesContentListRef.current[currentIndex + 1] && messagesContentListRef.current[currentIndex + 1].getDeliveredAt();
|
|
@@ -1266,7 +1317,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1266
1317
|
messageState = "DELIVERED";
|
|
1267
1318
|
else if (item.getSentAt())
|
|
1268
1319
|
messageState = "SENT";
|
|
1269
|
-
else if (item?.
|
|
1320
|
+
else if (item?.getData()?.metaData?.error)
|
|
1270
1321
|
messageState = "ERROR"
|
|
1271
1322
|
else if (isSender)
|
|
1272
1323
|
messageState = "WAIT";
|
|
@@ -1290,7 +1341,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1290
1341
|
dateAlignment="center"
|
|
1291
1342
|
/>
|
|
1292
1343
|
{
|
|
1293
|
-
(!disableReceipt && alignment !== "leftAligned") && isSender ?
|
|
1344
|
+
(!(disableReceipt || hideReceipt) && alignment !== "leftAligned") && isSender ?
|
|
1294
1345
|
<View style={{ marginLeft: 2, alignItems: "center", justifyContent: "center" }}>
|
|
1295
1346
|
<CometChatReceipt
|
|
1296
1347
|
receipt={messageState}
|
|
@@ -1300,9 +1351,9 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1300
1351
|
waitIcon={waitIcon}
|
|
1301
1352
|
errorIcon={errorIcon}
|
|
1302
1353
|
style={{
|
|
1303
|
-
height: isAudioVideo && 8, width: isAudioVideo && 10,
|
|
1304
1354
|
tintColor: (messageState === "READ" && item?.getType() === "text") ? theme.palette.getBackgroundColor() :
|
|
1305
|
-
messageState === "WAIT" ? theme?.palette?.getAccent400() : undefined
|
|
1355
|
+
messageState === "WAIT" ? theme?.palette?.getAccent400() : undefined,
|
|
1356
|
+
...(isAudioVideo ? {height: 8, width: 10} : {})
|
|
1306
1357
|
}}
|
|
1307
1358
|
/>
|
|
1308
1359
|
</View>
|
|
@@ -1337,21 +1388,21 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1337
1388
|
setSelectedEmoji(emoji);
|
|
1338
1389
|
}
|
|
1339
1390
|
|
|
1340
|
-
const getAlignment = useCallback((item: CometChat.BaseMessage): MessageBubbleAlignmentType => {
|
|
1391
|
+
const getAlignment = useCallback((item: CometChat.BaseMessage | any): MessageBubbleAlignmentType => {
|
|
1341
1392
|
if (item && item.getCategory() == MessageCategoryConstants.action)
|
|
1342
1393
|
return "center";
|
|
1343
|
-
if (alignment == "standard" && (item.getSender()?.getUid() || item?.['sender']?.['uid']) == loggedInUser.current
|
|
1394
|
+
if (alignment == "standard" && (item.getSender()?.getUid() || item?.['sender']?.['uid']) == loggedInUser.current?.getUid())
|
|
1344
1395
|
return "right";
|
|
1345
1396
|
return "left";
|
|
1346
1397
|
}, [])
|
|
1347
1398
|
|
|
1348
|
-
const openMessageInfo = (message) => {
|
|
1399
|
+
const openMessageInfo = (message: any) => {
|
|
1349
1400
|
infoObject.current = message;
|
|
1350
1401
|
setMessageInfo(true);
|
|
1351
1402
|
setShowMessageOptions([]);
|
|
1352
1403
|
}
|
|
1353
1404
|
|
|
1354
|
-
const openThreadView = (...params) => {
|
|
1405
|
+
const openThreadView = (...params: any[]) => {
|
|
1355
1406
|
if (onThreadRepliesPress) {
|
|
1356
1407
|
onThreadRepliesPress(params[0], MessageView.bind(this, { message: params[0], isThreaded: true, showOptions: false }));
|
|
1357
1408
|
}
|
|
@@ -1359,12 +1410,12 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1359
1410
|
return onThreadRepliesPress
|
|
1360
1411
|
}
|
|
1361
1412
|
|
|
1362
|
-
const editMessage = (item) => {
|
|
1413
|
+
const editMessage = (item: any) => {
|
|
1363
1414
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, { message: item, status: messageStatus.inprogress });
|
|
1364
1415
|
setShowMessageOptions([]);
|
|
1365
1416
|
}
|
|
1366
1417
|
|
|
1367
|
-
const copyMessage = (item) => {
|
|
1418
|
+
const copyMessage = (item: any) => {
|
|
1368
1419
|
let copyMessage = getPlainString(item['text'], item);
|
|
1369
1420
|
Clipboard.setString(copyMessage);
|
|
1370
1421
|
setShowMessageOptions([]);
|
|
@@ -1391,7 +1442,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1391
1442
|
}}
|
|
1392
1443
|
>
|
|
1393
1444
|
{alignment === "left" && <Image style={{ resizeMode: "contain", tintColor: theme?.palette.getAccent600(), width: 30, height: 18 }} source={LeftArrowCurve} />}
|
|
1394
|
-
<Text style={style}>{`${item.getReplyCount()} ${item.getReplyCount() > 1 ? localize("REPLIES") : localize("REPLY")}`}</Text>
|
|
1445
|
+
<Text style={style as TextStyle}>{`${item.getReplyCount()} ${item.getReplyCount() > 1 ? localize("REPLIES") : localize("REPLY")}`}</Text>
|
|
1395
1446
|
|
|
1396
1447
|
{/** NOTE: uncomment below code when want unread count in thread view **/}
|
|
1397
1448
|
{/* {alignment === "left" && !!unreadReplyCount &&
|
|
@@ -1432,20 +1483,20 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1432
1483
|
const privateMessage = (item: CometChat.BaseMessage) => {
|
|
1433
1484
|
setShowMessageOptions([]);
|
|
1434
1485
|
CometChat.getUser(item.getSender().getUid())
|
|
1435
|
-
.then(user => {
|
|
1486
|
+
.then((user: any) => {
|
|
1436
1487
|
console.log({ user });
|
|
1437
1488
|
CometChatUIEventHandler.emitUIEvent('openChat', { user, group });
|
|
1438
1489
|
})
|
|
1439
|
-
.catch(e => {
|
|
1490
|
+
.catch((e: any) => {
|
|
1440
1491
|
onError && onError(e);
|
|
1441
1492
|
})
|
|
1442
1493
|
}
|
|
1443
1494
|
|
|
1444
|
-
const shareMedia = async (messageObject: CometChat.MediaMessage) => {
|
|
1445
|
-
let _plainString = getPlainString(messageObject?.
|
|
1495
|
+
const shareMedia = async (messageObject: CometChat.MediaMessage | any) => {
|
|
1496
|
+
let _plainString = getPlainString(messageObject?.getData()['text'] || "", messageObject);
|
|
1446
1497
|
|
|
1447
1498
|
let textMessage = _plainString;
|
|
1448
|
-
let fileUrl = messageObject.
|
|
1499
|
+
let fileUrl = messageObject.getData()['url'];
|
|
1449
1500
|
|
|
1450
1501
|
const getFileName = () => {
|
|
1451
1502
|
if (!fileUrl) return "";
|
|
@@ -1460,13 +1511,13 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1460
1511
|
"mimeType": messageObject["type"] === "text" ? "" : (messageObject as CometChat.MediaMessage)?.getAttachment()?.getMimeType(), // get Mime Type
|
|
1461
1512
|
}
|
|
1462
1513
|
|
|
1463
|
-
NativeModules.FileManager.shareMessage(shareObj, (callback) => {
|
|
1514
|
+
NativeModules.FileManager.shareMessage(shareObj, (callback: any) => {
|
|
1464
1515
|
console.log("shareMessage Callback", callback);
|
|
1465
1516
|
});
|
|
1466
1517
|
};
|
|
1467
1518
|
|
|
1468
|
-
const getStyle = useCallback((item: CometChat.BaseMessage):
|
|
1469
|
-
let _style = new
|
|
1519
|
+
const getStyle = useCallback((item: CometChat.BaseMessage | any): MessageBubbleStyleInterface => {
|
|
1520
|
+
let _style = new MessageBubbleStyle({
|
|
1470
1521
|
..._messageBubbleStyle,
|
|
1471
1522
|
backgroundColor: theme?.palette.getAccent50()
|
|
1472
1523
|
});
|
|
@@ -1475,6 +1526,8 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1475
1526
|
if (item.getType() === MessageTypeConstants.form || item.getType() === MessageTypeConstants.card) {
|
|
1476
1527
|
_style.width = "100%"
|
|
1477
1528
|
}
|
|
1529
|
+
} else {
|
|
1530
|
+
_style.alignSelf = getAlignment(item) === "left" ? "flex-start" : "flex-end";
|
|
1478
1531
|
}
|
|
1479
1532
|
|
|
1480
1533
|
if ((item.getSender()?.getUid() || item?.['sender']?.['uid']) == loggedInUser.current?.['uid'])
|
|
@@ -1569,8 +1622,8 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1569
1622
|
// });
|
|
1570
1623
|
// }
|
|
1571
1624
|
|
|
1572
|
-
const openOptionsForMessage = useCallback((item: CometChat.BaseMessage, template: CometChatMessageTemplate) => {
|
|
1573
|
-
let options = template?.options ? template.options(loggedInUser.current, item, group) : [];
|
|
1625
|
+
const openOptionsForMessage = useCallback((item: CometChat.BaseMessage | any, template: CometChatMessageTemplate) => {
|
|
1626
|
+
let options = template?.options ? loggedInUser.current ? template.options(loggedInUser.current, item, group) : [] : [];
|
|
1574
1627
|
let optionsWithPressHandling = options.map(option => {
|
|
1575
1628
|
if (!option.onPress)
|
|
1576
1629
|
switch (option.id) {
|
|
@@ -1629,18 +1682,18 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1629
1682
|
const onLongPress = () => {
|
|
1630
1683
|
if (message.getDeletedBy() != null) return;
|
|
1631
1684
|
setSelectedMessage(message)
|
|
1632
|
-
openOptionsForMessage(message, hasTemplate)
|
|
1685
|
+
hasTemplate && openOptionsForMessage(message, hasTemplate)
|
|
1633
1686
|
}
|
|
1634
1687
|
|
|
1635
1688
|
return <TouchableOpacity activeOpacity={1} onLongPress={() => showOptions ? onLongPress() : undefined} >
|
|
1636
1689
|
<CometChatMessageBubble
|
|
1637
1690
|
id={`${message.getId()}`}
|
|
1638
|
-
LeadingView={() => !isThreaded
|
|
1639
|
-
HeaderView={hasTemplate.HeaderView ? hasTemplate.HeaderView?.bind(this, message, bubbleAlignment) : () => !isThreaded
|
|
1691
|
+
LeadingView={() => !isThreaded ? getLeadingView(message) : null}
|
|
1692
|
+
HeaderView={hasTemplate.HeaderView ? hasTemplate.HeaderView?.bind(this, message, bubbleAlignment) : () => !isThreaded ? getHeaderView(message) : null}
|
|
1640
1693
|
FooterView={hasTemplate.FooterView ? hasTemplate.FooterView?.bind(this, message, bubbleAlignment) : () => (disableReactions || isThreaded) ? null : getFooterView(message, bubbleAlignment)}
|
|
1641
1694
|
alignment={isThreaded ? "left" : bubbleAlignment}
|
|
1642
1695
|
ContentView={hasTemplate.ContentView?.bind(this, message, bubbleAlignment)}
|
|
1643
|
-
ThreadView={() => !isThreaded
|
|
1696
|
+
ThreadView={() => !isThreaded ? !message.getDeletedBy() ? getThreadView(message, bubbleAlignment) : null : null}
|
|
1644
1697
|
BottomView={hasTemplate.BottomView && hasTemplate.BottomView?.bind(this, message, bubbleAlignment)}
|
|
1645
1698
|
StatusInfoView={hasTemplate.StatusInfoView ? hasTemplate.StatusInfoView?.bind(this, message, bubbleAlignment) : () => getStatusInfoView(message, bubbleAlignment, currentIndex)}
|
|
1646
1699
|
style={getStyle(message)}
|
|
@@ -1651,8 +1704,8 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1651
1704
|
}
|
|
1652
1705
|
}, []);
|
|
1653
1706
|
|
|
1654
|
-
const getSentAtTimestamp = useCallback((item) => {
|
|
1655
|
-
return Date.now();
|
|
1707
|
+
const getSentAtTimestamp = useCallback((item: any) => {
|
|
1708
|
+
return item.getSentAt() ? (item.getSentAt() * 1000) : Date.now();
|
|
1656
1709
|
}, [])
|
|
1657
1710
|
|
|
1658
1711
|
|
|
@@ -1668,8 +1721,8 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1668
1721
|
}
|
|
1669
1722
|
);
|
|
1670
1723
|
if (emojiObject && emojiObject?.getReactedByMe()) {
|
|
1671
|
-
const updatedReactions = [];
|
|
1672
|
-
reactions.forEach((reaction) => {
|
|
1724
|
+
const updatedReactions: any[] = [];
|
|
1725
|
+
reactions.forEach((reaction: any) => {
|
|
1673
1726
|
if (reaction?.getReaction() == emoji) {
|
|
1674
1727
|
if (reaction?.getCount() === 1) {
|
|
1675
1728
|
return;
|
|
@@ -1687,17 +1740,17 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1687
1740
|
newMessageObj.setReactions(updatedReactions);
|
|
1688
1741
|
|
|
1689
1742
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, { message: newMessageObj, status: messageStatus.success });
|
|
1690
|
-
CometChat.removeReaction(messageId, emoji).then((message) => {
|
|
1691
|
-
}).catch((error) => {
|
|
1743
|
+
CometChat.removeReaction(messageId, emoji).then((message: any) => {
|
|
1744
|
+
}).catch((error: any) => {
|
|
1692
1745
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, { message: msgObj, status: messageStatus.success });
|
|
1693
1746
|
console.log(error);
|
|
1694
1747
|
});
|
|
1695
1748
|
} else {
|
|
1696
|
-
const updatedReactions = [];
|
|
1697
|
-
const reactionAvailable = reactions.find((reaction) => {
|
|
1749
|
+
const updatedReactions: any[] = [];
|
|
1750
|
+
const reactionAvailable = reactions.find((reaction: any) => {
|
|
1698
1751
|
return reaction?.getReaction() == emoji;
|
|
1699
1752
|
});
|
|
1700
|
-
reactions.forEach((reaction) => {
|
|
1753
|
+
reactions.forEach((reaction: any) => {
|
|
1701
1754
|
if (reaction?.getReaction() == emoji) {
|
|
1702
1755
|
reaction.setCount(reaction?.getCount() + 1);
|
|
1703
1756
|
reaction.setReactedByMe(true);
|
|
@@ -1733,7 +1786,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1733
1786
|
item: any;
|
|
1734
1787
|
index: number;
|
|
1735
1788
|
}) {
|
|
1736
|
-
let seperatorView = null;
|
|
1789
|
+
let seperatorView: JSX.Element | null = null;
|
|
1737
1790
|
const previousMessageDate = messagesContentListRef.current[index - 1] ? new Date(getSentAtTimestamp(messagesContentListRef.current[index - 1])) : null;
|
|
1738
1791
|
const currentMessageDate = new Date(getSentAtTimestamp(item));
|
|
1739
1792
|
|
|
@@ -1762,26 +1815,34 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1762
1815
|
</React.Fragment>
|
|
1763
1816
|
}), []);
|
|
1764
1817
|
|
|
1765
|
-
const keyExtractor = useCallback((item) => `${item.id}_${item.muid}`, [])
|
|
1818
|
+
const keyExtractor = useCallback((item: any) => `${item.id}_${item.muid}`, [])
|
|
1766
1819
|
|
|
1767
1820
|
const itemSeperator = useCallback(() => <View style={{ height: 8 }} />, [])
|
|
1768
1821
|
|
|
1769
1822
|
const getEmptyTextView = useCallback(() => {
|
|
1770
1823
|
if (EmptyStateView)
|
|
1771
|
-
return
|
|
1824
|
+
return (
|
|
1825
|
+
<>
|
|
1826
|
+
<ScrollView contentContainerStyle={Style.msgContainerStyle}>
|
|
1827
|
+
<EmptyStateView />
|
|
1828
|
+
</ScrollView>
|
|
1829
|
+
</>
|
|
1830
|
+
)
|
|
1772
1831
|
return (
|
|
1773
1832
|
<>
|
|
1774
|
-
<
|
|
1775
|
-
<
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1833
|
+
<ScrollView contentContainerStyle={Style.msgContainerStyle}>
|
|
1834
|
+
<View>
|
|
1835
|
+
<Text
|
|
1836
|
+
style={[
|
|
1837
|
+
Style.msgTxtStyle, {
|
|
1838
|
+
...(messageListStyle?.emptyStateTextFont),
|
|
1839
|
+
color: messageListStyle?.emptyStateTextColor
|
|
1840
|
+
}] as TextStyle}
|
|
1841
|
+
>
|
|
1842
|
+
{emptyStateText}
|
|
1843
|
+
</Text>
|
|
1844
|
+
</View >
|
|
1845
|
+
</ScrollView>
|
|
1785
1846
|
{CustomListHeader && <CustomListHeader />}
|
|
1786
1847
|
</>
|
|
1787
1848
|
)
|
|
@@ -1797,7 +1858,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1797
1858
|
style={[Style.msgTxtStyle, {
|
|
1798
1859
|
...messageListStyle?.errorStateTextFont,
|
|
1799
1860
|
color: messageListStyle?.errorStateTextColor
|
|
1800
|
-
}]}
|
|
1861
|
+
}] as TextStyle}
|
|
1801
1862
|
>
|
|
1802
1863
|
{errorStateText}
|
|
1803
1864
|
</Text>
|
|
@@ -1816,18 +1877,18 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1816
1877
|
)
|
|
1817
1878
|
}, [])
|
|
1818
1879
|
|
|
1819
|
-
const handleScroll = (event) => {
|
|
1880
|
+
const handleScroll = (event: any) => {
|
|
1820
1881
|
if (event.nativeEvent.contentOffset.y == 0) {
|
|
1821
1882
|
getPreviousMessages();
|
|
1822
1883
|
}
|
|
1823
1884
|
scrollHandler(event);
|
|
1824
1885
|
};
|
|
1825
1886
|
|
|
1826
|
-
const onContentSizeChange = useCallback((contentWidth, contentHeight) => {
|
|
1887
|
+
const onContentSizeChange = useCallback((contentWidth: any, contentHeight: any) => {
|
|
1827
1888
|
if (currentScrollPosition.current.y == 0 && currentScrollPosition.current.scrollViewHeight) {
|
|
1828
1889
|
let diff = contentHeight - currentScrollPosition.current.scrollViewHeight;
|
|
1829
1890
|
if (messagesLength.current > prevMessagesLength.current && diff > 0 && !(unreadCount > 0)) {
|
|
1830
|
-
messageListRef.current
|
|
1891
|
+
messageListRef.current?.scrollTo({ y: diff, animated: false })
|
|
1831
1892
|
}
|
|
1832
1893
|
}
|
|
1833
1894
|
|
|
@@ -1855,7 +1916,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1855
1916
|
<View style={{
|
|
1856
1917
|
height, width, backgroundColor, borderRadius, ...border,
|
|
1857
1918
|
paddingStart: 8, paddingEnd: 8,
|
|
1858
|
-
}}>
|
|
1919
|
+
} as ViewProps}>
|
|
1859
1920
|
{
|
|
1860
1921
|
listState == "loading" && messagesList.length == 0 ?
|
|
1861
1922
|
getLoadingStateView() :
|
|
@@ -1868,11 +1929,11 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1868
1929
|
{
|
|
1869
1930
|
HeaderView && <View style={[Style.stickyHeaderFooterStyle, { top: 0 }]}>
|
|
1870
1931
|
<HeaderView
|
|
1871
|
-
group={group && group['guid']}
|
|
1872
|
-
user={user && user['uid']}
|
|
1932
|
+
group={group && (group as any)['guid']}
|
|
1933
|
+
user={user && (user as any)['uid']}
|
|
1873
1934
|
id={{
|
|
1874
|
-
guid: group && group['guid'],
|
|
1875
|
-
uid: user && user['uid'],
|
|
1935
|
+
guid: group && (group as any)['guid'],
|
|
1936
|
+
uid: user && (user as any)['uid'],
|
|
1876
1937
|
parentMessageId: parentMessageId
|
|
1877
1938
|
}}
|
|
1878
1939
|
/>
|
|
@@ -1890,7 +1951,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1890
1951
|
onScroll={handleScroll}
|
|
1891
1952
|
scrollEventThrottle={16} // control how often the scroll event will be fired
|
|
1892
1953
|
onLayout={() => {
|
|
1893
|
-
!currentScrollPosition.current.scrollViewHeight && messageListRef.current
|
|
1954
|
+
!currentScrollPosition.current.scrollViewHeight && messageListRef.current?.scrollToEnd({ animated: false })
|
|
1894
1955
|
}}
|
|
1895
1956
|
onContentSizeChange={onContentSizeChange}
|
|
1896
1957
|
>
|
|
@@ -1915,11 +1976,11 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1915
1976
|
{
|
|
1916
1977
|
FooterView && <View style={[Style.stickyHeaderFooterStyle, { bottom: 0 }]}>
|
|
1917
1978
|
<FooterView
|
|
1918
|
-
group={group && group['guid']}
|
|
1919
|
-
user={user && user['uid']}
|
|
1979
|
+
group={group && (group as any)['guid']}
|
|
1980
|
+
user={user && (user as any)['uid']}
|
|
1920
1981
|
id={{
|
|
1921
|
-
guid: group && group['guid'],
|
|
1922
|
-
uid: user && user['uid'],
|
|
1982
|
+
guid: group && (group as any)['guid'],
|
|
1983
|
+
uid: user && (user as any)['uid'],
|
|
1923
1984
|
parentMessageId: parentMessageId
|
|
1924
1985
|
}}
|
|
1925
1986
|
/>
|
|
@@ -1983,16 +2044,16 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1983
2044
|
setShowMessageOptions([])
|
|
1984
2045
|
infoObject.current = null;
|
|
1985
2046
|
setMessageInfo(false);
|
|
1986
|
-
}} isOpen={showMessageOptions.length > 0 || ExtensionsComponent || messageInfo}
|
|
2047
|
+
}} isOpen={showMessageOptions.length > 0 || Boolean(ExtensionsComponent) || messageInfo}
|
|
1987
2048
|
sliderMaxHeight={Dimensions.get('window').height * 0.5}
|
|
1988
2049
|
sliderMinHeight={Dimensions.get('window').height * 0.5}
|
|
1989
2050
|
>
|
|
1990
2051
|
{
|
|
1991
2052
|
ExtensionsComponent ? ExtensionsComponent :
|
|
1992
|
-
messageInfo ?
|
|
2053
|
+
messageInfo && infoObject.current ?
|
|
1993
2054
|
<CometChatMessageInformation
|
|
1994
2055
|
message={infoObject.current}
|
|
1995
|
-
template={templatesMap.get(`${infoObject.current
|
|
2056
|
+
template={templatesMap.get(`${infoObject.current?.getCategory()}_${infoObject.current?.getType()}`)}
|
|
1996
2057
|
sentIcon={sentIcon}
|
|
1997
2058
|
deliveredIcon={deliveredIcon}
|
|
1998
2059
|
readIcon={readIcon}
|
|
@@ -2036,6 +2097,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
2036
2097
|
height: (Dimensions.get('window').height * 0.5) - 54,
|
|
2037
2098
|
...emojiKeyboardStyle
|
|
2038
2099
|
}}
|
|
2100
|
+
theme={theme}
|
|
2039
2101
|
/>
|
|
2040
2102
|
</CometChatBottomSheet>
|
|
2041
2103
|
|
|
@@ -2043,7 +2105,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
2043
2105
|
isOpen={showReactionList}
|
|
2044
2106
|
onClose={() => {
|
|
2045
2107
|
setShowReactionList(false);
|
|
2046
|
-
setSelectedEmoji(
|
|
2108
|
+
setSelectedEmoji(undefined);
|
|
2047
2109
|
}}
|
|
2048
2110
|
sliderMaxHeight={Dimensions.get('window').height * 0.5}
|
|
2049
2111
|
sliderMinHeight={Dimensions.get('window').height * 0.5}
|
|
@@ -2052,7 +2114,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
2052
2114
|
messageObject={selectedMessage}
|
|
2053
2115
|
selectedReaction={selectedEmoji}
|
|
2054
2116
|
{...reactionListConfiguration}
|
|
2055
|
-
onPress={(messageReaction: CometChat.Reaction, messageObject: CometChat.BaseMessage) => {
|
|
2117
|
+
onPress={(messageReaction: CometChat.Reaction | any, messageObject: CometChat.BaseMessage | any) => {
|
|
2056
2118
|
if (reactionListConfiguration?.onPress) {
|
|
2057
2119
|
reactionListConfiguration.onPress(messageReaction, messageObject);
|
|
2058
2120
|
return;
|
|
@@ -2060,7 +2122,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
2060
2122
|
reactToMessage(messageReaction?.getReaction(), messageObject);
|
|
2061
2123
|
if (messageObject?.getReactions()?.length === 1 && messageObject?.getReactions()?.[0]?.['count'] == 1) {
|
|
2062
2124
|
setShowReactionList(false);
|
|
2063
|
-
setSelectedEmoji(
|
|
2125
|
+
setSelectedEmoji(undefined);
|
|
2064
2126
|
}
|
|
2065
2127
|
}}
|
|
2066
2128
|
/>
|