@droppii-org/chat-mobile 0.2.6 → 0.2.8
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/lib/module/components/AttachmentPreview.js +250 -0
- package/lib/module/components/AttachmentPreview.js.map +1 -0
- package/lib/module/components/MediaViewer/index.js +2 -0
- package/lib/module/components/MediaViewer/index.js.map +1 -0
- package/lib/module/components/MediaViewerModal.js +57 -0
- package/lib/module/components/MediaViewerModal.js.map +1 -0
- package/lib/module/components/MergedImageGrid.js +173 -0
- package/lib/module/components/MergedImageGrid.js.map +1 -0
- package/lib/module/components/ThreadCard/AvatarSection.js +4 -4
- package/lib/module/components/ThreadCard/AvatarSection.js.map +1 -1
- package/lib/module/components/ThreadCard/NamePrefixIcon.js +13 -16
- package/lib/module/components/ThreadCard/NamePrefixIcon.js.map +1 -1
- package/lib/module/components/ThreadCard/ThreadCard.js +13 -33
- package/lib/module/components/ThreadCard/ThreadCard.js.map +1 -1
- package/lib/module/components/ThreadCard/thread-card.utils.js +80 -4
- package/lib/module/components/ThreadCard/thread-card.utils.js.map +1 -1
- package/lib/module/components/messages/fileMessage/index.js +26 -0
- package/lib/module/components/messages/fileMessage/index.js.map +1 -0
- package/lib/module/components/messages/imageMessage/index.js +118 -0
- package/lib/module/components/messages/imageMessage/index.js.map +1 -0
- package/lib/module/components/messages/linkMessage/index.js +122 -0
- package/lib/module/components/messages/linkMessage/index.js.map +1 -0
- package/lib/module/components/messages/mergedMessage/index.js +37 -0
- package/lib/module/components/messages/mergedMessage/index.js.map +1 -0
- package/lib/module/components/messages/styles.js +41 -0
- package/lib/module/components/messages/styles.js.map +1 -0
- package/lib/module/components/messages/textMessage/index.js +38 -0
- package/lib/module/components/messages/textMessage/index.js.map +1 -0
- package/lib/module/components/messages/types.js +14 -0
- package/lib/module/components/messages/types.js.map +1 -0
- package/lib/module/components/messages/videoMessage/index.js +110 -0
- package/lib/module/components/messages/videoMessage/index.js.map +1 -0
- package/lib/module/config/api-endpoints.js +66 -0
- package/lib/module/config/api-endpoints.js.map +1 -0
- package/lib/module/config/attachment-priority.js +81 -0
- package/lib/module/config/attachment-priority.js.map +1 -0
- package/lib/module/config/configuration.js +50 -0
- package/lib/module/config/configuration.js.map +1 -0
- package/lib/module/config/index.js +22 -0
- package/lib/module/config/index.js.map +1 -0
- package/lib/module/context/ChatContext.js +7 -6
- package/lib/module/context/ChatContext.js.map +1 -1
- package/lib/module/core/index.js +19 -1
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/useChatListener.js +0 -14
- package/lib/module/core/useChatListener.js.map +1 -1
- package/lib/module/hooks/message/useSendMessage.js +106 -0
- package/lib/module/hooks/message/useSendMessage.js.map +1 -0
- package/lib/module/hooks/useChatMessages.js +36 -121
- package/lib/module/hooks/useChatMessages.js.map +1 -1
- package/lib/module/hooks/useConversationList.js +29 -17
- package/lib/module/hooks/useConversationList.js.map +1 -1
- package/lib/module/hooks/useImageAttachment.js +263 -0
- package/lib/module/hooks/useImageAttachment.js.map +1 -0
- package/lib/module/hooks/useLinkPreview/useLinkPreview.js +3 -2
- package/lib/module/hooks/useLinkPreview/useLinkPreview.js.map +1 -1
- package/lib/module/hooks/useMediaViewer.js +24 -0
- package/lib/module/hooks/useMediaViewer.js.map +1 -0
- package/lib/module/hooks/useSendAttachment.js +182 -0
- package/lib/module/hooks/useSendAttachment.js.map +1 -0
- package/lib/module/hooks/useVideoAttachment.js +251 -0
- package/lib/module/hooks/useVideoAttachment.js.map +1 -0
- package/lib/module/index.js +13 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/MediaView/VideoPlayer.js +177 -0
- package/lib/module/screens/MediaView/VideoPlayer.js.map +1 -0
- package/lib/module/screens/MediaView/index.js +264 -0
- package/lib/module/screens/MediaView/index.js.map +1 -0
- package/lib/module/screens/chat-detail/ChatComposer.js +190 -196
- package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatDetail.js +106 -71
- package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatDetailHeader.js +5 -8
- package/lib/module/screens/chat-detail/ChatDetailHeader.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatLinkPreview.js +1 -1
- package/lib/module/screens/chat-detail/ChatLinkPreview.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatListLegend.js +5 -15
- package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
- package/lib/module/screens/chat-detail/components/ChatInputActions.js +51 -0
- package/lib/module/screens/chat-detail/components/ChatInputActions.js.map +1 -0
- package/lib/module/screens/chat-detail/components/ChatMessageInput.js +93 -0
- package/lib/module/screens/chat-detail/components/ChatMessageInput.js.map +1 -0
- package/lib/module/screens/chat-detail/conversationHeader.utils.js +7 -9
- package/lib/module/screens/chat-detail/conversationHeader.utils.js.map +1 -1
- package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js +221 -0
- package/lib/module/screens/chat-detail/hooks/useAttachmentSendHandler.js.map +1 -0
- package/lib/module/screens/chat-detail/hooks/useChatComposerAnimation.js +114 -0
- package/lib/module/screens/chat-detail/hooks/useChatComposerAnimation.js.map +1 -0
- package/lib/module/screens/chat-detail/hooks/useChatComposerState.js +26 -0
- package/lib/module/screens/chat-detail/hooks/useChatComposerState.js.map +1 -0
- package/lib/module/screens/chat-detail/index.js +0 -1
- package/lib/module/screens/chat-detail/index.js.map +1 -1
- package/lib/module/screens/chat-detail/legend/LegendChatMessage.js +32 -25
- package/lib/module/screens/chat-detail/legend/LegendChatMessage.js.map +1 -1
- package/lib/module/screens/chat-detail/legend/messageTypes.js +15 -0
- package/lib/module/screens/chat-detail/legend/messageTypes.js.map +1 -0
- package/lib/module/screens/inbox/MessagesTab.js.map +1 -1
- package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js +61 -0
- package/lib/module/services/attachmentHandlers/fileAttachmentHandler.js.map +1 -0
- package/lib/module/services/attachmentHandlers/imageAttachmentHandler.js +54 -0
- package/lib/module/services/attachmentHandlers/imageAttachmentHandler.js.map +1 -0
- package/lib/module/services/attachmentHandlers/index.js +12 -0
- package/lib/module/services/attachmentHandlers/index.js.map +1 -0
- package/lib/module/services/attachmentHandlers/videoAttachmentHandler.js +85 -0
- package/lib/module/services/attachmentHandlers/videoAttachmentHandler.js.map +1 -0
- package/lib/module/services/attachmentOrchestrator.js +225 -0
- package/lib/module/services/attachmentOrchestrator.js.map +1 -0
- package/lib/module/services/auth.js +35 -0
- package/lib/module/services/auth.js.map +1 -0
- package/lib/module/services/endpoints.js +20 -1
- package/lib/module/services/endpoints.js.map +1 -1
- package/lib/module/services/imageUpload.js +126 -0
- package/lib/module/services/imageUpload.js.map +1 -0
- package/lib/module/store/conversation.js +1 -1
- package/lib/module/store/conversation.js.map +1 -1
- package/lib/module/store/message.js +45 -0
- package/lib/module/store/message.js.map +1 -0
- package/lib/module/translation/resources/i18n.js +22 -2
- package/lib/module/translation/resources/i18n.js.map +1 -1
- package/lib/module/types/attachment.js +2 -0
- package/lib/module/types/attachment.js.map +1 -0
- package/lib/module/types/attachmentHandler.js +20 -0
- package/lib/module/types/attachmentHandler.js.map +1 -0
- package/lib/module/types/chat.js +2 -7
- package/lib/module/types/chat.js.map +1 -1
- package/lib/module/types/imageUpload.js +2 -0
- package/lib/module/types/imageUpload.js.map +1 -0
- package/lib/module/types/message.js +1 -0
- package/lib/module/types/message.js.map +1 -1
- package/lib/module/utils/chatImageDimens.js +148 -0
- package/lib/module/utils/chatImageDimens.js.map +1 -0
- package/lib/module/utils/conversation.js +34 -13
- package/lib/module/utils/conversation.js.map +1 -1
- package/lib/module/utils/device.js +65 -0
- package/lib/module/utils/device.js.map +1 -0
- package/lib/module/utils/imageUrlOptimizer.js +41 -0
- package/lib/module/utils/imageUrlOptimizer.js.map +1 -0
- package/lib/module/utils/imageUtils.js +69 -0
- package/lib/module/utils/imageUtils.js.map +1 -0
- package/lib/module/utils/legendListMessage.js +0 -3
- package/lib/module/utils/legendListMessage.js.map +1 -1
- package/lib/module/utils/message.js +5 -8
- package/lib/module/utils/message.js.map +1 -1
- package/lib/module/utils/resolveMessageType.js +3 -0
- package/lib/module/utils/resolveMessageType.js.map +1 -1
- package/lib/module/utils/ui.js +17 -0
- package/lib/module/utils/ui.js.map +1 -0
- package/lib/module/utils/url.js +3 -3
- package/lib/module/utils/url.js.map +1 -1
- package/lib/module/utils/videoThumbnail.js +62 -0
- package/lib/module/utils/videoThumbnail.js.map +1 -0
- package/lib/typescript/src/components/AttachmentPreview.d.ts +28 -0
- package/lib/typescript/src/components/AttachmentPreview.d.ts.map +1 -0
- package/lib/typescript/src/components/MediaViewer/index.d.ts +1 -0
- package/lib/typescript/src/components/MediaViewer/index.d.ts.map +1 -0
- package/lib/typescript/src/components/MediaViewerModal.d.ts +10 -0
- package/lib/typescript/src/components/MediaViewerModal.d.ts.map +1 -0
- package/lib/typescript/src/components/MergedImageGrid.d.ts +16 -0
- package/lib/typescript/src/components/MergedImageGrid.d.ts.map +1 -0
- package/lib/typescript/src/components/ThreadCard/AvatarSection.d.ts +2 -2
- package/lib/typescript/src/components/ThreadCard/AvatarSection.d.ts.map +1 -1
- package/lib/typescript/src/components/ThreadCard/NamePrefixIcon.d.ts +3 -4
- package/lib/typescript/src/components/ThreadCard/NamePrefixIcon.d.ts.map +1 -1
- package/lib/typescript/src/components/ThreadCard/ThreadCard.d.ts.map +1 -1
- package/lib/typescript/src/components/ThreadCard/thread-card.utils.d.ts.map +1 -1
- package/lib/typescript/src/components/messages/fileMessage/index.d.ts +3 -0
- package/lib/typescript/src/components/messages/fileMessage/index.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/imageMessage/index.d.ts +3 -0
- package/lib/typescript/src/components/messages/imageMessage/index.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/linkMessage/index.d.ts +9 -0
- package/lib/typescript/src/components/messages/linkMessage/index.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/mergedMessage/index.d.ts +3 -0
- package/lib/typescript/src/components/messages/mergedMessage/index.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/styles.d.ts +36 -0
- package/lib/typescript/src/components/messages/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/textMessage/index.d.ts +9 -0
- package/lib/typescript/src/components/messages/textMessage/index.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/types.d.ts +10 -0
- package/lib/typescript/src/components/messages/types.d.ts.map +1 -0
- package/lib/typescript/src/components/messages/videoMessage/index.d.ts +3 -0
- package/lib/typescript/src/components/messages/videoMessage/index.d.ts.map +1 -0
- package/lib/typescript/src/config/api-endpoints.d.ts +40 -0
- package/lib/typescript/src/config/api-endpoints.d.ts.map +1 -0
- package/lib/typescript/src/config/attachment-priority.d.ts +31 -0
- package/lib/typescript/src/config/attachment-priority.d.ts.map +1 -0
- package/lib/typescript/src/config/configuration.d.ts +30 -0
- package/lib/typescript/src/config/configuration.d.ts.map +1 -0
- package/lib/typescript/src/config/index.d.ts +15 -0
- package/lib/typescript/src/config/index.d.ts.map +1 -0
- package/lib/typescript/src/context/ChatContext.d.ts +1 -1
- package/lib/typescript/src/context/ChatContext.d.ts.map +1 -1
- package/lib/typescript/src/core/index.d.ts +13 -1
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/core/useChatListener.d.ts.map +1 -1
- package/lib/typescript/src/hooks/message/useSendMessage.d.ts +12 -0
- package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useChatMessages.d.ts +0 -1
- package/lib/typescript/src/hooks/useChatMessages.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useConversationList.d.ts +2 -1
- package/lib/typescript/src/hooks/useConversationList.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useImageAttachment.d.ts +20 -0
- package/lib/typescript/src/hooks/useImageAttachment.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useLinkPreview/useLinkPreview.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMediaViewer.d.ts +13 -0
- package/lib/typescript/src/hooks/useMediaViewer.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useSendAttachment.d.ts +59 -0
- package/lib/typescript/src/hooks/useSendAttachment.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useVideoAttachment.d.ts +29 -0
- package/lib/typescript/src/hooks/useVideoAttachment.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +14 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/MediaView/VideoPlayer.d.ts +12 -0
- package/lib/typescript/src/screens/MediaView/VideoPlayer.d.ts.map +1 -0
- package/lib/typescript/src/screens/MediaView/index.d.ts +11 -0
- package/lib/typescript/src/screens/MediaView/index.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/ChatListLegend.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/components/ChatInputActions.d.ts +8 -0
- package/lib/typescript/src/screens/chat-detail/components/ChatInputActions.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/components/ChatMessageInput.d.ts +15 -0
- package/lib/typescript/src/screens/chat-detail/components/ChatMessageInput.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts +1 -1
- package/lib/typescript/src/screens/chat-detail/conversationHeader.utils.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts +23 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useAttachmentSendHandler.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerAnimation.d.ts +15 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerAnimation.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerState.d.ts +13 -0
- package/lib/typescript/src/screens/chat-detail/hooks/useChatComposerState.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/index.d.ts +0 -2
- package/lib/typescript/src/screens/chat-detail/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts +3 -3
- package/lib/typescript/src/screens/chat-detail/legend/LegendChatMessage.d.ts.map +1 -1
- package/lib/typescript/src/screens/chat-detail/legend/messageTypes.d.ts +13 -0
- package/lib/typescript/src/screens/chat-detail/legend/messageTypes.d.ts.map +1 -0
- package/lib/typescript/src/screens/chat-detail/types.d.ts +10 -8
- package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
- package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts +22 -0
- package/lib/typescript/src/services/attachmentHandlers/fileAttachmentHandler.d.ts.map +1 -0
- package/lib/typescript/src/services/attachmentHandlers/imageAttachmentHandler.d.ts +3 -0
- package/lib/typescript/src/services/attachmentHandlers/imageAttachmentHandler.d.ts.map +1 -0
- package/lib/typescript/src/services/attachmentHandlers/index.d.ts +5 -0
- package/lib/typescript/src/services/attachmentHandlers/index.d.ts.map +1 -0
- package/lib/typescript/src/services/attachmentHandlers/videoAttachmentHandler.d.ts +31 -0
- package/lib/typescript/src/services/attachmentHandlers/videoAttachmentHandler.d.ts.map +1 -0
- package/lib/typescript/src/services/attachmentOrchestrator.d.ts +5 -0
- package/lib/typescript/src/services/attachmentOrchestrator.d.ts.map +1 -0
- package/lib/typescript/src/services/auth.d.ts +19 -0
- package/lib/typescript/src/services/auth.d.ts.map +1 -0
- package/lib/typescript/src/services/endpoints.d.ts +11 -1
- package/lib/typescript/src/services/endpoints.d.ts.map +1 -1
- package/lib/typescript/src/services/imageUpload.d.ts +7 -0
- package/lib/typescript/src/services/imageUpload.d.ts.map +1 -0
- package/lib/typescript/src/store/message.d.ts +3 -0
- package/lib/typescript/src/store/message.d.ts.map +1 -0
- package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
- package/lib/typescript/src/types/attachment.d.ts +72 -0
- package/lib/typescript/src/types/attachment.d.ts.map +1 -0
- package/lib/typescript/src/types/attachmentHandler.d.ts +13 -0
- package/lib/typescript/src/types/attachmentHandler.d.ts.map +1 -0
- package/lib/typescript/src/types/chat.d.ts +28 -27
- package/lib/typescript/src/types/chat.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +1 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -1
- package/lib/typescript/src/types/imageUpload.d.ts +26 -0
- package/lib/typescript/src/types/imageUpload.d.ts.map +1 -0
- package/lib/typescript/src/types/message.d.ts +1 -0
- package/lib/typescript/src/types/message.d.ts.map +1 -1
- package/lib/typescript/src/utils/chatImageDimens.d.ts +34 -0
- package/lib/typescript/src/utils/chatImageDimens.d.ts.map +1 -0
- package/lib/typescript/src/utils/conversation.d.ts +3 -2
- package/lib/typescript/src/utils/conversation.d.ts.map +1 -1
- package/lib/typescript/src/utils/device.d.ts +7 -0
- package/lib/typescript/src/utils/device.d.ts.map +1 -0
- package/lib/typescript/src/utils/imageUrlOptimizer.d.ts +12 -0
- package/lib/typescript/src/utils/imageUrlOptimizer.d.ts.map +1 -0
- package/lib/typescript/src/utils/imageUtils.d.ts +9 -0
- package/lib/typescript/src/utils/imageUtils.d.ts.map +1 -0
- package/lib/typescript/src/utils/legendListMessage.d.ts +0 -2
- package/lib/typescript/src/utils/legendListMessage.d.ts.map +1 -1
- package/lib/typescript/src/utils/message.d.ts.map +1 -1
- package/lib/typescript/src/utils/resolveMessageType.d.ts.map +1 -1
- package/lib/typescript/src/utils/ui.d.ts +13 -0
- package/lib/typescript/src/utils/ui.d.ts.map +1 -0
- package/lib/typescript/src/utils/url.d.ts +1 -1
- package/lib/typescript/src/utils/url.d.ts.map +1 -1
- package/lib/typescript/src/utils/videoThumbnail.d.ts +16 -0
- package/lib/typescript/src/utils/videoThumbnail.d.ts.map +1 -0
- package/package.json +15 -3
- package/src/components/AttachmentPreview.tsx +304 -0
- package/src/components/MediaViewer/index.tsx +0 -0
- package/src/components/MediaViewerModal.tsx +70 -0
- package/src/components/MergedImageGrid.tsx +238 -0
- package/src/components/ThreadCard/AvatarSection.tsx +5 -8
- package/src/components/ThreadCard/NamePrefixIcon.tsx +27 -38
- package/src/components/ThreadCard/ThreadCard.tsx +16 -30
- package/src/components/ThreadCard/thread-card.utils.ts +95 -4
- package/src/components/messages/fileMessage/index.tsx +30 -0
- package/src/components/messages/imageMessage/index.tsx +137 -0
- package/src/components/messages/linkMessage/index.tsx +162 -0
- package/src/components/messages/mergedMessage/index.tsx +45 -0
- package/src/components/messages/styles.ts +39 -0
- package/src/components/messages/textMessage/index.tsx +53 -0
- package/src/components/messages/types.ts +22 -0
- package/src/components/messages/videoMessage/index.tsx +120 -0
- package/src/config/api-endpoints.ts +72 -0
- package/src/config/attachment-priority.ts +93 -0
- package/src/config/configuration.ts +50 -0
- package/src/config/index.ts +19 -0
- package/src/context/ChatContext.tsx +12 -4
- package/src/core/index.ts +25 -1
- package/src/core/useChatListener.ts +0 -21
- package/src/hooks/message/useSendMessage.ts +143 -0
- package/src/hooks/useChatMessages.ts +69 -161
- package/src/hooks/useConversationList.ts +34 -16
- package/src/hooks/useImageAttachment.ts +348 -0
- package/src/hooks/useLinkPreview/useLinkPreview.ts +3 -2
- package/src/hooks/useMediaViewer.ts +32 -0
- package/src/hooks/useSendAttachment.ts +295 -0
- package/src/hooks/useVideoAttachment.ts +334 -0
- package/src/index.tsx +13 -1
- package/src/screens/MediaView/VideoPlayer.tsx +211 -0
- package/src/screens/MediaView/index.tsx +327 -0
- package/src/screens/chat-detail/ChatComposer.tsx +206 -271
- package/src/screens/chat-detail/ChatDetail.tsx +164 -104
- package/src/screens/chat-detail/ChatDetailHeader.tsx +4 -10
- package/src/screens/chat-detail/ChatLinkPreview.tsx +1 -1
- package/src/screens/chat-detail/ChatListLegend.tsx +10 -13
- package/src/screens/chat-detail/components/ChatInputActions.tsx +71 -0
- package/src/screens/chat-detail/components/ChatMessageInput.tsx +127 -0
- package/src/screens/chat-detail/conversationHeader.utils.ts +11 -14
- package/src/screens/chat-detail/hooks/useAttachmentSendHandler.ts +291 -0
- package/src/screens/chat-detail/hooks/useChatComposerAnimation.ts +184 -0
- package/src/screens/chat-detail/hooks/useChatComposerState.ts +40 -0
- package/src/screens/chat-detail/index.ts +0 -2
- package/src/screens/chat-detail/legend/LegendChatMessage.tsx +44 -39
- package/src/screens/chat-detail/legend/messageTypes.tsx +13 -0
- package/src/screens/chat-detail/types.ts +11 -9
- package/src/screens/inbox/MessagesTab.tsx +1 -1
- package/src/services/attachmentHandlers/fileAttachmentHandler.ts +78 -0
- package/src/services/attachmentHandlers/imageAttachmentHandler.ts +54 -0
- package/src/services/attachmentHandlers/index.ts +10 -0
- package/src/services/attachmentHandlers/videoAttachmentHandler.ts +114 -0
- package/src/services/attachmentOrchestrator.ts +300 -0
- package/src/services/auth.ts +34 -0
- package/src/services/endpoints.ts +24 -1
- package/src/services/imageUpload.ts +162 -0
- package/src/store/conversation.ts +1 -1
- package/src/store/message.ts +44 -0
- package/src/translation/resources/i18n.ts +22 -2
- package/src/types/attachment.ts +85 -0
- package/src/types/attachmentHandler.ts +31 -0
- package/src/types/chat.ts +31 -30
- package/src/types/common.ts +1 -0
- package/src/types/imageUpload.ts +28 -0
- package/src/types/message.ts +1 -0
- package/src/utils/chatImageDimens.ts +178 -0
- package/src/utils/conversation.ts +44 -17
- package/src/utils/device.ts +73 -0
- package/src/utils/imageUrlOptimizer.ts +56 -0
- package/src/utils/imageUtils.ts +76 -0
- package/src/utils/legendListMessage.ts +0 -5
- package/src/utils/message.ts +10 -12
- package/src/utils/resolveMessageType.ts +2 -0
- package/src/utils/ui.ts +19 -0
- package/src/utils/url.ts +3 -3
- package/src/utils/videoThumbnail.ts +85 -0
- package/lib/module/screens/chat-detail/ChatList.js +0 -147
- package/lib/module/screens/chat-detail/ChatList.js.map +0 -1
- package/lib/module/screens/chat-detail/ChatTextBubble.js +0 -62
- package/lib/module/screens/chat-detail/ChatTextBubble.js.map +0 -1
- package/lib/module/screens/chat-detail/legend/message-types.js +0 -122
- package/lib/module/screens/chat-detail/legend/message-types.js.map +0 -1
- package/lib/module/screens/chat-detail/messages/ChatMessageBubble.js +0 -24
- package/lib/module/screens/chat-detail/messages/ChatMessageBubble.js.map +0 -1
- package/lib/module/screens/chat-detail/messages/types.js +0 -4
- package/lib/module/screens/chat-detail/messages/types.js.map +0 -1
- package/lib/typescript/src/screens/chat-detail/ChatList.d.ts +0 -3
- package/lib/typescript/src/screens/chat-detail/ChatList.d.ts.map +0 -1
- package/lib/typescript/src/screens/chat-detail/ChatTextBubble.d.ts +0 -3
- package/lib/typescript/src/screens/chat-detail/ChatTextBubble.d.ts.map +0 -1
- package/lib/typescript/src/screens/chat-detail/legend/message-types.d.ts +0 -12
- package/lib/typescript/src/screens/chat-detail/legend/message-types.d.ts.map +0 -1
- package/lib/typescript/src/screens/chat-detail/messages/ChatMessageBubble.d.ts +0 -3
- package/lib/typescript/src/screens/chat-detail/messages/ChatMessageBubble.d.ts.map +0 -1
- package/lib/typescript/src/screens/chat-detail/messages/types.d.ts +0 -13
- package/lib/typescript/src/screens/chat-detail/messages/types.d.ts.map +0 -1
- package/src/screens/chat-detail/ChatList.tsx +0 -190
- package/src/screens/chat-detail/ChatTextBubble.tsx +0 -73
- package/src/screens/chat-detail/legend/message-types.tsx +0 -149
- package/src/screens/chat-detail/messages/ChatMessageBubble.tsx +0 -23
- package/src/screens/chat-detail/messages/types.ts +0 -14
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import { KContainer, KLabel } from '@droppii/libs';
|
|
5
|
+
import { getMessageText } from "../../../utils/legendListMessage.js";
|
|
6
|
+
import { CHAT_BUBBLE_COLORS } from "../../../screens/chat-detail/constants.js";
|
|
7
|
+
import { messageStyles } from "../styles.js";
|
|
8
|
+
import { formatMessageTime } from "../types.js";
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
export const TextMessage = /*#__PURE__*/memo(({
|
|
11
|
+
message,
|
|
12
|
+
isOutgoing,
|
|
13
|
+
createdAtTime
|
|
14
|
+
}) => {
|
|
15
|
+
const messageText = getMessageText(message);
|
|
16
|
+
const timeLabel = formatMessageTime(createdAtTime);
|
|
17
|
+
if (!messageText?.trim()) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return /*#__PURE__*/_jsxs(KContainer.View, {
|
|
21
|
+
style: messageStyles.wrapper,
|
|
22
|
+
children: [/*#__PURE__*/_jsx(KContainer.View, {
|
|
23
|
+
style: [messageStyles.bubble, isOutgoing ? messageStyles.bubbleSent : messageStyles.bubbleReceived],
|
|
24
|
+
children: /*#__PURE__*/_jsx(KLabel.Text, {
|
|
25
|
+
typo: "TextMdNormal",
|
|
26
|
+
color: CHAT_BUBBLE_COLORS.text,
|
|
27
|
+
children: messageText
|
|
28
|
+
})
|
|
29
|
+
}), !isOutgoing && timeLabel ? /*#__PURE__*/_jsx(KLabel.Text, {
|
|
30
|
+
typo: "TextXsNormal",
|
|
31
|
+
color: CHAT_BUBBLE_COLORS.timestamp,
|
|
32
|
+
marginL: '0.25rem',
|
|
33
|
+
children: timeLabel
|
|
34
|
+
}) : null]
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
TextMessage.displayName = 'TextMessage';
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["memo","KContainer","KLabel","getMessageText","CHAT_BUBBLE_COLORS","messageStyles","formatMessageTime","jsx","_jsx","jsxs","_jsxs","TextMessage","message","isOutgoing","createdAtTime","messageText","timeLabel","trim","View","style","wrapper","children","bubble","bubbleSent","bubbleReceived","Text","typo","color","text","timestamp","marginL","displayName"],"sourceRoot":"../../../../../src","sources":["components/messages/textMessage/index.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,OAAO;AAC5B,SAASC,UAAU,EAAEC,MAAM,QAAQ,eAAe;AAClD,SAASC,cAAc,QAAQ,qCAAkC;AAEjE,SAASC,kBAAkB,QAAQ,2CAAwC;AAC3E,SAASC,aAAa,QAAQ,cAAW;AACzC,SAASC,iBAAiB,QAAQ,aAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAQ7C,OAAO,MAAMC,WAAW,gBAAGX,IAAI,CAC7B,CAAC;EAAEY,OAAO;EAAEC,UAAU;EAAEC;AAAgC,CAAC,KAAK;EAC5D,MAAMC,WAAW,GAAGZ,cAAc,CAACS,OAAO,CAAC;EAC3C,MAAMI,SAAS,GAAGV,iBAAiB,CAACQ,aAAa,CAAC;EAElD,IAAI,CAACC,WAAW,EAAEE,IAAI,CAAC,CAAC,EAAE;IACxB,OAAO,IAAI;EACb;EAEA,oBACEP,KAAA,CAACT,UAAU,CAACiB,IAAI;IAACC,KAAK,EAAEd,aAAa,CAACe,OAAQ;IAAAC,QAAA,gBAC5Cb,IAAA,CAACP,UAAU,CAACiB,IAAI;MACdC,KAAK,EAAE,CACLd,aAAa,CAACiB,MAAM,EACpBT,UAAU,GACNR,aAAa,CAACkB,UAAU,GACxBlB,aAAa,CAACmB,cAAc,CAChC;MAAAH,QAAA,eAEFb,IAAA,CAACN,MAAM,CAACuB,IAAI;QAACC,IAAI,EAAC,cAAc;QAACC,KAAK,EAAEvB,kBAAkB,CAACwB,IAAK;QAAAP,QAAA,EAC7DN;MAAW,CACD;IAAC,CACC,CAAC,EAEjB,CAACF,UAAU,IAAIG,SAAS,gBACvBR,IAAA,CAACN,MAAM,CAACuB,IAAI;MACVC,IAAI,EAAC,cAAc;MACnBC,KAAK,EAAEvB,kBAAkB,CAACyB,SAAU;MACpCC,OAAO,EAAE,SAAU;MAAAT,QAAA,EAElBL;IAAS,CACC,CAAC,GACZ,IAAI;EAAA,CACO,CAAC;AAEtB,CACF,CAAC;AAEDL,WAAW,CAACoB,WAAW,GAAG,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const formatMessageTime = createdAt => {
|
|
4
|
+
const date = new Date(createdAt);
|
|
5
|
+
if (Number.isNaN(date.getTime())) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
return date.toLocaleTimeString('vi-VN', {
|
|
9
|
+
hour: '2-digit',
|
|
10
|
+
minute: '2-digit',
|
|
11
|
+
hour12: false
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["formatMessageTime","createdAt","date","Date","Number","isNaN","getTime","toLocaleTimeString","hour","minute","hour12"],"sourceRoot":"../../../../src","sources":["components/messages/types.ts"],"mappings":";;AAUA,OAAO,MAAMA,iBAAiB,GAAIC,SAAiB,IAAK;EACtD,MAAMC,IAAI,GAAG,IAAIC,IAAI,CAACF,SAAS,CAAC;EAChC,IAAIG,MAAM,CAACC,KAAK,CAACH,IAAI,CAACI,OAAO,CAAC,CAAC,CAAC,EAAE;IAChC,OAAO,EAAE;EACX;EAEA,OAAOJ,IAAI,CAACK,kBAAkB,CAAC,OAAO,EAAE;IACtCC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE,SAAS;IACjBC,MAAM,EAAE;EACV,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { memo, useCallback } from 'react';
|
|
4
|
+
import { StyleSheet } from 'react-native';
|
|
5
|
+
import { KContainer, KImage, KLabel } from '@droppii/libs';
|
|
6
|
+
import ChatImageDimens, { CHAT_IMAGE_VIEW_SOURCE } from "../../../utils/chatImageDimens.js";
|
|
7
|
+
import { CHAT_BUBBLE_COLORS } from "../../../screens/chat-detail/constants.js";
|
|
8
|
+
import { messageStyles } from "../styles.js";
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const formatDuration = durationMs => {
|
|
11
|
+
const totalSeconds = Math.floor(durationMs / 1000);
|
|
12
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
13
|
+
const seconds = totalSeconds % 60;
|
|
14
|
+
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
|
15
|
+
};
|
|
16
|
+
export const VideoMessage = /*#__PURE__*/memo(({
|
|
17
|
+
message,
|
|
18
|
+
onMediaPress
|
|
19
|
+
}) => {
|
|
20
|
+
const videoElem = message?.videoElem;
|
|
21
|
+
const videoUrl = videoElem?.videoUrl;
|
|
22
|
+
const duration = videoElem?.duration;
|
|
23
|
+
const thumbnail = videoElem?.snapshotUrl;
|
|
24
|
+
const handlePress = useCallback(() => {
|
|
25
|
+
if (videoUrl && onMediaPress) {
|
|
26
|
+
onMediaPress([{
|
|
27
|
+
url: videoUrl,
|
|
28
|
+
isVideo: true
|
|
29
|
+
}], 0);
|
|
30
|
+
}
|
|
31
|
+
}, [videoUrl, onMediaPress]);
|
|
32
|
+
if (!videoUrl) {
|
|
33
|
+
return /*#__PURE__*/_jsx(KContainer.View, {
|
|
34
|
+
style: messageStyles.wrapper,
|
|
35
|
+
children: /*#__PURE__*/_jsx(KContainer.View, {
|
|
36
|
+
style: [messageStyles.bubble, messageStyles.videoPlaceholder],
|
|
37
|
+
children: /*#__PURE__*/_jsx(KLabel.Text, {
|
|
38
|
+
typo: "TextSmNormal",
|
|
39
|
+
color: CHAT_BUBBLE_COLORS.text,
|
|
40
|
+
children: "\uD83D\uDCF9 [Video unavailable]"
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const dimen = ChatImageDimens.getDimensions(CHAT_IMAGE_VIEW_SOURCE.MessageListThumbnail);
|
|
46
|
+
return /*#__PURE__*/_jsx(KContainer.View, {
|
|
47
|
+
style: messageStyles.wrapper,
|
|
48
|
+
children: /*#__PURE__*/_jsxs(KContainer.Touchable, {
|
|
49
|
+
onPress: handlePress,
|
|
50
|
+
style: [styles.videoContainer, {
|
|
51
|
+
width: dimen.width,
|
|
52
|
+
height: dimen.height
|
|
53
|
+
}],
|
|
54
|
+
children: [thumbnail ? /*#__PURE__*/_jsx(KImage.Base, {
|
|
55
|
+
uri: thumbnail,
|
|
56
|
+
width: dimen.width,
|
|
57
|
+
height: dimen.height,
|
|
58
|
+
resizeMode: "cover"
|
|
59
|
+
}) : /*#__PURE__*/_jsx(KContainer.View, {
|
|
60
|
+
style: styles.videoBg
|
|
61
|
+
}), /*#__PURE__*/_jsx(KContainer.View, {
|
|
62
|
+
style: styles.playOverlay,
|
|
63
|
+
center: true,
|
|
64
|
+
children: /*#__PURE__*/_jsx(KImage.VectorIcons, {
|
|
65
|
+
name: "play-circle",
|
|
66
|
+
provider: "MaterialCommunityIcons",
|
|
67
|
+
size: 48,
|
|
68
|
+
color: "white"
|
|
69
|
+
})
|
|
70
|
+
}), duration && /*#__PURE__*/_jsx(KContainer.View, {
|
|
71
|
+
style: styles.durationBadge,
|
|
72
|
+
children: /*#__PURE__*/_jsx(KLabel.Text, {
|
|
73
|
+
typo: "TextXsNormal",
|
|
74
|
+
color: "white",
|
|
75
|
+
children: formatDuration(duration)
|
|
76
|
+
})
|
|
77
|
+
})]
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
VideoMessage.displayName = 'VideoMessage';
|
|
82
|
+
const styles = StyleSheet.create({
|
|
83
|
+
videoContainer: {
|
|
84
|
+
overflow: 'hidden',
|
|
85
|
+
borderRadius: 8,
|
|
86
|
+
backgroundColor: '#000'
|
|
87
|
+
},
|
|
88
|
+
videoBg: {
|
|
89
|
+
flex: 1,
|
|
90
|
+
backgroundColor: '#000'
|
|
91
|
+
},
|
|
92
|
+
playOverlay: {
|
|
93
|
+
position: 'absolute',
|
|
94
|
+
top: 0,
|
|
95
|
+
left: 0,
|
|
96
|
+
right: 0,
|
|
97
|
+
bottom: 0,
|
|
98
|
+
backgroundColor: 'rgba(0, 0, 0, 0.3)'
|
|
99
|
+
},
|
|
100
|
+
durationBadge: {
|
|
101
|
+
position: 'absolute',
|
|
102
|
+
bottom: 8,
|
|
103
|
+
right: 8,
|
|
104
|
+
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
105
|
+
paddingHorizontal: 6,
|
|
106
|
+
paddingVertical: 3,
|
|
107
|
+
borderRadius: 4
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["memo","useCallback","StyleSheet","KContainer","KImage","KLabel","ChatImageDimens","CHAT_IMAGE_VIEW_SOURCE","CHAT_BUBBLE_COLORS","messageStyles","jsx","_jsx","jsxs","_jsxs","formatDuration","durationMs","totalSeconds","Math","floor","minutes","seconds","String","padStart","VideoMessage","message","onMediaPress","videoElem","videoUrl","duration","thumbnail","snapshotUrl","handlePress","url","isVideo","View","style","wrapper","children","bubble","videoPlaceholder","Text","typo","color","text","dimen","getDimensions","MessageListThumbnail","Touchable","onPress","styles","videoContainer","width","height","Base","uri","resizeMode","videoBg","playOverlay","center","VectorIcons","name","provider","size","durationBadge","displayName","create","overflow","borderRadius","backgroundColor","flex","position","top","left","right","bottom","paddingHorizontal","paddingVertical"],"sourceRoot":"../../../../../src","sources":["components/messages/videoMessage/index.tsx"],"mappings":";;AAAA,SAASA,IAAI,EAAEC,WAAW,QAAQ,OAAO;AACzC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,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+
* Centralized endpoint management for all API calls.
|
|
7
|
+
* Can be overridden per environment or feature flag.
|
|
8
|
+
*
|
|
9
|
+
* Note: imageUpload is a relative path because ReactNativeBlobUtil.fetch()
|
|
10
|
+
* is used for image uploads (not axios). The full URL is constructed
|
|
11
|
+
* in the imageUpload service using the base URL from environment/config.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const DEFAULT_ENDPOINTS = {
|
|
15
|
+
urlMetadata: '/chat-service/v1/utils/url-metadata',
|
|
16
|
+
imageUpload: '/uploader-service/v1/uploader/permanently'
|
|
17
|
+
};
|
|
18
|
+
let endpoints = {
|
|
19
|
+
...DEFAULT_ENDPOINTS
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get a specific API endpoint
|
|
24
|
+
* @param key - Endpoint key
|
|
25
|
+
* @returns Full endpoint URL
|
|
26
|
+
*/
|
|
27
|
+
export const getApiEndpoint = key => {
|
|
28
|
+
return endpoints[key];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Set a specific API endpoint (useful for testing/override)
|
|
33
|
+
* @param key - Endpoint key
|
|
34
|
+
* @param value - New endpoint URL
|
|
35
|
+
*/
|
|
36
|
+
export const setApiEndpoint = (key, value) => {
|
|
37
|
+
endpoints[key] = value;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Set all endpoints at once
|
|
42
|
+
* @param newEndpoints - New endpoints object
|
|
43
|
+
*/
|
|
44
|
+
export const setAllApiEndpoints = newEndpoints => {
|
|
45
|
+
endpoints = {
|
|
46
|
+
...endpoints,
|
|
47
|
+
...newEndpoints
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Reset to default endpoints
|
|
53
|
+
*/
|
|
54
|
+
export const resetApiEndpoints = () => {
|
|
55
|
+
endpoints = {
|
|
56
|
+
...DEFAULT_ENDPOINTS
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get all endpoints (returns copy)
|
|
62
|
+
*/
|
|
63
|
+
export const getAllApiEndpoints = () => ({
|
|
64
|
+
...endpoints
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=api-endpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DEFAULT_ENDPOINTS","urlMetadata","imageUpload","endpoints","getApiEndpoint","key","setApiEndpoint","value","setAllApiEndpoints","newEndpoints","resetApiEndpoints","getAllApiEndpoints"],"sourceRoot":"../../../src","sources":["config/api-endpoints.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,MAAMA,iBAA+B,GAAG;EACtCC,WAAW,EAAE,qCAAqC;EAClDC,WAAW,EAAE;AACf,CAAC;AAED,IAAIC,SAAuB,GAAG;EAAE,GAAGH;AAAkB,CAAC;;AAEtD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,cAAc,GACzBC,GAAM,IACc;EACpB,OAAOF,SAAS,CAACE,GAAG,CAAC;AACvB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAGA,CAC5BD,GAAM,EACNE,KAAsB,KACnB;EACHJ,SAAS,CAACE,GAAG,CAAC,GAAGE,KAAK;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAIC,YAAmC,IAAK;EACzEN,SAAS,GAAG;IACV,GAAGA,SAAS;IACZ,GAAGM;EACL,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EACrCP,SAAS,GAAG;IAAE,GAAGH;EAAkB,CAAC;AACtC,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMW,kBAAkB,GAAGA,CAAA,MAAqB;EACrD,GAAGR;AACL,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for attachment sending priority order
|
|
5
|
+
* AC2: Send mixed media with configurable priority
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Default AC2 configuration
|
|
9
|
+
export const DEFAULT_ATTACHMENT_PRIORITY = {
|
|
10
|
+
enabled: true,
|
|
11
|
+
order: ['image', 'video', 'file', 'text'],
|
|
12
|
+
mergeStrategy: {
|
|
13
|
+
images: 'merge',
|
|
14
|
+
// Multiple images merged into one message
|
|
15
|
+
videos: 'individual',
|
|
16
|
+
// Videos always sent individually (never merged)
|
|
17
|
+
files: 'merge' // Multiple files merged into one message
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Alternative configurations
|
|
22
|
+
export const ATTACHMENT_PRIORITY_PRESETS = {
|
|
23
|
+
// Send everything individually (no merging)
|
|
24
|
+
INDIVIDUAL: {
|
|
25
|
+
enabled: true,
|
|
26
|
+
order: ['image', 'video', 'file', 'text'],
|
|
27
|
+
mergeStrategy: {
|
|
28
|
+
images: 'individual',
|
|
29
|
+
videos: 'individual',
|
|
30
|
+
files: 'individual'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
// Send videos first, then everything else
|
|
34
|
+
VIDEOS_FIRST: {
|
|
35
|
+
enabled: true,
|
|
36
|
+
order: ['video', 'image', 'file', 'text'],
|
|
37
|
+
mergeStrategy: {
|
|
38
|
+
images: 'merge',
|
|
39
|
+
videos: 'individual',
|
|
40
|
+
files: 'merge'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
// Group by type - all media first, then text
|
|
44
|
+
MEDIA_FIRST: {
|
|
45
|
+
enabled: true,
|
|
46
|
+
order: ['image', 'video', 'file', 'text'],
|
|
47
|
+
mergeStrategy: {
|
|
48
|
+
images: 'merge',
|
|
49
|
+
videos: 'individual',
|
|
50
|
+
files: 'merge'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
// Disabled - use original behavior
|
|
54
|
+
DISABLED: {
|
|
55
|
+
enabled: false,
|
|
56
|
+
order: [],
|
|
57
|
+
mergeStrategy: {
|
|
58
|
+
images: 'merge',
|
|
59
|
+
videos: 'individual',
|
|
60
|
+
files: 'merge'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get attachment priority config
|
|
67
|
+
* Can be overridden via environment variable or per-user settings
|
|
68
|
+
*/
|
|
69
|
+
export function getAttachmentPriorityConfig() {
|
|
70
|
+
// Can be extended to read from environment or user preferences
|
|
71
|
+
return DEFAULT_ATTACHMENT_PRIORITY;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Validate and normalize priority order
|
|
76
|
+
*/
|
|
77
|
+
export function validatePriorityOrder(order) {
|
|
78
|
+
const validTypes = ['image', 'video', 'file', 'text'];
|
|
79
|
+
return order.filter(type => validTypes.includes(type));
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=attachment-priority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DEFAULT_ATTACHMENT_PRIORITY","enabled","order","mergeStrategy","images","videos","files","ATTACHMENT_PRIORITY_PRESETS","INDIVIDUAL","VIDEOS_FIRST","MEDIA_FIRST","DISABLED","getAttachmentPriorityConfig","validatePriorityOrder","validTypes","filter","type","includes"],"sourceRoot":"../../../src","sources":["config/attachment-priority.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAcA;AACA,OAAO,MAAMA,2BAAqD,GAAG;EACnEC,OAAO,EAAE,IAAI;EACbC,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC;EACzCC,aAAa,EAAE;IACbC,MAAM,EAAE,OAAO;IAAE;IACjBC,MAAM,EAAE,YAAY;IAAE;IACtBC,KAAK,EAAE,OAAO,CAAE;EAClB;AACF,CAAC;;A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ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Centralized Configuration
|
|
5
|
+
*
|
|
6
|
+
* Manages all API configuration in one place. Different services may use
|
|
7
|
+
* different protocols (axios, native HTTP), but they should all derive
|
|
8
|
+
* from the same base URL configuration.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
let config = {
|
|
12
|
+
apiBaseUrl: ''
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the base URL configuration
|
|
17
|
+
* This should be called during app startup before any API calls
|
|
18
|
+
*
|
|
19
|
+
* @param apiBaseUrl - The base URL for all API services (e.g., 'https://api.example.com')
|
|
20
|
+
*/
|
|
21
|
+
export const initBaseUrl = apiBaseUrl => {
|
|
22
|
+
if (!apiBaseUrl) {
|
|
23
|
+
if (__DEV__) console.warn('[Configuration] Initializing with empty apiBaseUrl');
|
|
24
|
+
}
|
|
25
|
+
config.apiBaseUrl = apiBaseUrl;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get the configured base URL
|
|
30
|
+
*/
|
|
31
|
+
export const getBaseUrl = () => {
|
|
32
|
+
return config.apiBaseUrl;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Reset configuration (useful for testing)
|
|
37
|
+
*/
|
|
38
|
+
export const resetBaseUrl = () => {
|
|
39
|
+
config = {
|
|
40
|
+
apiBaseUrl: ''
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Check if base URL is configured
|
|
46
|
+
*/
|
|
47
|
+
export const isBaseUrlConfigured = () => {
|
|
48
|
+
return !!config.apiBaseUrl;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["config","apiBaseUrl","initBaseUrl","__DEV__","console","warn","getBaseUrl","resetBaseUrl","isBaseUrlConfigured"],"sourceRoot":"../../../src","sources":["config/configuration.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,IAAIA,MAAiB,GAAG;EACtBC,UAAU,EAAE;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAID,UAAkB,IAAW;EACvD,IAAI,CAACA,UAAU,EAAE;IACf,IAAIE,OAAO,EACTC,OAAO,CAACC,IAAI,CAAC,oDAAoD,CAAC;EACtE;EACAL,MAAM,CAACC,UAAU,GAAGA,UAAU;AAChC,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMK,UAAU,GAAGA,CAAA,KAAc;EACtC,OAAON,MAAM,CAACC,UAAU;AAC1B,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMM,YAAY,GAAGA,CAAA,KAAY;EACtCP,MAAM,GAAG;IAAEC,UAAU,EAAE;EAAG,CAAC;AAC7B,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMO,mBAAmB,GAAGA,CAAA,KAAe;EAChD,OAAO,CAAC,CAACR,MAAM,CAACC,UAAU;AAC5B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Library Configuration
|
|
5
|
+
* Provides convenient access to library configuration values
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { getBaseUrl } from "./configuration.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Library Config object for easy access to configuration values
|
|
12
|
+
*/
|
|
13
|
+
export const Config = {
|
|
14
|
+
/**
|
|
15
|
+
* Get the configured API base URL
|
|
16
|
+
* @returns The base URL (e.g., 'https://api.example.com')
|
|
17
|
+
*/
|
|
18
|
+
get BASE_URL() {
|
|
19
|
+
return getBaseUrl();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getBaseUrl","Config","BASE_URL"],"sourceRoot":"../../../src","sources":["config/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,QAAQ,oBAAiB;;AAE5C;AACA;AACA;AACA,OAAO,MAAMC,MAAM,GAAG;EACpB;AACF;AACA;AACA;EACE,IAAIC,QAAQA,CAAA,EAAW;IACrB,OAAOF,UAAU,CAAC,CAAC;EACrB;AACF,CAAC","ignoreList":[]}
|
|
@@ -12,20 +12,21 @@ export const useChatContext = () => {
|
|
|
12
12
|
};
|
|
13
13
|
const ChatProviderInner = ({
|
|
14
14
|
logGA,
|
|
15
|
-
children
|
|
15
|
+
children,
|
|
16
|
+
applicationType
|
|
16
17
|
}) => {
|
|
17
18
|
const value = useMemo(() => ({
|
|
18
|
-
logGA
|
|
19
|
-
|
|
19
|
+
logGA,
|
|
20
|
+
applicationType
|
|
21
|
+
}), [logGA, applicationType]);
|
|
20
22
|
return /*#__PURE__*/_jsx(ChatContext.Provider, {
|
|
21
23
|
value: value,
|
|
22
24
|
children: children
|
|
23
25
|
});
|
|
24
26
|
};
|
|
25
27
|
export const ChatProvider = ({
|
|
26
|
-
enabled,
|
|
27
28
|
...props
|
|
28
|
-
}) =>
|
|
29
|
+
}) => /*#__PURE__*/_jsx(ChatProviderInner, {
|
|
29
30
|
...props
|
|
30
|
-
})
|
|
31
|
+
});
|
|
31
32
|
//# sourceMappingURL=ChatContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useContext","useMemo","jsx","_jsx","ChatContext","undefined","useChatContext","context","Error","ChatProviderInner","logGA","children","value","Provider","ChatProvider","
|
|
1
|
+
{"version":3,"names":["createContext","useContext","useMemo","jsx","_jsx","ChatContext","undefined","useChatContext","context","Error","ChatProviderInner","logGA","children","applicationType","value","Provider","ChatProvider","props"],"sourceRoot":"../../../src","sources":["context/ChatContext.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG3D,OAAO,MAAMC,WAAW,gBAAGL,aAAa,CACtCM,SACF,CAAC;AAED,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAuB;EACnD,MAAMC,OAAO,GAAGP,UAAU,CAACI,WAAW,CAAC;EACvC,IAAI,CAACG,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CAAC,iDAAiD,CAAC;EACpE;EACA,OAAOD,OAAO;AAChB,CAAC;AAED,MAAME,iBAAiB,GAAGA,CAAC;EACzBC,KAAK;EACLC,QAAQ;EACRC;AACiB,CAAC,KAAK;EACvB,MAAMC,KAAK,GAAGZ,OAAO,CACnB,OAAO;IAAES,KAAK;IAAEE;EAAgB,CAAC,CAAC,EAClC,CAACF,KAAK,EAAEE,eAAe,CACzB,CAAC;EAED,oBAAOT,IAAA,CAACC,WAAW,CAACU,QAAQ;IAACD,KAAK,EAAEA,KAAM;IAAAF,QAAA,EAAEA;EAAQ,CAAuB,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMI,YAAY,GAAGA,CAAC;EAAE,GAAGC;AAAyB,CAAC,kBAC1Db,IAAA,CAACM,iBAAiB;EAAA,GAAKO;AAAK,CAAG,CAChC","ignoreList":[]}
|
package/lib/module/core/index.js
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import OpenIMSDK from '@droppii/openim-rn-client-sdk';
|
|
4
|
+
import { initBaseUrl } from "../config/configuration.js";
|
|
4
5
|
import { useUserListener } from "./useUserListener.js";
|
|
5
6
|
import { useChatListener } from "./useChatListener.js";
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Initialize the chat SDK with optional base URL
|
|
9
|
+
* @param options - SDK initialization options + apiBaseUrl for centralized config
|
|
10
|
+
*/
|
|
11
|
+
export const initChatSdk = options => {
|
|
12
|
+
const {
|
|
13
|
+
apiBaseUrl,
|
|
14
|
+
...sdkOptions
|
|
15
|
+
} = options;
|
|
16
|
+
|
|
17
|
+
// Initialize OpenIM SDK
|
|
18
|
+
OpenIMSDK.initSDK(sdkOptions);
|
|
19
|
+
|
|
20
|
+
// Initialize centralized base URL config for all services
|
|
21
|
+
if (apiBaseUrl) {
|
|
22
|
+
initBaseUrl(apiBaseUrl);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
7
25
|
export const useChatSdk = () => {
|
|
8
26
|
useUserListener();
|
|
9
27
|
useChatListener();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OpenIMSDK","useUserListener","useChatListener","initChatSdk","
|
|
1
|
+
{"version":3,"names":["OpenIMSDK","initBaseUrl","useUserListener","useChatListener","initChatSdk","options","apiBaseUrl","sdkOptions","initSDK","useChatSdk"],"sourceRoot":"../../../src","sources":["core/index.ts"],"mappings":";;AAAA,OAAOA,SAAS,MAAM,+BAA+B;AAErD,SAASC,WAAW,QAAQ,4BAAyB;AACrD,SAASC,eAAe,QAAQ,sBAAmB;AACnD,SAASC,eAAe,QAAQ,sBAAmB;AAUnD;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAIC,OAA2B,IAAK;EAC1D,MAAM;IAAEC,UAAU;IAAE,GAAGC;EAAW,CAAC,GAAGF,OAAO;;EAE7C;EACAL,SAAS,CAACQ,OAAO,CAACD,UAAU,CAAC;;EAE7B;EACA,IAAID,UAAU,EAAE;IACdL,WAAW,CAACK,UAAU,CAAC;EACzB;AACF,CAAC;AAED,OAAO,MAAMG,UAAU,GAAGA,CAAA,KAAM;EAC9BP,eAAe,CAAC,CAAC;EACjBC,eAAe,CAAC,CAAC;AACnB,CAAC","ignoreList":[]}
|
|
@@ -4,12 +4,6 @@ import OpenIMSDK, { OpenIMEvent } from '@droppii/openim-rn-client-sdk';
|
|
|
4
4
|
import { useCallback, useEffect } from 'react';
|
|
5
5
|
import { useConversationStore } from "../store/conversation.js";
|
|
6
6
|
export const useChatListener = () => {
|
|
7
|
-
const onRecvNewMessages = useCallback(messages => {
|
|
8
|
-
console.log('onRecvNewMessages', messages);
|
|
9
|
-
}, []);
|
|
10
|
-
const onNewRecvMessageRevoked = useCallback(revokedInfo => {
|
|
11
|
-
console.log('onNewRecvMessageRevoked', revokedInfo);
|
|
12
|
-
}, []);
|
|
13
7
|
const onConversationChanged = useCallback(conversations => {
|
|
14
8
|
console.log('onConversationChanged', conversations);
|
|
15
9
|
useConversationStore.getState().mergeOpenIMConversations(conversations);
|
|
@@ -27,10 +21,6 @@ export const useChatListener = () => {
|
|
|
27
21
|
console.log('onGroupMemberDeleted', member);
|
|
28
22
|
}, []);
|
|
29
23
|
useEffect(() => {
|
|
30
|
-
// Message
|
|
31
|
-
OpenIMSDK.on(OpenIMEvent.OnRecvNewMessages, onRecvNewMessages);
|
|
32
|
-
OpenIMSDK.on(OpenIMEvent.OnNewRecvMessageRevoked, onNewRecvMessageRevoked);
|
|
33
|
-
|
|
34
24
|
// Conversation
|
|
35
25
|
OpenIMSDK.on(OpenIMEvent.OnConversationChanged, onConversationChanged);
|
|
36
26
|
OpenIMSDK.on(OpenIMEvent.OnNewConversation, onNewConversation);
|
|
@@ -39,10 +29,6 @@ export const useChatListener = () => {
|
|
|
39
29
|
OpenIMSDK.on(OpenIMEvent.OnGroupMemberAdded, onGroupMemberAdded);
|
|
40
30
|
OpenIMSDK.on(OpenIMEvent.OnGroupMemberDeleted, onGroupMemberDeleted);
|
|
41
31
|
return () => {
|
|
42
|
-
// Message
|
|
43
|
-
OpenIMSDK.off(OpenIMEvent.OnRecvNewMessages, onRecvNewMessages);
|
|
44
|
-
OpenIMSDK.off(OpenIMEvent.OnNewRecvMessageRevoked, onNewRecvMessageRevoked);
|
|
45
|
-
|
|
46
32
|
// Conversation
|
|
47
33
|
OpenIMSDK.off(OpenIMEvent.OnConversationChanged, onConversationChanged);
|
|
48
34
|
OpenIMSDK.off(OpenIMEvent.OnNewConversation, onNewConversation);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OpenIMSDK","OpenIMEvent","useCallback","useEffect","useConversationStore","useChatListener","
|
|
1
|
+
{"version":3,"names":["OpenIMSDK","OpenIMEvent","useCallback","useEffect","useConversationStore","useChatListener","onConversationChanged","conversations","console","log","getState","mergeOpenIMConversations","onNewConversation","onGroupMemberAdded","member","onGroupMemberDeleted","on","OnConversationChanged","OnNewConversation","OnGroupMemberAdded","OnGroupMemberDeleted","off"],"sourceRoot":"../../../src","sources":["core/useChatListener.ts"],"mappings":";;AAAA,OAAOA,SAAS,IACdC,WAAW,QAGN,+BAA+B;AACtC,SAASC,WAAW,EAAEC,SAAS,QAAQ,OAAO;AAC9C,SAASC,oBAAoB,QAAQ,0BAAuB;AAE5D,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAAM;EACnC,MAAMC,qBAAqB,GAAGJ,WAAW,CACtCK,aAAiC,IAAK;IACrCC,OAAO,CAACC,GAAG,CAAC,uBAAuB,EAAEF,aAAa,CAAC;IACnDH,oBAAoB,CAACM,QAAQ,CAAC,CAAC,CAACC,wBAAwB,CAACJ,aAAa,CAAC;EACzE,CAAC,EACD,EACF,CAAC;EAED,MAAMK,iBAAiB,GAAGV,WAAW,CAAEK,aAAiC,IAAK;IAC3EC,OAAO,CAACC,GAAG,CAAC,mBAAmB,EAAEF,aAAa,CAAC;IAC/C;IACA;IACAH,oBAAoB,CAACM,QAAQ,CAAC,CAAC,CAACC,wBAAwB,CAACJ,aAAa,CAAC;EACzE,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMM,kBAAkB,GAAGX,WAAW,CAAEY,MAAuB,IAAK;IAClEN,OAAO,CAACC,GAAG,CAAC,oBAAoB,EAAEK,MAAM,CAAC;EAC3C,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,oBAAoB,GAAGb,WAAW,CAAEY,MAAuB,IAAK;IACpEN,OAAO,CAACC,GAAG,CAAC,sBAAsB,EAAEK,MAAM,CAAC;EAC7C,CAAC,EAAE,EAAE,CAAC;EAENX,SAAS,CAAC,MAAM;IACd;IACAH,SAAS,CAACgB,EAAE,CAACf,WAAW,CAACgB,qBAAqB,EAAEX,qBAAqB,CAAC;IACtEN,SAAS,CAACgB,EAAE,CAACf,WAAW,CAACiB,iBAAiB,EAAEN,iBAAiB,CAAC;;IAE9D;IACAZ,SAAS,CAACgB,EAAE,CAACf,WAAW,CAACkB,kBAAkB,EAAEN,kBAAkB,CAAC;IAChEb,SAAS,CAACgB,EAAE,CAACf,WAAW,CAACmB,oBAAoB,EAAEL,oBAAoB,CAAC;IAEpE,OAAO,MAAM;MACX;MACAf,SAAS,CAACqB,GAAG,CAACpB,WAAW,CAACgB,qBAAqB,EAAEX,qBAAqB,CAAC;MACvEN,SAAS,CAACqB,GAAG,CAACpB,WAAW,CAACiB,iBAAiB,EAAEN,iBAAiB,CAAC;;MAE/D;MACAZ,SAAS,CAACqB,GAAG,CAACpB,WAAW,CAACkB,kBAAkB,EAAEN,kBAAkB,CAAC;MACjEb,SAAS,CAACqB,GAAG,CAACpB,WAAW,CAACmB,oBAAoB,EAAEL,oBAAoB,CAAC;IACvE,CAAC;IACD;EACF,CAAC,EAAE,EAAE,CAAC;AACR,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useConversationStore } from "../../store/index.js";
|
|
5
|
+
import { extractUrls } from "../../utils/url.js";
|
|
6
|
+
import OpenIMSDK from '@droppii/openim-rn-client-sdk';
|
|
7
|
+
import { useChatContext } from "../../context/index.js";
|
|
8
|
+
import { generateContentBasedOnMessageType } from "../../utils/conversation.js";
|
|
9
|
+
import { useMessageStore } from "../../store/message.js";
|
|
10
|
+
export const useSendMessage = () => {
|
|
11
|
+
const applicationType = useChatContext().applicationType;
|
|
12
|
+
const pushNewMessage = useMessageStore(state => state.pushNewMessage);
|
|
13
|
+
const sendMessage = useCallback(async ({
|
|
14
|
+
plainText,
|
|
15
|
+
files,
|
|
16
|
+
urlMetadata
|
|
17
|
+
}) => {
|
|
18
|
+
const {
|
|
19
|
+
userID: recvID,
|
|
20
|
+
groupID
|
|
21
|
+
} = useConversationStore.getState().getCurrentConversation() || {};
|
|
22
|
+
if (!recvID && !groupID) return;
|
|
23
|
+
const messageList = [];
|
|
24
|
+
for (const file of files || []) {
|
|
25
|
+
if (!file) continue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Allow empty text if urlMetadata (preview link) is present
|
|
29
|
+
const hasText = !!plainText && plainText.trim() !== '';
|
|
30
|
+
const hasPreview = !!urlMetadata?.url;
|
|
31
|
+
if (hasText || hasPreview) {
|
|
32
|
+
const urls = hasText ? extractUrls(plainText) : [];
|
|
33
|
+
const isUrlMessage = urls.length > 0 || hasPreview;
|
|
34
|
+
let message = null;
|
|
35
|
+
if (isUrlMessage) {
|
|
36
|
+
// Create URL message even with empty text if preview exists
|
|
37
|
+
message = await createUrlTextMessage(plainText || '', urls);
|
|
38
|
+
} else if (hasText) {
|
|
39
|
+
message = await createTextMessage(plainText);
|
|
40
|
+
}
|
|
41
|
+
if (!message) return;
|
|
42
|
+
messageList.push(message);
|
|
43
|
+
}
|
|
44
|
+
for (const message of messageList) {
|
|
45
|
+
const extendMessageInfo = {
|
|
46
|
+
applicationType,
|
|
47
|
+
urlMetadata
|
|
48
|
+
};
|
|
49
|
+
const successMessage = await OpenIMSDK.sendMessage({
|
|
50
|
+
groupID: groupID || '',
|
|
51
|
+
recvID: recvID || '',
|
|
52
|
+
message: {
|
|
53
|
+
...message,
|
|
54
|
+
ex: JSON.stringify(extendMessageInfo) || '{}'
|
|
55
|
+
},
|
|
56
|
+
offlinePushInfo: generateOfflinePushInfo(message.contentType, plainText || '')
|
|
57
|
+
});
|
|
58
|
+
pushNewMessage(successMessage);
|
|
59
|
+
}
|
|
60
|
+
}, [applicationType, pushNewMessage]);
|
|
61
|
+
return {
|
|
62
|
+
sendMessage
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const generateOfflinePushInfo = (contentType, plainText) => {
|
|
66
|
+
const conversationData = useConversationStore?.getState?.()?.getCurrentConversation();
|
|
67
|
+
const title = conversationData?.showName || 'Droppii';
|
|
68
|
+
const desc = generateContentBasedOnMessageType(contentType, plainText);
|
|
69
|
+
return {
|
|
70
|
+
title,
|
|
71
|
+
desc,
|
|
72
|
+
ex: JSON.stringify({
|
|
73
|
+
icon: conversationData?.faceURL || '',
|
|
74
|
+
conversationId: conversationData?.conversationId || '',
|
|
75
|
+
title,
|
|
76
|
+
desc
|
|
77
|
+
}),
|
|
78
|
+
iOSPushSound: 'default',
|
|
79
|
+
iOSBadgeCount: true
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export const createTextMessage = async text => {
|
|
83
|
+
let textMessage = await OpenIMSDK.createTextMessage(text, new Date().getTime().toString()).then(data => {
|
|
84
|
+
return data;
|
|
85
|
+
}).catch(({
|
|
86
|
+
errCode,
|
|
87
|
+
errMsg
|
|
88
|
+
}) => {
|
|
89
|
+
console.error('createTextMessage', errCode, errMsg);
|
|
90
|
+
return null;
|
|
91
|
+
});
|
|
92
|
+
return textMessage;
|
|
93
|
+
};
|
|
94
|
+
export const createUrlTextMessage = async (text, urls) => {
|
|
95
|
+
let urlTextMessage = await OpenIMSDK.createUrlTextMessage(text, urls, new Date().getTime().toString()).then(data => {
|
|
96
|
+
return data;
|
|
97
|
+
}).catch(({
|
|
98
|
+
errCode,
|
|
99
|
+
errMsg
|
|
100
|
+
}) => {
|
|
101
|
+
console.error('createUrlTextMessage', errCode, errMsg);
|
|
102
|
+
return null;
|
|
103
|
+
});
|
|
104
|
+
return urlTextMessage;
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=useSendMessage.js.map
|