@droppii-org/chat-mobile 0.2.7 → 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/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/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 +10 -5
- package/lib/module/hooks/message/useSendMessage.js.map +1 -1
- package/lib/module/hooks/useChatMessages.js +0 -3
- package/lib/module/hooks/useChatMessages.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/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 +94 -63
- package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
- package/lib/module/screens/chat-detail/ChatListLegend.js +5 -13
- 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/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 +33 -13
- 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/translation/resources/i18n.js +22 -8
- 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/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/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/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 +1 -1
- 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/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/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.map +1 -1
- package/lib/typescript/src/hooks/useChatMessages.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/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/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/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 -1
- 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 +4 -1
- 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/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/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/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/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/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/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/core/index.ts +25 -1
- package/src/core/useChatListener.ts +0 -21
- package/src/hooks/message/useSendMessage.ts +12 -5
- package/src/hooks/useChatMessages.ts +0 -4
- package/src/hooks/useImageAttachment.ts +348 -0
- 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 +142 -89
- package/src/screens/chat-detail/ChatListLegend.tsx +9 -11
- 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/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 +47 -24
- package/src/screens/chat-detail/legend/messageTypes.tsx +13 -0
- package/src/screens/chat-detail/types.ts +5 -1
- 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/translation/resources/i18n.ts +22 -8
- package/src/types/attachment.ts +85 -0
- package/src/types/attachmentHandler.ts +31 -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/device.ts +73 -0
- package/src/utils/imageUrlOptimizer.ts +56 -0
- package/src/utils/imageUtils.ts +76 -0
- package/src/utils/resolveMessageType.ts +2 -0
- package/src/utils/ui.ts +19 -0
- package/src/utils/url.ts +1 -1
- 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 -244
- 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 -13
- 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 -304
- package/src/screens/chat-detail/messages/ChatMessageBubble.tsx +0 -23
- package/src/screens/chat-detail/messages/types.ts +0 -14
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { memo, useCallback } from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import { KContainer, KImage, KLabel } from '@droppii/libs';
|
|
4
|
+
import ChatImageDimens, {
|
|
5
|
+
CHAT_IMAGE_VIEW_SOURCE,
|
|
6
|
+
} from '../../../utils/chatImageDimens';
|
|
7
|
+
import { CHAT_BUBBLE_COLORS } from '../../../screens/chat-detail/constants';
|
|
8
|
+
import { messageStyles } from '../styles';
|
|
9
|
+
import type { BaseLegendMessageProps } from '../types';
|
|
10
|
+
|
|
11
|
+
const formatDuration = (durationMs: number): string => {
|
|
12
|
+
const totalSeconds = Math.floor(durationMs / 1000);
|
|
13
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
14
|
+
const seconds = totalSeconds % 60;
|
|
15
|
+
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const VideoMessage = memo(
|
|
19
|
+
({ message, onMediaPress }: BaseLegendMessageProps) => {
|
|
20
|
+
const videoElem = message?.videoElem;
|
|
21
|
+
const videoUrl = videoElem?.videoUrl;
|
|
22
|
+
const duration = videoElem?.duration;
|
|
23
|
+
const thumbnail = videoElem?.snapshotUrl;
|
|
24
|
+
|
|
25
|
+
const handlePress = useCallback(() => {
|
|
26
|
+
if (videoUrl && onMediaPress) {
|
|
27
|
+
onMediaPress([{ url: videoUrl, isVideo: true }], 0);
|
|
28
|
+
}
|
|
29
|
+
}, [videoUrl, onMediaPress]);
|
|
30
|
+
|
|
31
|
+
if (!videoUrl) {
|
|
32
|
+
return (
|
|
33
|
+
<KContainer.View style={messageStyles.wrapper}>
|
|
34
|
+
<KContainer.View
|
|
35
|
+
style={[messageStyles.bubble, messageStyles.videoPlaceholder]}
|
|
36
|
+
>
|
|
37
|
+
<KLabel.Text typo="TextSmNormal" color={CHAT_BUBBLE_COLORS.text}>
|
|
38
|
+
📹 [Video unavailable]
|
|
39
|
+
</KLabel.Text>
|
|
40
|
+
</KContainer.View>
|
|
41
|
+
</KContainer.View>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const dimen = ChatImageDimens.getDimensions(
|
|
46
|
+
CHAT_IMAGE_VIEW_SOURCE.MessageListThumbnail
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<KContainer.View style={messageStyles.wrapper}>
|
|
51
|
+
<KContainer.Touchable
|
|
52
|
+
onPress={handlePress}
|
|
53
|
+
style={[
|
|
54
|
+
styles.videoContainer,
|
|
55
|
+
{ width: dimen.width, height: dimen.height },
|
|
56
|
+
]}
|
|
57
|
+
>
|
|
58
|
+
{thumbnail ? (
|
|
59
|
+
<KImage.Base
|
|
60
|
+
uri={thumbnail}
|
|
61
|
+
width={dimen.width}
|
|
62
|
+
height={dimen.height}
|
|
63
|
+
resizeMode="cover"
|
|
64
|
+
/>
|
|
65
|
+
) : (
|
|
66
|
+
<KContainer.View style={styles.videoBg} />
|
|
67
|
+
)}
|
|
68
|
+
|
|
69
|
+
<KContainer.View style={styles.playOverlay} center>
|
|
70
|
+
<KImage.VectorIcons
|
|
71
|
+
name="play-circle"
|
|
72
|
+
provider="MaterialCommunityIcons"
|
|
73
|
+
size={48}
|
|
74
|
+
color="white"
|
|
75
|
+
/>
|
|
76
|
+
</KContainer.View>
|
|
77
|
+
|
|
78
|
+
{duration && (
|
|
79
|
+
<KContainer.View style={styles.durationBadge}>
|
|
80
|
+
<KLabel.Text typo="TextXsNormal" color="white">
|
|
81
|
+
{formatDuration(duration)}
|
|
82
|
+
</KLabel.Text>
|
|
83
|
+
</KContainer.View>
|
|
84
|
+
)}
|
|
85
|
+
</KContainer.Touchable>
|
|
86
|
+
</KContainer.View>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
VideoMessage.displayName = 'VideoMessage';
|
|
92
|
+
|
|
93
|
+
const styles = StyleSheet.create({
|
|
94
|
+
videoContainer: {
|
|
95
|
+
overflow: 'hidden',
|
|
96
|
+
borderRadius: 8,
|
|
97
|
+
backgroundColor: '#000',
|
|
98
|
+
},
|
|
99
|
+
videoBg: {
|
|
100
|
+
flex: 1,
|
|
101
|
+
backgroundColor: '#000',
|
|
102
|
+
},
|
|
103
|
+
playOverlay: {
|
|
104
|
+
position: 'absolute',
|
|
105
|
+
top: 0,
|
|
106
|
+
left: 0,
|
|
107
|
+
right: 0,
|
|
108
|
+
bottom: 0,
|
|
109
|
+
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
|
110
|
+
},
|
|
111
|
+
durationBadge: {
|
|
112
|
+
position: 'absolute',
|
|
113
|
+
bottom: 8,
|
|
114
|
+
right: 8,
|
|
115
|
+
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
116
|
+
paddingHorizontal: 6,
|
|
117
|
+
paddingVertical: 3,
|
|
118
|
+
borderRadius: 4,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Endpoints Configuration
|
|
3
|
+
*
|
|
4
|
+
* Centralized endpoint management for all API calls.
|
|
5
|
+
* Can be overridden per environment or feature flag.
|
|
6
|
+
*
|
|
7
|
+
* Note: imageUpload is a relative path because ReactNativeBlobUtil.fetch()
|
|
8
|
+
* is used for image uploads (not axios). The full URL is constructed
|
|
9
|
+
* in the imageUpload service using the base URL from environment/config.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export interface ApiEndpoints {
|
|
13
|
+
// Chat service (relative paths - used with axios baseURL)
|
|
14
|
+
urlMetadata: string;
|
|
15
|
+
// Image upload service (relative path - full URL constructed in imageUpload service)
|
|
16
|
+
imageUpload: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const DEFAULT_ENDPOINTS: ApiEndpoints = {
|
|
20
|
+
urlMetadata: '/chat-service/v1/utils/url-metadata',
|
|
21
|
+
imageUpload: '/uploader-service/v1/uploader/permanently',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
let endpoints: ApiEndpoints = { ...DEFAULT_ENDPOINTS };
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get a specific API endpoint
|
|
28
|
+
* @param key - Endpoint key
|
|
29
|
+
* @returns Full endpoint URL
|
|
30
|
+
*/
|
|
31
|
+
export const getApiEndpoint = <K extends keyof ApiEndpoints>(
|
|
32
|
+
key: K
|
|
33
|
+
): ApiEndpoints[K] => {
|
|
34
|
+
return endpoints[key];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Set a specific API endpoint (useful for testing/override)
|
|
39
|
+
* @param key - Endpoint key
|
|
40
|
+
* @param value - New endpoint URL
|
|
41
|
+
*/
|
|
42
|
+
export const setApiEndpoint = <K extends keyof ApiEndpoints>(
|
|
43
|
+
key: K,
|
|
44
|
+
value: ApiEndpoints[K]
|
|
45
|
+
) => {
|
|
46
|
+
endpoints[key] = value;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Set all endpoints at once
|
|
51
|
+
* @param newEndpoints - New endpoints object
|
|
52
|
+
*/
|
|
53
|
+
export const setAllApiEndpoints = (newEndpoints: Partial<ApiEndpoints>) => {
|
|
54
|
+
endpoints = {
|
|
55
|
+
...endpoints,
|
|
56
|
+
...newEndpoints,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Reset to default endpoints
|
|
62
|
+
*/
|
|
63
|
+
export const resetApiEndpoints = () => {
|
|
64
|
+
endpoints = { ...DEFAULT_ENDPOINTS };
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get all endpoints (returns copy)
|
|
69
|
+
*/
|
|
70
|
+
export const getAllApiEndpoints = (): ApiEndpoints => ({
|
|
71
|
+
...endpoints,
|
|
72
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for attachment sending priority order
|
|
3
|
+
* AC2: Send mixed media with configurable priority
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type AttachmentType = 'image' | 'video' | 'file' | 'text';
|
|
7
|
+
|
|
8
|
+
export interface AttachmentPriorityConfig {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
order: AttachmentType[];
|
|
11
|
+
mergeStrategy: {
|
|
12
|
+
images: 'merge' | 'individual';
|
|
13
|
+
videos: 'merge' | 'individual';
|
|
14
|
+
files: 'merge' | 'individual';
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Default AC2 configuration
|
|
19
|
+
export const DEFAULT_ATTACHMENT_PRIORITY: AttachmentPriorityConfig = {
|
|
20
|
+
enabled: true,
|
|
21
|
+
order: ['image', 'video', 'file', 'text'],
|
|
22
|
+
mergeStrategy: {
|
|
23
|
+
images: 'merge', // Multiple images merged into one message
|
|
24
|
+
videos: 'individual', // Videos always sent individually (never merged)
|
|
25
|
+
files: 'merge', // Multiple files merged into one message
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Alternative configurations
|
|
30
|
+
export const ATTACHMENT_PRIORITY_PRESETS = {
|
|
31
|
+
// Send everything individually (no merging)
|
|
32
|
+
INDIVIDUAL: {
|
|
33
|
+
enabled: true,
|
|
34
|
+
order: ['image', 'video', 'file', 'text'],
|
|
35
|
+
mergeStrategy: {
|
|
36
|
+
images: 'individual',
|
|
37
|
+
videos: 'individual',
|
|
38
|
+
files: 'individual',
|
|
39
|
+
},
|
|
40
|
+
} as AttachmentPriorityConfig,
|
|
41
|
+
|
|
42
|
+
// Send videos first, then everything else
|
|
43
|
+
VIDEOS_FIRST: {
|
|
44
|
+
enabled: true,
|
|
45
|
+
order: ['video', 'image', 'file', 'text'],
|
|
46
|
+
mergeStrategy: {
|
|
47
|
+
images: 'merge',
|
|
48
|
+
videos: 'individual',
|
|
49
|
+
files: 'merge',
|
|
50
|
+
},
|
|
51
|
+
} as AttachmentPriorityConfig,
|
|
52
|
+
|
|
53
|
+
// Group by type - all media first, then text
|
|
54
|
+
MEDIA_FIRST: {
|
|
55
|
+
enabled: true,
|
|
56
|
+
order: ['image', 'video', 'file', 'text'],
|
|
57
|
+
mergeStrategy: {
|
|
58
|
+
images: 'merge',
|
|
59
|
+
videos: 'individual',
|
|
60
|
+
files: 'merge',
|
|
61
|
+
},
|
|
62
|
+
} as AttachmentPriorityConfig,
|
|
63
|
+
|
|
64
|
+
// Disabled - use original behavior
|
|
65
|
+
DISABLED: {
|
|
66
|
+
enabled: false,
|
|
67
|
+
order: [],
|
|
68
|
+
mergeStrategy: {
|
|
69
|
+
images: 'merge',
|
|
70
|
+
videos: 'individual',
|
|
71
|
+
files: 'merge',
|
|
72
|
+
},
|
|
73
|
+
} as AttachmentPriorityConfig,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get attachment priority config
|
|
78
|
+
* Can be overridden via environment variable or per-user settings
|
|
79
|
+
*/
|
|
80
|
+
export function getAttachmentPriorityConfig(): AttachmentPriorityConfig {
|
|
81
|
+
// Can be extended to read from environment or user preferences
|
|
82
|
+
return DEFAULT_ATTACHMENT_PRIORITY;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Validate and normalize priority order
|
|
87
|
+
*/
|
|
88
|
+
export function validatePriorityOrder(
|
|
89
|
+
order: AttachmentType[]
|
|
90
|
+
): AttachmentType[] {
|
|
91
|
+
const validTypes: AttachmentType[] = ['image', 'video', 'file', 'text'];
|
|
92
|
+
return order.filter((type) => validTypes.includes(type));
|
|
93
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized Configuration
|
|
3
|
+
*
|
|
4
|
+
* Manages all API configuration in one place. Different services may use
|
|
5
|
+
* different protocols (axios, native HTTP), but they should all derive
|
|
6
|
+
* from the same base URL configuration.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface AppConfig {
|
|
10
|
+
apiBaseUrl: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let config: AppConfig = {
|
|
14
|
+
apiBaseUrl: '',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Initialize the base URL configuration
|
|
19
|
+
* This should be called during app startup before any API calls
|
|
20
|
+
*
|
|
21
|
+
* @param apiBaseUrl - The base URL for all API services (e.g., 'https://api.example.com')
|
|
22
|
+
*/
|
|
23
|
+
export const initBaseUrl = (apiBaseUrl: string): void => {
|
|
24
|
+
if (!apiBaseUrl) {
|
|
25
|
+
if (__DEV__)
|
|
26
|
+
console.warn('[Configuration] Initializing with empty apiBaseUrl');
|
|
27
|
+
}
|
|
28
|
+
config.apiBaseUrl = apiBaseUrl;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the configured base URL
|
|
33
|
+
*/
|
|
34
|
+
export const getBaseUrl = (): string => {
|
|
35
|
+
return config.apiBaseUrl;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Reset configuration (useful for testing)
|
|
40
|
+
*/
|
|
41
|
+
export const resetBaseUrl = (): void => {
|
|
42
|
+
config = { apiBaseUrl: '' };
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Check if base URL is configured
|
|
47
|
+
*/
|
|
48
|
+
export const isBaseUrlConfigured = (): boolean => {
|
|
49
|
+
return !!config.apiBaseUrl;
|
|
50
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library Configuration
|
|
3
|
+
* Provides convenient access to library configuration values
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { getBaseUrl } from './configuration';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Library Config object for easy access to configuration values
|
|
10
|
+
*/
|
|
11
|
+
export const Config = {
|
|
12
|
+
/**
|
|
13
|
+
* Get the configured API base URL
|
|
14
|
+
* @returns The base URL (e.g., 'https://api.example.com')
|
|
15
|
+
*/
|
|
16
|
+
get BASE_URL(): string {
|
|
17
|
+
return getBaseUrl();
|
|
18
|
+
},
|
|
19
|
+
};
|
package/src/core/index.ts
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
import OpenIMSDK from '@droppii/openim-rn-client-sdk';
|
|
2
|
+
import type { InitOptions } from '@droppii/openim-rn-client-sdk';
|
|
3
|
+
import { initBaseUrl } from '../config/configuration';
|
|
2
4
|
import { useUserListener } from './useUserListener';
|
|
3
5
|
import { useChatListener } from './useChatListener';
|
|
4
6
|
|
|
5
|
-
export
|
|
7
|
+
export interface InitChatSdkOptions extends InitOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Base URL for API services (image uploads, etc.)
|
|
10
|
+
* Will be set as the centralized configuration
|
|
11
|
+
*/
|
|
12
|
+
apiBaseUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the chat SDK with optional base URL
|
|
17
|
+
* @param options - SDK initialization options + apiBaseUrl for centralized config
|
|
18
|
+
*/
|
|
19
|
+
export const initChatSdk = (options: InitChatSdkOptions) => {
|
|
20
|
+
const { apiBaseUrl, ...sdkOptions } = options;
|
|
21
|
+
|
|
22
|
+
// Initialize OpenIM SDK
|
|
23
|
+
OpenIMSDK.initSDK(sdkOptions);
|
|
24
|
+
|
|
25
|
+
// Initialize centralized base URL config for all services
|
|
26
|
+
if (apiBaseUrl) {
|
|
27
|
+
initBaseUrl(apiBaseUrl);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
6
30
|
|
|
7
31
|
export const useChatSdk = () => {
|
|
8
32
|
useUserListener();
|
|
@@ -2,21 +2,11 @@ import OpenIMSDK, {
|
|
|
2
2
|
OpenIMEvent,
|
|
3
3
|
type ConversationItem,
|
|
4
4
|
type GroupMemberItem,
|
|
5
|
-
type MessageItem,
|
|
6
|
-
type RevokedInfo,
|
|
7
5
|
} from '@droppii/openim-rn-client-sdk';
|
|
8
6
|
import { useCallback, useEffect } from 'react';
|
|
9
7
|
import { useConversationStore } from '../store/conversation';
|
|
10
8
|
|
|
11
9
|
export const useChatListener = () => {
|
|
12
|
-
const onRecvNewMessages = useCallback((messages: MessageItem[]) => {
|
|
13
|
-
console.log('onRecvNewMessages', messages);
|
|
14
|
-
}, []);
|
|
15
|
-
|
|
16
|
-
const onNewRecvMessageRevoked = useCallback((revokedInfo: RevokedInfo) => {
|
|
17
|
-
console.log('onNewRecvMessageRevoked', revokedInfo);
|
|
18
|
-
}, []);
|
|
19
|
-
|
|
20
10
|
const onConversationChanged = useCallback(
|
|
21
11
|
(conversations: ConversationItem[]) => {
|
|
22
12
|
console.log('onConversationChanged', conversations);
|
|
@@ -41,10 +31,6 @@ export const useChatListener = () => {
|
|
|
41
31
|
}, []);
|
|
42
32
|
|
|
43
33
|
useEffect(() => {
|
|
44
|
-
// Message
|
|
45
|
-
OpenIMSDK.on(OpenIMEvent.OnRecvNewMessages, onRecvNewMessages);
|
|
46
|
-
OpenIMSDK.on(OpenIMEvent.OnNewRecvMessageRevoked, onNewRecvMessageRevoked);
|
|
47
|
-
|
|
48
34
|
// Conversation
|
|
49
35
|
OpenIMSDK.on(OpenIMEvent.OnConversationChanged, onConversationChanged);
|
|
50
36
|
OpenIMSDK.on(OpenIMEvent.OnNewConversation, onNewConversation);
|
|
@@ -54,13 +40,6 @@ export const useChatListener = () => {
|
|
|
54
40
|
OpenIMSDK.on(OpenIMEvent.OnGroupMemberDeleted, onGroupMemberDeleted);
|
|
55
41
|
|
|
56
42
|
return () => {
|
|
57
|
-
// Message
|
|
58
|
-
OpenIMSDK.off(OpenIMEvent.OnRecvNewMessages, onRecvNewMessages);
|
|
59
|
-
OpenIMSDK.off(
|
|
60
|
-
OpenIMEvent.OnNewRecvMessageRevoked,
|
|
61
|
-
onNewRecvMessageRevoked
|
|
62
|
-
);
|
|
63
|
-
|
|
64
43
|
// Conversation
|
|
65
44
|
OpenIMSDK.off(OpenIMEvent.OnConversationChanged, onConversationChanged);
|
|
66
45
|
OpenIMSDK.off(OpenIMEvent.OnNewConversation, onNewConversation);
|
|
@@ -38,15 +38,22 @@ export const useSendMessage = () => {
|
|
|
38
38
|
if (!file) continue;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
// Allow empty text if urlMetadata (preview link) is present
|
|
42
|
+
const hasText = !!plainText && plainText.trim() !== '';
|
|
43
|
+
const hasPreview = !!urlMetadata?.url;
|
|
44
|
+
|
|
45
|
+
if (hasText || hasPreview) {
|
|
46
|
+
const urls = hasText ? extractUrls(plainText) : [];
|
|
47
|
+
const isUrlMessage = urls.length > 0 || hasPreview;
|
|
44
48
|
let message: MessageItem | null = null;
|
|
49
|
+
|
|
45
50
|
if (isUrlMessage) {
|
|
46
|
-
message
|
|
47
|
-
|
|
51
|
+
// Create URL message even with empty text if preview exists
|
|
52
|
+
message = await createUrlTextMessage(plainText || '', urls);
|
|
53
|
+
} else if (hasText) {
|
|
48
54
|
message = await createTextMessage(plainText);
|
|
49
55
|
}
|
|
56
|
+
|
|
50
57
|
if (!message) return;
|
|
51
58
|
messageList.push(message);
|
|
52
59
|
}
|
|
@@ -175,15 +175,11 @@ export function useChatMessages({
|
|
|
175
175
|
|
|
176
176
|
const handleNewMessages = (incoming: MessageItem[]) =>
|
|
177
177
|
appendIncomingMessages(incoming);
|
|
178
|
-
const handleNewMessage = (incoming: MessageItem) =>
|
|
179
|
-
appendIncomingMessages([incoming]);
|
|
180
178
|
|
|
181
179
|
OpenIMSDK.on(OpenIMEvent.OnRecvNewMessages, handleNewMessages);
|
|
182
|
-
OpenIMSDK.on(OpenIMEvent.OnRecvNewMessage, handleNewMessage);
|
|
183
180
|
|
|
184
181
|
return () => {
|
|
185
182
|
OpenIMSDK.off(OpenIMEvent.OnRecvNewMessages, handleNewMessages);
|
|
186
|
-
OpenIMSDK.off(OpenIMEvent.OnRecvNewMessage, handleNewMessage);
|
|
187
183
|
};
|
|
188
184
|
}, [appendIncomingMessages, conversationId, enabled]);
|
|
189
185
|
|