@azure/communication-react 1.14.1-alpha-202403290012 → 1.15.0-alpha-202404030013
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/dist/communication-react.d.ts +125 -218
- package/dist/dist-cjs/communication-react/{RichTextSendBoxWrapper-CH6WvEGZ.js → RichTextSendBoxWrapper-B8qxZi1I.js} +2 -2
- package/dist/dist-cjs/communication-react/{RichTextSendBoxWrapper-CH6WvEGZ.js.map → RichTextSendBoxWrapper-B8qxZi1I.js.map} +1 -1
- package/dist/dist-cjs/communication-react/{index-qxnuqL7s.js → index-aOBAWcNI.js} +1018 -874
- package/dist/dist-cjs/communication-react/index-aOBAWcNI.js.map +1 -0
- package/dist/dist-cjs/communication-react/index.js +2 -1
- package/dist/dist-cjs/communication-react/index.js.map +1 -1
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallClientState.d.ts +4 -4
- package/dist/dist-esm/calling-stateful-client/src/CallClientState.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallContext.d.ts +4 -0
- package/dist/dist-esm/calling-stateful-client/src/CallContext.js +6 -1
- package/dist/dist-esm/calling-stateful-client/src/CallContext.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/ReactionSubscriber.d.ts +1 -1
- package/dist/dist-esm/calling-stateful-client/src/ReactionSubscriber.js +2 -2
- package/dist/dist-esm/calling-stateful-client/src/ReactionSubscriber.js.map +1 -1
- package/dist/dist-esm/chat-component-bindings/src/messageThreadSelector.js +20 -20
- package/dist/dist-esm/chat-component-bindings/src/messageThreadSelector.js.map +1 -1
- package/dist/dist-esm/communication-react/src/index.d.ts +2 -2
- package/dist/dist-esm/communication-react/src/index.js +2 -0
- package/dist/dist-esm/communication-react/src/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/AttachmentCard.d.ts +0 -4
- package/dist/dist-esm/react-components/src/components/AttachmentCard.js +4 -1
- package/dist/dist-esm/react-components/src/components/AttachmentCard.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/AttachmentUploadCards.d.ts +5 -36
- package/dist/dist-esm/react-components/src/components/AttachmentUploadCards.js +17 -26
- package/dist/dist-esm/react-components/src/components/AttachmentUploadCards.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsEditBox.js +6 -10
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsEditBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsRichTextEditBox.js +2 -2
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsRichTextEditBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/EndCallButton.d.ts +10 -1
- package/dist/dist-esm/react-components/src/components/EndCallButton.js +93 -51
- package/dist/dist-esm/react-components/src/components/EndCallButton.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ReactionButton.d.ts +2 -2
- package/dist/dist-esm/react-components/src/components/ReactionButton.js +12 -15
- package/dist/dist-esm/react-components/src/components/ReactionButton.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.d.ts +2 -2
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.js +6 -6
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.d.ts +6 -6
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js +25 -25
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/SendBox.d.ts +6 -6
- package/dist/dist-esm/react-components/src/components/SendBox.js +18 -18
- package/dist/dist-esm/react-components/src/components/SendBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/VideoEffects/VideoBackgroundEffectsPicker.d.ts +8 -0
- package/dist/dist-esm/react-components/src/components/VideoEffects/VideoBackgroundEffectsPicker.js +1 -1
- package/dist/dist-esm/react-components/src/components/VideoEffects/VideoBackgroundEffectsPicker.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/VideoGallery/ParticipantVideoTileOverlay.js +8 -4
- package/dist/dist-esm/react-components/src/components/VideoGallery/ParticipantVideoTileOverlay.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/VideoGallery/RemoteContentShareReactionOverlay.js +4 -4
- package/dist/dist-esm/react-components/src/components/VideoGallery/RemoteContentShareReactionOverlay.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/VideoGallery/utils/videoGalleryLayoutUtils.d.ts +4 -0
- package/dist/dist-esm/react-components/src/components/VideoGallery/utils/videoGalleryLayoutUtils.js +22 -1
- package/dist/dist-esm/react-components/src/components/VideoGallery/utils/videoGalleryLayoutUtils.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/index.d.ts +1 -2
- package/dist/dist-esm/react-components/src/components/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/ReactionButton.styles.d.ts +3 -3
- package/dist/dist-esm/react-components/src/components/styles/ReactionButton.styles.js +16 -9
- package/dist/dist-esm/react-components/src/components/styles/ReactionButton.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/ReactionOverlay.style.d.ts +2 -1
- package/dist/dist-esm/react-components/src/components/styles/ReactionOverlay.style.js +10 -12
- package/dist/dist-esm/react-components/src/components/styles/ReactionOverlay.style.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/SendBox.styles.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/styles/SendBox.styles.js +2 -2
- package/dist/dist-esm/react-components/src/components/styles/SendBox.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.d.ts +1 -0
- package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.js +3 -1
- package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentAsEditBoxUtils.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentAsEditBoxUtils.js +2 -2
- package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentAsEditBoxUtils.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentUtils.js +4 -3
- package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentUtils.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.d.ts +3 -3
- package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js +7 -7
- package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/common.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/utils/common.js +1 -1
- package/dist/dist-esm/react-components/src/components/utils/common.js.map +1 -1
- package/dist/dist-esm/react-components/src/localization/LocalizationProvider.js.map +1 -1
- package/dist/dist-esm/react-components/src/localization/locales/en-US/strings.json +3 -1
- package/dist/dist-esm/react-components/src/types/Attachment.d.ts +22 -95
- package/dist/dist-esm/react-components/src/types/Attachment.js.map +1 -1
- package/dist/dist-esm/react-components/src/types/ChatMessage.d.ts +2 -2
- package/dist/dist-esm/react-components/src/types/ChatMessage.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/Strings.d.ts +24 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/Strings.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallArrangement.js +3 -4
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallArrangement.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/Prompt.js +0 -7
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/Prompt.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/buttons/EndCall.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/buttons/EndCall.js +66 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/buttons/EndCall.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/CallPage.js +1 -3
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/CallPage.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.d.ts +2 -2
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.js +3 -3
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.d.ts +8 -8
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js +21 -21
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.d.ts +8 -8
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.d.ts +8 -8
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js +15 -15
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/state/CallWithChatAdapterState.d.ts +3 -3
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/state/CallWithChatAdapterState.js +2 -2
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/state/CallWithChatAdapterState.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatComposite.d.ts +2 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatComposite.js +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatComposite.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.d.ts +2 -33
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js +26 -18
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/Strings.d.ts +2 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/Strings.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationAttachmentUploadAdapter.d.ts +47 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationAttachmentUploadAdapter.js +179 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationAttachmentUploadAdapter.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.d.ts +9 -9
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js +30 -30
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.d.ts +5 -5
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapterProvider.d.ts +2 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapterProvider.js +8 -8
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapterProvider.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/{FileUpload.d.ts → AttachmentUpload.d.ts} +11 -11
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/{FileUpload.js → AttachmentUpload.js} +13 -13
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.d.ts +38 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/{FileUploadButton.js → AttachmentUploadButton.js} +14 -12
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.d.ts +4 -4
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.js +2 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.d.ts +2 -3
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/attachmentUploadsSelector.d.ts +29 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/attachmentUploadsSelector.js +12 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/attachmentUploadsSelector.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.d.ts +2 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.js +2 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/ControlBar/CommonCallControlBar.js +26 -9
- package/dist/dist-esm/react-composites/src/composites/common/ControlBar/CommonCallControlBar.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/MoreDrawer.js +6 -2
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/MoreDrawer.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/SendBox.js +5 -5
- package/dist/dist-esm/react-composites/src/composites/common/SendBox.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/types/CommonCallControlOptions.d.ts +8 -2
- package/dist/dist-esm/react-composites/src/composites/common/types/CommonCallControlOptions.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/utils.d.ts +4 -0
- package/dist/dist-esm/react-composites/src/composites/common/utils.js +6 -0
- package/dist/dist-esm/react-composites/src/composites/common/utils.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/ar-SA/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/cs-CZ/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/de-DE/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/en-GB/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/en-US/strings.json +7 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/es-ES/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/fi-FI/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/fr-FR/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/he-IL/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/it-IT/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/ja-JP/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/ko-KR/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/nb-NO/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/nl-NL/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/pl-PL/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/pt-BR/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/ru-RU/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/sv-SE/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/tr-TR/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/zh-CN/strings.json +1 -1
- package/dist/dist-esm/react-composites/src/composites/localization/locales/zh-TW/strings.json +1 -1
- package/package.json +7 -7
- package/dist/dist-cjs/communication-react/index-qxnuqL7s.js.map +0 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationFileUploadAdapter.d.ts +0 -48
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationFileUploadAdapter.js +0 -160
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationFileUploadAdapter.js.map +0 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/FileUpload.js.map +0 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/FileUploadButton.d.ts +0 -36
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/FileUploadButton.js.map +0 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/fileUploadsSelector.d.ts +0 -27
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/fileUploadsSelector.js +0 -12
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/fileUploadsSelector.js.map +0 -1
@@ -0,0 +1,47 @@
|
|
1
|
+
import { AttachmentUploadManager, AttachmentMetadata } from "../../../../../react-components/src";
|
2
|
+
import { FileSharingMetadata } from '../file-sharing';
|
3
|
+
import { ChatContext } from './AzureCommunicationChatAdapter';
|
4
|
+
/**
|
5
|
+
* A record containing {@link AttachmentMetadata} mapped to unique ids.
|
6
|
+
* @beta
|
7
|
+
*/
|
8
|
+
export type AttachmentUploadsUiState = Record<string, AttachmentMetadata>;
|
9
|
+
/**
|
10
|
+
* @beta
|
11
|
+
*/
|
12
|
+
export interface AttachmentUploadAdapter {
|
13
|
+
registerActiveUploads: (files: File[]) => AttachmentUploadManager[];
|
14
|
+
registerCompletedUploads: (metadata: AttachmentMetadata[]) => AttachmentUploadManager[];
|
15
|
+
clearUploads: () => void;
|
16
|
+
cancelUpload: (id: string) => void;
|
17
|
+
updateUploadProgress: (id: string, progress: number) => void;
|
18
|
+
updateUploadStatusMessage: (id: string, errorMessage: string) => void;
|
19
|
+
updateUploadMetadata: (id: string, metadata: AttachmentMetadata) => void;
|
20
|
+
}
|
21
|
+
/**
|
22
|
+
* @internal
|
23
|
+
*/
|
24
|
+
export declare class AzureCommunicationAttachmentUploadAdapter implements AttachmentUploadAdapter {
|
25
|
+
private context;
|
26
|
+
private attachmentUploads;
|
27
|
+
constructor(chatContext: ChatContext);
|
28
|
+
private findAttachmentUpload;
|
29
|
+
private deleteAttachmentUploads;
|
30
|
+
private deleteErroneousAttachmentUploads;
|
31
|
+
private registerAttachmentUploads;
|
32
|
+
registerActiveUploads(files: File[]): AttachmentUploadManager[];
|
33
|
+
registerCompletedUploads(metadata: AttachmentMetadata[]): AttachmentUploadManager[];
|
34
|
+
clearUploads(): void;
|
35
|
+
cancelUpload(id: string): void;
|
36
|
+
updateUploadProgress(id: string, progress: number): void;
|
37
|
+
updateUploadStatusMessage(id: string, errorMessage: string): void;
|
38
|
+
updateUploadMetadata(id: string, metadata: AttachmentMetadata): void;
|
39
|
+
private subscribeAllEvents;
|
40
|
+
private unsubscribeAllEvents;
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* @param attachmentUploadUiState {@link AttachmentUploadsUiState}
|
44
|
+
* @private
|
45
|
+
*/
|
46
|
+
export declare const convertAttachmentUploadsUiStateToMessageMetadata: (attachmentUploads?: AttachmentUploadsUiState) => FileSharingMetadata | undefined;
|
47
|
+
//# sourceMappingURL=AzureCommunicationAttachmentUploadAdapter.d.ts.map
|
@@ -0,0 +1,179 @@
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
2
|
+
// Licensed under the MIT License.
|
3
|
+
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
4
|
+
import { produce } from 'immer';
|
5
|
+
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
6
|
+
import { AttachmentUpload } from '../file-sharing';
|
7
|
+
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
8
|
+
/**
|
9
|
+
* @internal
|
10
|
+
*/
|
11
|
+
class AttachmentUploadContext {
|
12
|
+
constructor(chatContext) {
|
13
|
+
this.chatContext = chatContext;
|
14
|
+
}
|
15
|
+
getAttachmentUploads() {
|
16
|
+
return this.chatContext.getState().attachmentUploads;
|
17
|
+
}
|
18
|
+
addAttachmentUploads(attachmentUploads) {
|
19
|
+
const attachmentUploadsMap = convertObservableAttachmentUploadToAttachmentUploadsUiState(attachmentUploads);
|
20
|
+
this.chatContext.setState(produce(this.chatContext.getState(), (draft) => {
|
21
|
+
draft.attachmentUploads = draft.attachmentUploads || {};
|
22
|
+
draft.attachmentUploads = Object.assign(Object.assign({}, draft.attachmentUploads), attachmentUploadsMap);
|
23
|
+
}));
|
24
|
+
}
|
25
|
+
clearUploads() {
|
26
|
+
this.chatContext.setState(produce(this.chatContext.getState(), (draft) => {
|
27
|
+
draft.attachmentUploads = {};
|
28
|
+
}));
|
29
|
+
}
|
30
|
+
updateAttachmentUpload(id, data) {
|
31
|
+
this.chatContext.setState(produce(this.chatContext.getState(), (draft) => {
|
32
|
+
var _a, _b, _c, _d;
|
33
|
+
if ((_a = draft.attachmentUploads) === null || _a === void 0 ? void 0 : _a[id]) {
|
34
|
+
draft.attachmentUploads[(_b = data.id) !== null && _b !== void 0 ? _b : id] = Object.assign(Object.assign({}, (_c = draft.attachmentUploads) === null || _c === void 0 ? void 0 : _c[id]), data);
|
35
|
+
if (data.id) {
|
36
|
+
(_d = draft.attachmentUploads) === null || _d === void 0 ? true : delete _d[id];
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}));
|
40
|
+
}
|
41
|
+
deleteAttachmentUploads(ids) {
|
42
|
+
this.chatContext.setState(produce(this.chatContext.getState(), (draft) => {
|
43
|
+
ids.forEach((id) => {
|
44
|
+
var _a;
|
45
|
+
const keys = Object.keys((_a = draft === null || draft === void 0 ? void 0 : draft.attachmentUploads) !== null && _a !== void 0 ? _a : []).filter((rawID) => { var _a; return ((_a = draft.attachmentUploads) === null || _a === void 0 ? void 0 : _a[rawID].id) === id; });
|
46
|
+
keys.forEach((key) => {
|
47
|
+
var _a;
|
48
|
+
(_a = draft.attachmentUploads) === null || _a === void 0 ? true : delete _a[key];
|
49
|
+
});
|
50
|
+
});
|
51
|
+
}));
|
52
|
+
}
|
53
|
+
}
|
54
|
+
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
55
|
+
/**
|
56
|
+
* @internal
|
57
|
+
*/
|
58
|
+
export class AzureCommunicationAttachmentUploadAdapter {
|
59
|
+
constructor(chatContext) {
|
60
|
+
this.attachmentUploads = [];
|
61
|
+
this.context = new AttachmentUploadContext(chatContext);
|
62
|
+
}
|
63
|
+
findAttachmentUpload(id) {
|
64
|
+
return this.attachmentUploads.find((attachmentUpload) => attachmentUpload.id === id);
|
65
|
+
}
|
66
|
+
deleteAttachmentUploads(ids) {
|
67
|
+
this.attachmentUploads = this.attachmentUploads.filter((attachmentUpload) => !ids.includes(attachmentUpload.id));
|
68
|
+
this.context.deleteAttachmentUploads(ids);
|
69
|
+
}
|
70
|
+
deleteErroneousAttachmentUploads() {
|
71
|
+
const attachmentUploads = this.context.getAttachmentUploads() || {};
|
72
|
+
const ids = Object.values(attachmentUploads)
|
73
|
+
.filter((item) => item.uploadError)
|
74
|
+
.map((item) => item.id);
|
75
|
+
ids.forEach((id) => {
|
76
|
+
const attachmentUpload = this.findAttachmentUpload(id);
|
77
|
+
this.unsubscribeAllEvents(attachmentUpload);
|
78
|
+
});
|
79
|
+
this.deleteAttachmentUploads(ids);
|
80
|
+
}
|
81
|
+
registerAttachmentUploads(files) {
|
82
|
+
this.deleteErroneousAttachmentUploads();
|
83
|
+
const attachmentUploads = [];
|
84
|
+
files.forEach((file) => attachmentUploads.push(new AttachmentUpload(file)));
|
85
|
+
attachmentUploads.forEach((attachmentUpload) => this.subscribeAllEvents(attachmentUpload));
|
86
|
+
this.attachmentUploads = this.attachmentUploads.concat(attachmentUploads);
|
87
|
+
this.context.addAttachmentUploads(attachmentUploads);
|
88
|
+
return attachmentUploads;
|
89
|
+
}
|
90
|
+
registerActiveUploads(files) {
|
91
|
+
return this.registerAttachmentUploads(files);
|
92
|
+
}
|
93
|
+
registerCompletedUploads(metadata) {
|
94
|
+
return this.registerAttachmentUploads(metadata);
|
95
|
+
}
|
96
|
+
clearUploads() {
|
97
|
+
this.context.clearUploads();
|
98
|
+
this.attachmentUploads.forEach((attachmentUpload) => this.unsubscribeAllEvents(attachmentUpload));
|
99
|
+
this.attachmentUploads = [];
|
100
|
+
}
|
101
|
+
cancelUpload(id) {
|
102
|
+
this.deleteErroneousAttachmentUploads();
|
103
|
+
const attachmentUpload = this.findAttachmentUpload(id);
|
104
|
+
this.unsubscribeAllEvents(attachmentUpload);
|
105
|
+
this.deleteAttachmentUploads([id]);
|
106
|
+
}
|
107
|
+
updateUploadProgress(id, progress) {
|
108
|
+
this.context.updateAttachmentUpload(id, { progress });
|
109
|
+
}
|
110
|
+
updateUploadStatusMessage(id, errorMessage) {
|
111
|
+
this.context.updateAttachmentUpload(id, {
|
112
|
+
uploadError: {
|
113
|
+
message: errorMessage,
|
114
|
+
timestamp: Date.now()
|
115
|
+
}
|
116
|
+
});
|
117
|
+
}
|
118
|
+
updateUploadMetadata(id, metadata) {
|
119
|
+
this.context.updateAttachmentUpload(id, {
|
120
|
+
progress: 1,
|
121
|
+
id: metadata.id,
|
122
|
+
name: metadata.name,
|
123
|
+
url: metadata.url,
|
124
|
+
extension: metadata.extension
|
125
|
+
});
|
126
|
+
}
|
127
|
+
subscribeAllEvents(attachmentUpload) {
|
128
|
+
attachmentUpload.on('uploadProgressChange', this.updateUploadProgress.bind(this));
|
129
|
+
attachmentUpload.on('uploadComplete', this.updateUploadMetadata.bind(this));
|
130
|
+
attachmentUpload.on('uploadFail', this.updateUploadStatusMessage.bind(this));
|
131
|
+
}
|
132
|
+
unsubscribeAllEvents(attachmentUpload) {
|
133
|
+
attachmentUpload === null || attachmentUpload === void 0 ? void 0 : attachmentUpload.off('uploadProgressChange', this.updateUploadProgress.bind(this));
|
134
|
+
attachmentUpload === null || attachmentUpload === void 0 ? void 0 : attachmentUpload.off('uploadComplete', this.updateUploadMetadata.bind(this));
|
135
|
+
attachmentUpload === null || attachmentUpload === void 0 ? void 0 : attachmentUpload.off('uploadFail', this.updateUploadStatusMessage.bind(this));
|
136
|
+
}
|
137
|
+
}
|
138
|
+
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
139
|
+
/**
|
140
|
+
* @param attachmentUploadUiState {@link AttachmentUploadsUiState}
|
141
|
+
* @private
|
142
|
+
*/
|
143
|
+
export const convertAttachmentUploadsUiStateToMessageMetadata = (attachmentUploads) => {
|
144
|
+
if (attachmentUploads) {
|
145
|
+
const attachmentMetadata = [];
|
146
|
+
Object.keys(attachmentUploads).forEach((key) => {
|
147
|
+
const attachment = attachmentUploads[key];
|
148
|
+
if (attachment && !attachment.uploadError) {
|
149
|
+
attachmentMetadata.push({
|
150
|
+
id: attachment.id,
|
151
|
+
name: attachment.name,
|
152
|
+
extension: attachment.extension,
|
153
|
+
url: attachment.url,
|
154
|
+
progress: attachment.progress
|
155
|
+
});
|
156
|
+
}
|
157
|
+
});
|
158
|
+
if (attachmentMetadata.length > 0) {
|
159
|
+
return { fileSharingMetadata: JSON.stringify(attachmentMetadata) };
|
160
|
+
}
|
161
|
+
}
|
162
|
+
return undefined;
|
163
|
+
};
|
164
|
+
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
165
|
+
/**
|
166
|
+
* @private
|
167
|
+
*/
|
168
|
+
const convertObservableAttachmentUploadToAttachmentUploadsUiState = (attachmentUploads) => {
|
169
|
+
return attachmentUploads.reduce((map, attachmentUpload) => {
|
170
|
+
map[attachmentUpload.id] = {
|
171
|
+
id: attachmentUpload.id,
|
172
|
+
name: attachmentUpload.name,
|
173
|
+
progress: 0,
|
174
|
+
extension: attachmentUpload.name.split('.').pop() || ''
|
175
|
+
};
|
176
|
+
return map;
|
177
|
+
}, {});
|
178
|
+
};
|
179
|
+
//# sourceMappingURL=AzureCommunicationAttachmentUploadAdapter.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AzureCommunicationAttachmentUploadAdapter.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/adapter/AzureCommunicationAttachmentUploadAdapter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,qGAAqG;AACrG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,qGAAqG;AACrG,OAAO,EAAuB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAyBxE,qGAAqG;AACrG;;GAEG;AACH,MAAM,uBAAuB;IAG3B,YAAY,WAAwB;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEM,oBAAoB;QACzB,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,iBAAiB,CAAC;IACvD,CAAC;IAEM,oBAAoB,CAAC,iBAAqC;QAC/D,MAAM,oBAAoB,GAAG,2DAA2D,CAAC,iBAAiB,CAAC,CAAC;QAC5G,IAAI,CAAC,WAAW,CAAC,QAAQ,CACvB,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE;YAC7C,KAAK,CAAC,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC;YACxD,KAAK,CAAC,iBAAiB,mCAAQ,KAAK,CAAC,iBAAiB,GAAK,oBAAoB,CAAE,CAAC;QACpF,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;IAEM,YAAY;QACjB,IAAI,CAAC,WAAW,CAAC,Q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,EAAE,CAAC;QACrE,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,qGAAqG;AACrG;;GAEG;AACH,MAAM,2DAA2D,GAAG,CAClE,iBAAqC,EACX,EAAE;IAC5B,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAA6B,EAAE,gBAAgB,EAAE,EAAE;QAClF,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC,GAAG;YACzB,EAAE,EAAE,gBAAgB,CAAC,EAAE;YACvB,IAAI,EAAE,gBAAgB,CAAC,IAAI;YAC3B,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE;SACxD,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AttachmentUploadManager, AttachmentMetadata } from '@internal/react-components';\n/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\nimport { produce } from 'immer';\n/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\nimport { FileSharingMetadata, AttachmentUpload } from '../file-sharing';\n/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\nimport { ChatContext } from './AzureCommunicationChatAdapter';\n/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\nimport { ChatAdapterState } from './ChatAdapter';\n\n/**\n * A record containing {@link AttachmentMetadata} mapped to unique ids.\n * @beta\n */\nexport type AttachmentUploadsUiState = Record<string, AttachmentMetadata>;\n\n/**\n * @beta\n */\nexport interface AttachmentUploadAdapter {\n registerActiveUploads: (files: File[]) => AttachmentUploadManager[];\n registerCompletedUploads: (metadata: AttachmentMetadata[]) => AttachmentUploadManager[];\n clearUploads: () => void;\n cancelUpload: (id: string) => void;\n updateUploadProgress: (id: string, progress: number) => void;\n updateUploadStatusMessage: (id: string, errorMessage: string) => void;\n updateUploadMetadata: (id: string, metadata: AttachmentMetadata) => void;\n}\n\n/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\n/**\n * @internal\n */\nclass AttachmentUploadContext {\n private chatContext: ChatContext;\n\n constructor(chatContext: ChatContext) {\n this.chatContext = chatContext;\n }\n\n public getAttachmentUploads(): AttachmentUploadsUiState | undefined {\n return this.chatContext.getState().attachmentUploads;\n }\n\n public addAttachmentUploads(attachmentUploads: AttachmentUpload[]): void {\n const attachmentUploadsMap = convertObservableAttachmentUploadToAttachmentUploadsUiState(attachmentUploads);\n this.chatContext.setState(\n produce(this.chatContext.getState(), (draft) => {\n draft.attachmentUploads = draft.attachmentUploads || {};\n draft.attachmentUploads = { ...draft.attachmentUploads, ...attachmentUploadsMap };\n })\n );\n }\n\n public clearUploads(): void {\n this.chatContext.setState(\n produce(this.chatContext.getState(), (draft: ChatAdapterState) => {\n draft.attachmentUploads = {};\n })\n );\n }\n\n public updateAttachmentUpload(\n id: string,\n data: Partial<Pick<AttachmentMetadata, 'progress' | 'id' | 'name' | 'extension' | 'uploadError' | 'url'>>\n ): void {\n this.chatContext.setState(\n produce(this.chatContext.getState(), (draft: ChatAdapterState) => {\n if (draft.attachmentUploads?.[id]) {\n draft.attachmentUploads[data.id ?? id] = {\n ...draft.attachmentUploads?.[id],\n ...data\n };\n if (data.id) {\n delete draft.attachmentUploads?.[id];\n }\n }\n })\n );\n }\n\n public deleteAttachmentUploads(ids: string[]): void {\n this.chatContext.setState(\n produce(this.chatContext.getState(), (draft: ChatAdapterState) => {\n ids.forEach((id) => {\n const keys = Object.keys(draft?.attachmentUploads ?? []).filter(\n (rawID) => draft.attachmentUploads?.[rawID].id === id\n );\n keys.forEach((key) => {\n delete draft.attachmentUploads?.[key];\n });\n });\n })\n );\n }\n}\n\n/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\n/**\n * @internal\n */\nexport class AzureCommunicationAttachmentUploadAdapter implements AttachmentUploadAdapter {\n private context: AttachmentUploadContext;\n private attachmentUploads: AttachmentUpload[] = [];\n\n constructor(chatContext: ChatContext) {\n this.context = new AttachmentUploadContext(chatContext);\n }\n\n private findAttachmentUpload(id: string): AttachmentUpload | undefined {\n return this.attachmentUploads.find((attachmentUpload) => attachmentUpload.id === id);\n }\n\n private deleteAttachmentUploads(ids: string[]): void {\n this.attachmentUploads = this.attachmentUploads.filter((attachmentUpload) => !ids.includes(attachmentUpload.id));\n this.context.deleteAttachmentUploads(ids);\n }\n\n private deleteErroneousAttachmentUploads(): void {\n const attachmentUploads = this.context.getAttachmentUploads() || {};\n const ids = Object.values(attachmentUploads)\n .filter((item: AttachmentMetadata) => item.uploadError)\n .map((item: AttachmentMetadata) => item.id);\n\n ids.forEach((id) => {\n const attachmentUpload = this.findAttachmentUpload(id);\n this.unsubscribeAllEvents(attachmentUpload);\n });\n\n this.deleteAttachmentUploads(ids);\n }\n\n private registerAttachmentUploads(files: File[] | AttachmentMetadata[]): AttachmentUploadManager[] {\n this.deleteErroneousAttachmentUploads();\n const attachmentUploads: AttachmentUpload[] = [];\n files.forEach((file) => attachmentUploads.push(new AttachmentUpload(file)));\n attachmentUploads.forEach((attachmentUpload) => this.subscribeAllEvents(attachmentUpload));\n this.attachmentUploads = this.attachmentUploads.concat(attachmentUploads);\n this.context.addAttachmentUploads(attachmentUploads);\n return attachmentUploads;\n }\n\n registerActiveUploads(files: File[]): AttachmentUploadManager[] {\n return this.registerAttachmentUploads(files);\n }\n\n registerCompletedUploads(metadata: AttachmentMetadata[]): AttachmentUploadManager[] {\n return this.registerAttachmentUploads(metadata);\n }\n\n clearUploads(): void {\n this.context.clearUploads();\n this.attachmentUploads.forEach((attachmentUpload) => this.unsubscribeAllEvents(attachmentUpload));\n this.attachmentUploads = [];\n }\n\n cancelUpload(id: string): void {\n this.deleteErroneousAttachmentUploads();\n const attachmentUpload = this.findAttachmentUpload(id);\n this.unsubscribeAllEvents(attachmentUpload);\n this.deleteAttachmentUploads([id]);\n }\n\n updateUploadProgress(id: string, progress: number): void {\n this.context.updateAttachmentUpload(id, { progress });\n }\n\n updateUploadStatusMessage(id: string, errorMessage: string): void {\n this.context.updateAttachmentUpload(id, {\n uploadError: {\n message: errorMessage,\n timestamp: Date.now()\n }\n });\n }\n\n updateUploadMetadata(id: string, metadata: AttachmentMetadata): void {\n this.context.updateAttachmentUpload(id, {\n progress: 1,\n id: metadata.id,\n name: metadata.name,\n url: metadata.url,\n extension: metadata.extension\n });\n }\n\n private subscribeAllEvents(attachmentUpload: AttachmentUpload): void {\n attachmentUpload.on('uploadProgressChange', this.updateUploadProgress.bind(this));\n attachmentUpload.on('uploadComplete', this.updateUploadMetadata.bind(this));\n attachmentUpload.on('uploadFail', this.updateUploadStatusMessage.bind(this));\n }\n\n private unsubscribeAllEvents(attachmentUpload?: AttachmentUpload): void {\n attachmentUpload?.off('uploadProgressChange', this.updateUploadProgress.bind(this));\n attachmentUpload?.off('uploadComplete', this.updateUploadMetadata.bind(this));\n attachmentUpload?.off('uploadFail', this.updateUploadStatusMessage.bind(this));\n }\n}\n\n/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\n/**\n * @param attachmentUploadUiState {@link AttachmentUploadsUiState}\n * @private\n */\nexport const convertAttachmentUploadsUiStateToMessageMetadata = (\n attachmentUploads?: AttachmentUploadsUiState\n): FileSharingMetadata | undefined => {\n if (attachmentUploads) {\n const attachmentMetadata: AttachmentMetadata[] = [];\n Object.keys(attachmentUploads).forEach((key) => {\n const attachment = attachmentUploads[key];\n if (attachment && !attachment.uploadError) {\n attachmentMetadata.push({\n id: attachment.id,\n name: attachment.name,\n extension: attachment.extension,\n url: attachment.url,\n progress: attachment.progress\n });\n }\n });\n if (attachmentMetadata.length > 0) {\n return { fileSharingMetadata: JSON.stringify(attachmentMetadata) };\n }\n }\n return undefined;\n};\n\n/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */\n/**\n * @private\n */\nconst convertObservableAttachmentUploadToAttachmentUploadsUiState = (\n attachmentUploads: AttachmentUpload[]\n): AttachmentUploadsUiState => {\n return attachmentUploads.reduce((map: AttachmentUploadsUiState, attachmentUpload) => {\n map[attachmentUpload.id] = {\n id: attachmentUpload.id,\n name: attachmentUpload.name,\n progress: 0,\n extension: attachmentUpload.name.split('.').pop() || ''\n };\n return map;\n }, {});\n};\n"]}
|
@@ -6,7 +6,7 @@ import { ChatAdapter, ChatAdapterState, MessageDeletedListener, MessageEditedLis
|
|
6
6
|
import { ResourceDetails } from './ChatAdapter';
|
7
7
|
import { AdapterError } from '../../common/adapters';
|
8
8
|
import { AttachmentMetadata } from "../../../../../react-components/src";
|
9
|
-
import {
|
9
|
+
import { AttachmentUploadManager } from "../../../../../react-components/src";
|
10
10
|
/**
|
11
11
|
* Context of Chat, which is a centralized context for all state updates
|
12
12
|
* @private
|
@@ -30,7 +30,7 @@ export declare class AzureCommunicationChatAdapter implements ChatAdapter {
|
|
30
30
|
private chatClient;
|
31
31
|
private chatThreadClient;
|
32
32
|
private context;
|
33
|
-
private
|
33
|
+
private attachmentUploadAdapter;
|
34
34
|
private handlers;
|
35
35
|
private emitter;
|
36
36
|
constructor(chatClient: StatefulChatClient, chatThreadClient: ChatThreadClient);
|
@@ -50,13 +50,13 @@ export declare class AzureCommunicationChatAdapter implements ChatAdapter {
|
|
50
50
|
attachmentMetadata?: AttachmentMetadata[];
|
51
51
|
}): Promise<void>;
|
52
52
|
deleteMessage(messageId: string): Promise<void>;
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
53
|
+
registerActiveUploads(files: File[]): AttachmentUploadManager[];
|
54
|
+
registerCompletedUploads(metadata: AttachmentMetadata[]): AttachmentUploadManager[];
|
55
|
+
clearUploads(): void;
|
56
|
+
cancelUpload(id: string): void;
|
57
|
+
updateUploadProgress(id: string, progress: number): void;
|
58
|
+
updateUploadStatusMessage(id: string, errorMessage: string): void;
|
59
|
+
updateUploadMetadata(id: string, metadata: AttachmentMetadata): void;
|
60
60
|
downloadResourceToCache(resourceDetails: ResourceDetails): Promise<void>;
|
61
61
|
removeResourceFromCache(resourceDetails: ResourceDetails): void;
|
62
62
|
private messageReceivedListener;
|
@@ -21,9 +21,9 @@ import { createDefaultChatHandlers } from "../../../../../chat-component-binding
|
|
21
21
|
import { toFlatCommunicationIdentifier } from "../../../../../acs-ui-common/src";
|
22
22
|
import EventEmitter from 'events';
|
23
23
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
24
|
-
import {
|
24
|
+
import { convertAttachmentUploadsUiStateToMessageMetadata } from './AzureCommunicationAttachmentUploadAdapter';
|
25
25
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
26
|
-
import {
|
26
|
+
import { AzureCommunicationAttachmentUploadAdapter } from './AzureCommunicationAttachmentUploadAdapter';
|
27
27
|
import { useEffect, useRef, useState } from 'react';
|
28
28
|
import { _isValidIdentifier } from "../../../../../acs-ui-common/src";
|
29
29
|
/**
|
@@ -73,7 +73,7 @@ export class ChatContext {
|
|
73
73
|
latestErrors: clientState.latestErrors
|
74
74
|
};
|
75
75
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
76
|
-
updatedState = Object.assign(Object.assign({}, updatedState), {
|
76
|
+
updatedState = Object.assign(Object.assign({}, updatedState), { attachmentUploads: this.state.attachmentUploads });
|
77
77
|
this.setState(updatedState);
|
78
78
|
}
|
79
79
|
}
|
@@ -88,7 +88,7 @@ export class AzureCommunicationChatAdapter {
|
|
88
88
|
this.chatThreadClient = chatThreadClient;
|
89
89
|
this.context = new ChatContext(chatClient.getState(), chatThreadClient.threadId);
|
90
90
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
91
|
-
this.
|
91
|
+
this.attachmentUploadAdapter = new AzureCommunicationAttachmentUploadAdapter(this.context);
|
92
92
|
const onStateChange = (clientState) => {
|
93
93
|
// unsubscribe when the instance gets disposed
|
94
94
|
if (!this) {
|
@@ -118,19 +118,19 @@ export class AzureCommunicationChatAdapter {
|
|
118
118
|
this.on = this.on.bind(this);
|
119
119
|
this.off = this.off.bind(this);
|
120
120
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
121
|
-
this.
|
121
|
+
this.registerActiveUploads = this.registerActiveUploads.bind(this);
|
122
122
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
123
|
-
this.
|
123
|
+
this.registerCompletedUploads = this.registerCompletedUploads.bind(this);
|
124
124
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
125
|
-
this.
|
125
|
+
this.clearUploads = this.clearUploads.bind(this);
|
126
126
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
127
|
-
this.
|
127
|
+
this.cancelUpload = this.cancelUpload.bind(this);
|
128
128
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
129
|
-
this.
|
129
|
+
this.updateUploadProgress = this.updateUploadProgress.bind(this);
|
130
130
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
131
|
-
this.
|
131
|
+
this.updateUploadStatusMessage = this.updateUploadStatusMessage.bind(this);
|
132
132
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
133
|
-
this.
|
133
|
+
this.updateUploadMetadata = this.updateUploadMetadata.bind(this);
|
134
134
|
this.downloadResourceToCache = this.downloadResourceToCache.bind(this);
|
135
135
|
this.removeResourceFromCache = this.removeResourceFromCache.bind(this);
|
136
136
|
}
|
@@ -180,16 +180,16 @@ export class AzureCommunicationChatAdapter {
|
|
180
180
|
return __awaiter(this, arguments, void 0, function* (content, options = {}) {
|
181
181
|
yield this.asyncTeeErrorToEventEmitter(() => __awaiter(this, void 0, void 0, function* () {
|
182
182
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
183
|
-
options.metadata = Object.assign(Object.assign({}, options.metadata),
|
183
|
+
options.metadata = Object.assign(Object.assign({}, options.metadata), convertAttachmentUploadsUiStateToMessageMetadata(this.context.getState().attachmentUploads));
|
184
184
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
185
185
|
/**
|
186
186
|
* All the current uploads need to be clear from the state before a message has been sent.
|
187
187
|
* This ensures the following behavior:
|
188
|
-
* 1.
|
189
|
-
* 2. any component rendering these
|
190
|
-
* 3. Cleans the state for new
|
188
|
+
* 1. Attachment Upload cards are removed from sendbox at the same time text in sendbox is removed.
|
189
|
+
* 2. any component rendering these attachment uploads doesn't continue to do so.
|
190
|
+
* 3. Cleans the state for new attachment uploads with a fresh message.
|
191
191
|
*/
|
192
|
-
this.
|
192
|
+
this.attachmentUploadAdapter.clearUploads();
|
193
193
|
yield this.handlers.onSendMessage(content, options);
|
194
194
|
}));
|
195
195
|
});
|
@@ -248,32 +248,32 @@ export class AzureCommunicationChatAdapter {
|
|
248
248
|
});
|
249
249
|
}
|
250
250
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
251
|
-
|
252
|
-
return this.
|
251
|
+
registerActiveUploads(files) {
|
252
|
+
return this.attachmentUploadAdapter.registerActiveUploads(files);
|
253
253
|
}
|
254
254
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
255
|
-
|
256
|
-
return this.
|
255
|
+
registerCompletedUploads(metadata) {
|
256
|
+
return this.attachmentUploadAdapter.registerCompletedUploads(metadata);
|
257
257
|
}
|
258
258
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
259
|
-
|
260
|
-
this.
|
259
|
+
clearUploads() {
|
260
|
+
this.attachmentUploadAdapter.clearUploads();
|
261
261
|
}
|
262
262
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
263
|
-
|
264
|
-
this.
|
263
|
+
cancelUpload(id) {
|
264
|
+
this.attachmentUploadAdapter.cancelUpload(id);
|
265
265
|
}
|
266
266
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
267
|
-
|
268
|
-
this.
|
267
|
+
updateUploadProgress(id, progress) {
|
268
|
+
this.attachmentUploadAdapter.updateUploadProgress(id, progress);
|
269
269
|
}
|
270
270
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
271
|
-
|
272
|
-
this.
|
271
|
+
updateUploadStatusMessage(id, errorMessage) {
|
272
|
+
this.attachmentUploadAdapter.updateUploadStatusMessage(id, errorMessage);
|
273
273
|
}
|
274
274
|
/* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
|
275
|
-
|
276
|
-
this.
|
275
|
+
updateUploadMetadata(id, metadata) {
|
276
|
+
this.attachmentUploadAdapter.updateUploadMetadata(id, metadata);
|
277
277
|
}
|
278
278
|
downloadResourceToCache(resourceDetails) {
|
279
279
|
return __awaiter(this, void 0, void 0, function* () {
|