Skip to content

Commit 56cc57b

Browse files
authored
Chat: Updating the downloadAttachment api to not be list (#4071)
1 parent e132b25 commit 56cc57b

15 files changed

Lines changed: 67 additions & 78 deletions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "prerelease",
3+
"area": "improvement",
4+
"workstream": "InlineImages",
5+
"comment": "Updating the downloadAttachment api to not be list",
6+
"packageName": "@azure/communication-react",
7+
"email": "9044372+JoshuaLai@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "prerelease",
3+
"area": "improvement",
4+
"workstream": "InlineImages",
5+
"comment": "Updating the downloadAttachment api to not be list",
6+
"packageName": "@azure/communication-react",
7+
"email": "9044372+JoshuaLai@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}

packages/communication-react/review/beta/communication-react.api.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ export type AreTypeEqual<A, B> = A extends B ? (B extends A ? true : false) : fa
149149

150150
// @beta
151151
export interface AttachmentDownloadResult {
152-
attachmentId: string;
153152
blobUrl: string;
154153
}
155154

@@ -993,9 +992,9 @@ export interface CallWithChatAdapterManagement {
993992
disposeScreenShareStreamView(remoteUserId: string): Promise<void>;
994993
disposeStreamView(remoteUserId?: string, options?: VideoStreamOptions): Promise<void>;
995994
// (undocumented)
996-
downloadAttachments: (options: {
997-
attachmentUrls: Record<string, string>;
998-
}) => Promise<AttachmentDownloadResult[]>;
995+
downloadAttachment: (options: {
996+
attachmentUrl: string;
997+
}) => Promise<AttachmentDownloadResult>;
999998
fetchInitialData(): Promise<void>;
1000999
// @beta
10011000
holdCall: () => Promise<void>;
@@ -1607,9 +1606,9 @@ export interface ChatAdapterSubscribers {
16071606
export interface ChatAdapterThreadManagement {
16081607
deleteMessage(messageId: string): Promise<void>;
16091608
// (undocumented)
1610-
downloadAttachments: (options: {
1611-
attachmentUrls: Record<string, string>;
1612-
}) => Promise<AttachmentDownloadResult[]>;
1609+
downloadAttachment: (options: {
1610+
attachmentUrl: string;
1611+
}) => Promise<AttachmentDownloadResult>;
16131612
fetchInitialData(): Promise<void>;
16141613
loadPreviousChatMessages(messagesToLoad: number): Promise<boolean>;
16151614
removeParticipant(userId: string): Promise<void>;

packages/react-components/review/beta/react-components.api.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export type AnnouncerProps = {
6868

6969
// @beta
7070
export interface AttachmentDownloadResult {
71-
attachmentId: string;
7271
blobUrl: string;
7372
}
7473

packages/react-components/src/components/FileDownloadCards.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ export type AttachmentMetadata =
9494
* @beta
9595
*/
9696
export interface AttachmentDownloadResult {
97-
/**
98-
* Unique ID of the attachment.
99-
*/
100-
attachmentId: string;
10197
/**
10298
* Blob URL for the attachment.
10399
*/

packages/react-composites/review/beta/react-composites.api.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,9 @@ export interface CallWithChatAdapterManagement {
692692
disposeScreenShareStreamView(remoteUserId: string): Promise<void>;
693693
disposeStreamView(remoteUserId?: string, options?: VideoStreamOptions): Promise<void>;
694694
// (undocumented)
695-
downloadAttachments: (options: {
696-
attachmentUrls: Record<string, string>;
697-
}) => Promise<AttachmentDownloadResult[]>;
695+
downloadAttachment: (options: {
696+
attachmentUrl: string;
697+
}) => Promise<AttachmentDownloadResult>;
698698
fetchInitialData(): Promise<void>;
699699
// @beta
700700
holdCall: () => Promise<void>;
@@ -1121,9 +1121,9 @@ export interface ChatAdapterSubscribers {
11211121
export interface ChatAdapterThreadManagement {
11221122
deleteMessage(messageId: string): Promise<void>;
11231123
// (undocumented)
1124-
downloadAttachments: (options: {
1125-
attachmentUrls: Record<string, string>;
1126-
}) => Promise<AttachmentDownloadResult[]>;
1124+
downloadAttachment: (options: {
1125+
attachmentUrl: string;
1126+
}) => Promise<AttachmentDownloadResult>;
11271127
fetchInitialData(): Promise<void>;
11281128
loadPreviousChatMessages(messagesToLoad: number): Promise<boolean>;
11291129
removeParticipant(userId: string): Promise<void>;

packages/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export class AzureCommunicationCallWithChatAdapter implements CallWithChatAdapte
232232
/* @conditional-compile-remove(file-sharing) */
233233
this.updateFileUploadMetadata = this.updateFileUploadMetadata.bind(this);
234234
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
235-
this.downloadAttachments = this.downloadAttachments.bind(this);
235+
this.downloadAttachment = this.downloadAttachment.bind(this);
236236
/* @conditional-compile-remove(PSTN-calls) */
237237
this.holdCall.bind(this);
238238
/* @conditional-compile-remove(PSTN-calls) */
@@ -472,8 +472,8 @@ export class AzureCommunicationCallWithChatAdapter implements CallWithChatAdapte
472472
this.chatAdapter.updateFileUploadMetadata(id, metadata);
473473
};
474474
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
475-
async downloadAttachments(options: { attachmentUrls: Record<string, string> }): Promise<AttachmentDownloadResult[]> {
476-
return await this.chatAdapter.downloadAttachments(options);
475+
async downloadAttachment(options: { attachmentUrl: string }): Promise<AttachmentDownloadResult> {
476+
return await this.chatAdapter.downloadAttachment(options);
477477
}
478478
/* @conditional-compile-remove(PSTN-calls) */
479479
public async holdCall(): Promise<void> {

packages/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ export interface CallWithChatAdapterManagement {
385385
/** @beta */
386386
updateFileUploadMetadata: (id: string, metadata: AttachmentMetadata) => void;
387387
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
388-
downloadAttachments: (options: { attachmentUrls: Record<string, string> }) => Promise<AttachmentDownloadResult[]>;
388+
downloadAttachment: (options: { attachmentUrl: string }) => Promise<AttachmentDownloadResult>;
389389
/* @conditional-compile-remove(PSTN-calls) */
390390
/**
391391
* Puts the Call in a Localhold.

packages/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ export class CallWithChatBackedChatAdapter implements ChatAdapter {
130130
};
131131

132132
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
133-
public async downloadAttachments(options: {
134-
attachmentUrls: Record<string, string>;
135-
}): Promise<AttachmentDownloadResult[]> {
136-
return await this.callWithChatAdapter.downloadAttachments(options);
133+
public async downloadAttachment(options: { attachmentUrl: string }): Promise<AttachmentDownloadResult> {
134+
return await this.callWithChatAdapter.downloadAttachment(options);
137135
}
138136
}
139137

packages/react-composites/src/composites/ChatComposite/ChatScreen.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ export const ChatScreen = (props: ChatScreenProps): JSX.Element => {
267267

268268
if (attachment.attachmentType === 'inlineImage' && attachment.url) {
269269
// TBD: Need to begin investigating how to download HQ images.
270-
const blob = await adapter.downloadAttachments({ attachmentUrls: { [attachment.id]: attachment.url } });
271-
if (blob[0]) {
272-
const blobUrl = blob[0].blobUrl;
270+
const blob = await adapter.downloadAttachment({ attachmentUrl: attachment.url });
271+
if (blob) {
272+
const blobUrl = blob.blobUrl;
273273
setFullSizeAttachments((prev) => ({ ...prev, [attachment.id]: blobUrl }));
274274
setGalleryImages([
275275
{

0 commit comments

Comments
 (0)