@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,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message type components - re-exports from components/messages
|
|
3
|
+
* Stateless message components live in components/messages
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type { BaseLegendMessageProps } from '../../../components/messages/types';
|
|
7
|
+
export { formatMessageTime } from '../../../components/messages/types';
|
|
8
|
+
export { TextMessage } from '../../../components/messages/textMessage';
|
|
9
|
+
export { ImageMessage } from '../../../components/messages/imageMessage';
|
|
10
|
+
export { VideoMessage } from '../../../components/messages/videoMessage';
|
|
11
|
+
export { FileMessage } from '../../../components/messages/fileMessage';
|
|
12
|
+
export { MergedMessage } from '../../../components/messages/mergedMessage';
|
|
13
|
+
export { messageStyles } from '../../../components/messages/styles';
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import type { MediaItem } from '../../hooks/useMediaViewer';
|
|
3
4
|
import type { DConversationItem, DMessageItem } from '../../types/chat';
|
|
5
|
+
import type { IUrlMetadata } from '../../types/common';
|
|
6
|
+
import type { PeerType } from '@droppii/openim-rn-client-sdk';
|
|
4
7
|
|
|
5
8
|
export type DChatActionIconProvider = 'MaterialCommunityIcons' | 'DroppiiNew';
|
|
6
9
|
|
|
@@ -22,8 +25,7 @@ export interface ChatDetailHeaderProps {
|
|
|
22
25
|
subtitle?: string;
|
|
23
26
|
avatarUri?: string | null;
|
|
24
27
|
avatarFullName?: string;
|
|
25
|
-
|
|
26
|
-
chatCategory?: DChatCategory;
|
|
28
|
+
peerType?: PeerType;
|
|
27
29
|
applicationType?: DConversationItem['applicationType'];
|
|
28
30
|
showAddMember?: boolean;
|
|
29
31
|
onBack?: () => void;
|
|
@@ -59,10 +61,11 @@ export interface ChatAttachmentPanelProps {
|
|
|
59
61
|
export interface ChatComposerProps {
|
|
60
62
|
value?: string;
|
|
61
63
|
placeholder?: string;
|
|
62
|
-
onChangeText?: (text
|
|
63
|
-
onSend?: () => void;
|
|
64
|
+
onChangeText?: (text?: string) => void;
|
|
65
|
+
onSend?: (urlMetadata?: IUrlMetadata) => void;
|
|
64
66
|
onPressAttach?: () => void;
|
|
65
67
|
onPressEmoji?: () => void;
|
|
68
|
+
onMessageSent?: (message: DMessageItem) => void;
|
|
66
69
|
showQuickActions?: boolean;
|
|
67
70
|
quickActions?: DChatQuickAction[];
|
|
68
71
|
attachmentActions?: DChatAttachmentAction[];
|
|
@@ -85,6 +88,7 @@ export interface ChatListProps {
|
|
|
85
88
|
onLoadNewer?: () => void;
|
|
86
89
|
isLoadingNewer?: boolean;
|
|
87
90
|
hasMoreNewer?: boolean;
|
|
91
|
+
onMediaPress?: (items: MediaItem[], index?: number) => void;
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
export interface ChatDetailProps extends Omit<
|
|
@@ -93,8 +97,7 @@ export interface ChatDetailProps extends Omit<
|
|
|
93
97
|
| 'subtitle'
|
|
94
98
|
| 'avatarUri'
|
|
95
99
|
| 'avatarFullName'
|
|
96
|
-
| '
|
|
97
|
-
| 'chatCategory'
|
|
100
|
+
| 'peerType'
|
|
98
101
|
| 'applicationType'
|
|
99
102
|
| 'showAddMember'
|
|
100
103
|
> {
|
|
@@ -104,8 +107,7 @@ export interface ChatDetailProps extends Omit<
|
|
|
104
107
|
subtitle?: string;
|
|
105
108
|
avatarUri?: string | null;
|
|
106
109
|
avatarFullName?: string;
|
|
107
|
-
|
|
108
|
-
chatCategory?: DChatCategory;
|
|
110
|
+
peerType?: PeerType;
|
|
109
111
|
applicationType?: DConversationItem['applicationType'];
|
|
110
112
|
showAddMember?: boolean;
|
|
111
113
|
getSubtitle?: (conversation: DConversationItem) => string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { memo, useCallback } from 'react';
|
|
2
|
-
import { GestureResponderEvent, ActivityIndicator } from 'react-native';
|
|
2
|
+
import { type GestureResponderEvent, ActivityIndicator } from 'react-native';
|
|
3
3
|
import { KContainer, KDivider, KLabel, KColors } from '@droppii/libs';
|
|
4
4
|
import { useConversationList } from '../../hooks/useConversationList';
|
|
5
5
|
import { ThreadCard } from '../../components/ThreadCard';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Attachment, FileAttachment } from '../../types/attachment';
|
|
2
|
+
import type { IAttachmentHandler } from '../../types/attachmentHandler';
|
|
3
|
+
|
|
4
|
+
interface FileElem {
|
|
5
|
+
uuid: string;
|
|
6
|
+
fileName: string;
|
|
7
|
+
fileSize: number;
|
|
8
|
+
fileType: string;
|
|
9
|
+
url: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class FileAttachmentHandler implements IAttachmentHandler {
|
|
13
|
+
private static readonly MAX_FILE_SIZE = 200 * 1024 * 1024; // 200MB
|
|
14
|
+
|
|
15
|
+
validate(
|
|
16
|
+
attachment: Attachment
|
|
17
|
+
): { valid: true } | { valid: false; reason: string } {
|
|
18
|
+
if (attachment.type !== 'file') {
|
|
19
|
+
return {
|
|
20
|
+
valid: false,
|
|
21
|
+
reason: 'Invalid attachment type for file handler',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { sourceFile } = attachment;
|
|
26
|
+
|
|
27
|
+
if (!sourceFile.filename) {
|
|
28
|
+
return {
|
|
29
|
+
valid: false,
|
|
30
|
+
reason: 'File name is required',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!sourceFile.size) {
|
|
35
|
+
return {
|
|
36
|
+
valid: false,
|
|
37
|
+
reason: 'File size is required',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (sourceFile.size > FileAttachmentHandler.MAX_FILE_SIZE) {
|
|
42
|
+
return {
|
|
43
|
+
valid: false,
|
|
44
|
+
reason: `File size exceeds maximum (${FileAttachmentHandler.MAX_FILE_SIZE / 1024 / 1024}MB)`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return { valid: true };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async buildPayload(
|
|
52
|
+
attachment: Attachment,
|
|
53
|
+
uploadedUrl: string
|
|
54
|
+
): Promise<FileElem> {
|
|
55
|
+
const file = attachment as FileAttachment;
|
|
56
|
+
const { sourceFile } = file;
|
|
57
|
+
|
|
58
|
+
const fileElem: FileElem = {
|
|
59
|
+
uuid: attachment.id,
|
|
60
|
+
fileName: sourceFile.filename,
|
|
61
|
+
fileSize: sourceFile.size,
|
|
62
|
+
fileType: sourceFile.mimeType,
|
|
63
|
+
url: uploadedUrl,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
console.warn('[FileAttachmentHandler] Built payload', {
|
|
67
|
+
uuid: fileElem.uuid,
|
|
68
|
+
fileName: fileElem.fileName,
|
|
69
|
+
fileSize: fileElem.fileSize,
|
|
70
|
+
fileType: fileElem.fileType,
|
|
71
|
+
url: uploadedUrl.substring(0, 50) + '...',
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return fileElem;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default new FileAttachmentHandler();
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ImageAttachment } from '../../types/attachment';
|
|
2
|
+
import type { IAttachmentHandler } from '../../types/attachmentHandler';
|
|
3
|
+
import { generateUUID } from '../../utils/imageUtils';
|
|
4
|
+
|
|
5
|
+
export const ImageAttachmentHandler: IAttachmentHandler = {
|
|
6
|
+
validate(attachment: ImageAttachment) {
|
|
7
|
+
const MAX_SIZE = 5 * 1024 * 1024;
|
|
8
|
+
if (attachment.sourceFile.size > MAX_SIZE) {
|
|
9
|
+
return { valid: false, reason: 'Image exceeds 5MB limit' };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const validMimes = ['image/jpeg', 'image/png', 'image/webp', 'image/jpg'];
|
|
13
|
+
if (!validMimes.includes(attachment.sourceFile.mimeType)) {
|
|
14
|
+
return {
|
|
15
|
+
valid: false,
|
|
16
|
+
reason: `Unsupported format: ${attachment.sourceFile.mimeType}`,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (attachment.metadata.width <= 0 || attachment.metadata.height <= 0) {
|
|
21
|
+
return { valid: false, reason: 'Invalid image dimensions' };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return { valid: true };
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
async buildPayload(attachment: ImageAttachment, uploadedUrl: string) {
|
|
28
|
+
console.log('[ImageAttachmentHandler] Building payload for', {
|
|
29
|
+
filename: attachment.sourceFile.filename,
|
|
30
|
+
url: uploadedUrl,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const picInfo = {
|
|
34
|
+
uuid: generateUUID(),
|
|
35
|
+
type: attachment.sourceFile.mimeType,
|
|
36
|
+
size: attachment.sourceFile.size,
|
|
37
|
+
width: attachment.metadata.width,
|
|
38
|
+
height: attachment.metadata.height,
|
|
39
|
+
url: uploadedUrl,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const payload = {
|
|
43
|
+
sourcePicture: picInfo,
|
|
44
|
+
bigPicture: picInfo,
|
|
45
|
+
snapshotPicture: picInfo,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
console.log('[ImageAttachmentHandler] Payload created for', {
|
|
49
|
+
fileName: attachment.sourceFile.filename,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return payload;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Handlers are now dispatched directly in getAttachmentHandler without registry
|
|
2
|
+
|
|
3
|
+
// Legacy export for backward compatibility
|
|
4
|
+
export function initializeAttachmentHandlers(): void {
|
|
5
|
+
// No longer needed - handlers are dispatched directly
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { ImageAttachmentHandler } from './imageAttachmentHandler';
|
|
9
|
+
export { default as VideoAttachmentHandler } from './videoAttachmentHandler';
|
|
10
|
+
export { default as FileAttachmentHandler } from './fileAttachmentHandler';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { Attachment, VideoAttachment } from '../../types/attachment';
|
|
2
|
+
import type { IAttachmentHandler } from '../../types/attachmentHandler';
|
|
3
|
+
|
|
4
|
+
interface VideoPicInfo {
|
|
5
|
+
videoUUID: string;
|
|
6
|
+
videoType: string;
|
|
7
|
+
videoSize: number;
|
|
8
|
+
duration: number;
|
|
9
|
+
snapshotWidth: number;
|
|
10
|
+
snapshotHeight: number;
|
|
11
|
+
videoUrl: string;
|
|
12
|
+
videoPath: string;
|
|
13
|
+
snapshotPath: string;
|
|
14
|
+
snapshotUUID: string;
|
|
15
|
+
snapshotSize: number;
|
|
16
|
+
snapshotUrl: string;
|
|
17
|
+
snapShotType: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class VideoAttachmentHandler implements IAttachmentHandler {
|
|
21
|
+
private static readonly MAX_VIDEO_SIZE = 100 * 1024 * 1024; // 100MB
|
|
22
|
+
private static readonly SUPPORTED_TYPES = ['video/mp4', 'video/quicktime'];
|
|
23
|
+
|
|
24
|
+
validate(
|
|
25
|
+
attachment: Attachment
|
|
26
|
+
): { valid: true } | { valid: false; reason: string } {
|
|
27
|
+
if (attachment.type !== 'video') {
|
|
28
|
+
return {
|
|
29
|
+
valid: false,
|
|
30
|
+
reason: 'Invalid attachment type for video handler',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const { sourceFile } = attachment;
|
|
35
|
+
|
|
36
|
+
if (!sourceFile?.size) {
|
|
37
|
+
return {
|
|
38
|
+
valid: false,
|
|
39
|
+
reason: 'Video file size is required',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (sourceFile.size > VideoAttachmentHandler.MAX_VIDEO_SIZE) {
|
|
44
|
+
return {
|
|
45
|
+
valid: false,
|
|
46
|
+
reason: `Video size exceeds maximum (${VideoAttachmentHandler.MAX_VIDEO_SIZE / 1024 / 1024}MB)`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (
|
|
51
|
+
sourceFile.mimeType &&
|
|
52
|
+
!VideoAttachmentHandler.SUPPORTED_TYPES.includes(sourceFile.mimeType)
|
|
53
|
+
) {
|
|
54
|
+
return {
|
|
55
|
+
valid: false,
|
|
56
|
+
reason: 'Unsupported video format',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return { valid: true };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async buildPayload(
|
|
64
|
+
attachment: Attachment,
|
|
65
|
+
uploadedUrl: string
|
|
66
|
+
): Promise<VideoPicInfo> {
|
|
67
|
+
const video = attachment as VideoAttachment;
|
|
68
|
+
const { sourceFile, metadata } = video;
|
|
69
|
+
|
|
70
|
+
// Use thumbnail URL if available, otherwise fall back to video URL
|
|
71
|
+
const snapshotUrl = metadata.thumbnail?.url || uploadedUrl;
|
|
72
|
+
const snapshotWidth = metadata.thumbnail?.width || metadata.width || 320;
|
|
73
|
+
const snapshotHeight = metadata.thumbnail?.height || metadata.height || 180;
|
|
74
|
+
const snapshotSize = metadata.thumbnail?.size || 0;
|
|
75
|
+
|
|
76
|
+
if (metadata.thumbnail?.url) {
|
|
77
|
+
console.log('✅ [VideoAttachmentHandler] Using thumbnail:', {
|
|
78
|
+
snapshotUrl: metadata.thumbnail.url,
|
|
79
|
+
snapshotWidth,
|
|
80
|
+
snapshotHeight,
|
|
81
|
+
snapshotSize,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const picInfo: VideoPicInfo = {
|
|
86
|
+
videoUUID: attachment.id,
|
|
87
|
+
videoType: sourceFile.mimeType || 'video/mp4',
|
|
88
|
+
videoSize: sourceFile.size,
|
|
89
|
+
duration: metadata.duration,
|
|
90
|
+
snapshotWidth: snapshotWidth,
|
|
91
|
+
snapshotHeight: snapshotHeight,
|
|
92
|
+
videoUrl: uploadedUrl,
|
|
93
|
+
videoPath: sourceFile.path,
|
|
94
|
+
snapshotPath: snapshotUrl,
|
|
95
|
+
snapshotUUID: `${attachment.id}-snapshot`,
|
|
96
|
+
snapshotSize: snapshotSize,
|
|
97
|
+
snapshotUrl: snapshotUrl,
|
|
98
|
+
snapShotType: 'image/jpeg',
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
console.warn('[VideoAttachmentHandler] Built payload', {
|
|
102
|
+
videoUUID: picInfo.videoUUID,
|
|
103
|
+
videoSize: picInfo.videoSize,
|
|
104
|
+
duration: picInfo.duration,
|
|
105
|
+
snapshotWidth: picInfo.snapshotWidth,
|
|
106
|
+
snapshotHeight: picInfo.snapshotHeight,
|
|
107
|
+
videoUrl: uploadedUrl.substring(0, 50) + '...',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return picInfo;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export default new VideoAttachmentHandler();
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import OpenIMSDK, { type MessageItem } from '@droppii/openim-rn-client-sdk';
|
|
2
|
+
import type {
|
|
3
|
+
Attachment,
|
|
4
|
+
AttachmentSendOptions,
|
|
5
|
+
AttachmentSendResult,
|
|
6
|
+
} from '../types/attachment';
|
|
7
|
+
import { getAttachmentHandler } from '../types/attachmentHandler';
|
|
8
|
+
import { useConversationStore } from '../store';
|
|
9
|
+
import {
|
|
10
|
+
getAttachmentPriorityConfig,
|
|
11
|
+
type AttachmentType,
|
|
12
|
+
} from '../config/attachment-priority';
|
|
13
|
+
|
|
14
|
+
export namespace AttachmentOrchestratorService {
|
|
15
|
+
export async function sendPreparedAttachments(
|
|
16
|
+
attachments: Attachment[],
|
|
17
|
+
uploadedUrls: Record<string, string>,
|
|
18
|
+
options: AttachmentSendOptions = { strategy: 'individual' },
|
|
19
|
+
onMessageSent?: (message: any) => void
|
|
20
|
+
): Promise<AttachmentSendResult> {
|
|
21
|
+
const result: AttachmentSendResult = {
|
|
22
|
+
success: false,
|
|
23
|
+
sentAttachmentIds: [],
|
|
24
|
+
failedAttachmentIds: [],
|
|
25
|
+
errors: {},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
if (!attachments || attachments.length === 0) {
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 1. Validate all attachments
|
|
33
|
+
console.log('[AttachmentOrchestrator] Validating prepared attachments...');
|
|
34
|
+
for (const att of attachments) {
|
|
35
|
+
try {
|
|
36
|
+
const handler = getAttachmentHandler(att.type);
|
|
37
|
+
const validation = handler.validate(att);
|
|
38
|
+
if (!validation.valid) {
|
|
39
|
+
result.failedAttachmentIds.push(att.id);
|
|
40
|
+
result.errors[att.id] = (
|
|
41
|
+
validation as { valid: false; reason: string }
|
|
42
|
+
).reason;
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
const msg =
|
|
46
|
+
error instanceof Error ? error.message : 'Validation failed';
|
|
47
|
+
result.failedAttachmentIds.push(att.id);
|
|
48
|
+
result.errors[att.id] = msg;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (result.failedAttachmentIds.length === attachments.length) {
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const validAttachments = attachments.filter(
|
|
57
|
+
(a) => !result.failedAttachmentIds.includes(a.id)
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// 2. Build message payloads directly (no upload)
|
|
61
|
+
console.log(
|
|
62
|
+
'[AttachmentOrchestrator] Building message payloads for prepared attachments...'
|
|
63
|
+
);
|
|
64
|
+
const payloads: Array<{ attachmentId: string; payload: unknown }> = [];
|
|
65
|
+
for (const att of validAttachments) {
|
|
66
|
+
try {
|
|
67
|
+
const uploadedUrl = uploadedUrls[att.id];
|
|
68
|
+
if (!uploadedUrl) {
|
|
69
|
+
result.failedAttachmentIds.push(att.id);
|
|
70
|
+
result.errors[att.id] = 'No uploaded URL provided';
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const handler = getAttachmentHandler(att.type);
|
|
75
|
+
const payload = await handler.buildPayload(att, uploadedUrl);
|
|
76
|
+
payloads.push({ attachmentId: att.id, payload });
|
|
77
|
+
} catch (error) {
|
|
78
|
+
const msg =
|
|
79
|
+
error instanceof Error ? error.message : 'Payload build failed';
|
|
80
|
+
result.failedAttachmentIds.push(att.id);
|
|
81
|
+
result.errors[att.id] = msg;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 3. Send via OpenIM - always use createMergerMessage
|
|
86
|
+
console.log('[AttachmentOrchestrator] Sending via createMergerMessage', {
|
|
87
|
+
payloadCount: payloads.length,
|
|
88
|
+
attachmentIds: payloads.map((p) => p.attachmentId),
|
|
89
|
+
});
|
|
90
|
+
try {
|
|
91
|
+
const mergedMsgId = await sendMergedMessage(
|
|
92
|
+
payloads.map((p) => p.payload),
|
|
93
|
+
options.includeCaption,
|
|
94
|
+
onMessageSent
|
|
95
|
+
);
|
|
96
|
+
console.log('[AttachmentOrchestrator] Messages sent via merger:', {
|
|
97
|
+
messageId: mergedMsgId,
|
|
98
|
+
count: payloads.length,
|
|
99
|
+
});
|
|
100
|
+
result.sentAttachmentIds = payloads.map((p) => p.attachmentId);
|
|
101
|
+
result.mergedMessageId = mergedMsgId;
|
|
102
|
+
} catch (error) {
|
|
103
|
+
const msg = error instanceof Error ? error.message : 'Send failed';
|
|
104
|
+
console.error('[AttachmentOrchestrator] OpenIM send error:', {
|
|
105
|
+
error: msg,
|
|
106
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
107
|
+
});
|
|
108
|
+
if (result.sentAttachmentIds.length === 0) {
|
|
109
|
+
result.errors._send = msg;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
result.success = result.sentAttachmentIds.length > 0;
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function sendMergedMessage(
|
|
118
|
+
payloads: unknown[],
|
|
119
|
+
_caption?: string,
|
|
120
|
+
onMessageSent?: (message: any) => void
|
|
121
|
+
): Promise<string> {
|
|
122
|
+
const currentConversation = useConversationStore
|
|
123
|
+
.getState()
|
|
124
|
+
.getCurrentConversation();
|
|
125
|
+
|
|
126
|
+
if (!currentConversation) {
|
|
127
|
+
throw new Error('No conversation selected');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Get priority configuration
|
|
131
|
+
const priorityConfig = getAttachmentPriorityConfig();
|
|
132
|
+
console.log('[AttachmentOrchestrator] Using priority config:', {
|
|
133
|
+
enabled: priorityConfig.enabled,
|
|
134
|
+
order: priorityConfig.order,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Categorize payloads by type
|
|
138
|
+
const categorizedPayloads: Record<AttachmentType, unknown[]> = {
|
|
139
|
+
image: [],
|
|
140
|
+
video: [],
|
|
141
|
+
file: [],
|
|
142
|
+
text: [],
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
for (const p of payloads) {
|
|
146
|
+
const payload = p as any;
|
|
147
|
+
// Detect type from payload properties
|
|
148
|
+
if (payload.duration !== undefined || payload.videoPath !== undefined) {
|
|
149
|
+
categorizedPayloads.video.push(p);
|
|
150
|
+
} else if (
|
|
151
|
+
payload.fileExtension !== undefined ||
|
|
152
|
+
(payload.fileName && payload.fileName.includes('.'))
|
|
153
|
+
) {
|
|
154
|
+
categorizedPayloads.file.push(p);
|
|
155
|
+
} else if (payload.content && typeof payload.content === 'string') {
|
|
156
|
+
categorizedPayloads.text.push(p);
|
|
157
|
+
} else {
|
|
158
|
+
categorizedPayloads.image.push(p);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
console.log('[AttachmentOrchestrator] Categorized payloads:', {
|
|
163
|
+
count: payloads.length,
|
|
164
|
+
images: categorizedPayloads.image.length,
|
|
165
|
+
videos: categorizedPayloads.video.length,
|
|
166
|
+
files: categorizedPayloads.file.length,
|
|
167
|
+
texts: categorizedPayloads.text.length,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// AC2: Create message from payload based on type
|
|
171
|
+
const createMessageFromPayload = async (p: any) => {
|
|
172
|
+
if (p.duration !== undefined || p.videoPath !== undefined) {
|
|
173
|
+
console.log('[AttachmentOrchestrator] Creating video message');
|
|
174
|
+
return OpenIMSDK.createVideoMessageByURL(p);
|
|
175
|
+
}
|
|
176
|
+
if (
|
|
177
|
+
p.fileExtension !== undefined ||
|
|
178
|
+
(p.fileName && p.fileName.includes('.'))
|
|
179
|
+
) {
|
|
180
|
+
console.log('[AttachmentOrchestrator] Creating file message');
|
|
181
|
+
return OpenIMSDK.createFileMessageByURL(p);
|
|
182
|
+
}
|
|
183
|
+
if (p.content && typeof p.content === 'string') {
|
|
184
|
+
console.log('[AttachmentOrchestrator] Creating text message');
|
|
185
|
+
return OpenIMSDK.createTextMessage(p.content);
|
|
186
|
+
}
|
|
187
|
+
// Default to image
|
|
188
|
+
console.log('[AttachmentOrchestrator] Creating image message');
|
|
189
|
+
return OpenIMSDK.createImageMessageByURL(p);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// Process attachments in priority order from config
|
|
193
|
+
let lastMsgId = '';
|
|
194
|
+
const allMessages = [];
|
|
195
|
+
|
|
196
|
+
if (priorityConfig.enabled) {
|
|
197
|
+
// Use configured priority order
|
|
198
|
+
console.log(
|
|
199
|
+
'[AttachmentOrchestrator] Processing in priority order:',
|
|
200
|
+
priorityConfig.order
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
for (const attachmentType of priorityConfig.order) {
|
|
204
|
+
const payloadsForType = categorizedPayloads[attachmentType];
|
|
205
|
+
if (payloadsForType.length === 0) continue;
|
|
206
|
+
|
|
207
|
+
console.log(`[AttachmentOrchestrator] Processing ${attachmentType}:`, {
|
|
208
|
+
count: payloadsForType.length,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const mergeStrategy =
|
|
212
|
+
attachmentType === 'image'
|
|
213
|
+
? priorityConfig.mergeStrategy.images
|
|
214
|
+
: attachmentType === 'video'
|
|
215
|
+
? priorityConfig.mergeStrategy.videos
|
|
216
|
+
: attachmentType === 'file'
|
|
217
|
+
? priorityConfig.mergeStrategy.files
|
|
218
|
+
: 'individual';
|
|
219
|
+
|
|
220
|
+
if (mergeStrategy === 'individual' || payloadsForType.length === 1) {
|
|
221
|
+
// Send individually
|
|
222
|
+
for (const p of payloadsForType) {
|
|
223
|
+
const message = await createMessageFromPayload(p as any);
|
|
224
|
+
allMessages.push(message);
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
// Merge multiple items
|
|
228
|
+
const messages = [];
|
|
229
|
+
for (const p of payloadsForType) {
|
|
230
|
+
const message = await createMessageFromPayload(p as any);
|
|
231
|
+
messages.push(message);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const typeLabel =
|
|
235
|
+
attachmentType.charAt(0).toUpperCase() + attachmentType.slice(1);
|
|
236
|
+
const merged = await OpenIMSDK.createMergerMessage({
|
|
237
|
+
messageList: messages,
|
|
238
|
+
title: typeLabel + 's',
|
|
239
|
+
summaryList: messages.map((_, i) => `[${typeLabel} ${i + 1}]`),
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
if (merged) {
|
|
243
|
+
allMessages.push(merged);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
// Original behavior (config disabled)
|
|
249
|
+
console.log('[AttachmentOrchestrator] Priority config disabled');
|
|
250
|
+
|
|
251
|
+
const allPayloads = [
|
|
252
|
+
...categorizedPayloads.image,
|
|
253
|
+
...categorizedPayloads.video,
|
|
254
|
+
...categorizedPayloads.file,
|
|
255
|
+
...categorizedPayloads.text,
|
|
256
|
+
];
|
|
257
|
+
|
|
258
|
+
for (const p of allPayloads) {
|
|
259
|
+
const message = await createMessageFromPayload(p as any);
|
|
260
|
+
allMessages.push(message);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Send all messages in priority order
|
|
265
|
+
console.log(
|
|
266
|
+
'[AttachmentOrchestrator] Sending all messages in priority order',
|
|
267
|
+
{
|
|
268
|
+
totalMessages: allMessages.length,
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
for (let i = 0; i < allMessages.length; i++) {
|
|
273
|
+
const message = allMessages[i] as MessageItem;
|
|
274
|
+
console.log(
|
|
275
|
+
'[AttachmentOrchestrator] Sending message',
|
|
276
|
+
i + 1,
|
|
277
|
+
'of',
|
|
278
|
+
allMessages.length
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
const result = await OpenIMSDK.sendMessageNotOss({
|
|
282
|
+
recvID: currentConversation.userID || '',
|
|
283
|
+
groupID: currentConversation.groupID || '',
|
|
284
|
+
message,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
lastMsgId = result?.clientMsgID || result?.serverMsgID || '';
|
|
288
|
+
console.log('[AttachmentOrchestrator] Message sent:', {
|
|
289
|
+
messageId: lastMsgId,
|
|
290
|
+
index: i + 1,
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
if (onMessageSent && result) {
|
|
294
|
+
onMessageSent(result);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return lastMsgId;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth token management
|
|
3
|
+
* Consumer app calls setAuthToken() once at startup
|
|
4
|
+
* Library services call getAuthToken() internally
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
let authToken: string | null = null;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Set auth token (call once at app startup)
|
|
11
|
+
*/
|
|
12
|
+
export const setAuthToken = (token: string) => {
|
|
13
|
+
authToken = token;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get auth token (called internally by library services)
|
|
18
|
+
* @throws Error if token not set
|
|
19
|
+
*/
|
|
20
|
+
export const getAuthToken = (): string => {
|
|
21
|
+
if (!authToken) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
'Auth token not initialized. Call setAuthToken(token) at app startup.'
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return authToken;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Clear token (logout)
|
|
31
|
+
*/
|
|
32
|
+
export const clearAuthToken = () => {
|
|
33
|
+
authToken = null;
|
|
34
|
+
};
|