Skip to content
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
09468e6
Use resourceCache from adapter state for fullsize image src
Leah-Xia-Microsoft Mar 2, 2024
da03ff4
Clean full size cache when ImageOverlay is closed
Leah-Xia-Microsoft Mar 2, 2024
dc9fbf8
Change files
Leah-Xia-Microsoft Mar 2, 2024
dbb2efb
Duplicate change files for beta release
Leah-Xia-Microsoft Mar 2, 2024
676b7d6
Update ChatScreen.tsx
Leah-Xia-Microsoft Mar 2, 2024
6922e00
Remove cc for stable
Leah-Xia-Microsoft Mar 2, 2024
1dd3191
Merge branch 'main' into leahxia/useAdapterStateForFullsizeCache
Leah-Xia-Microsoft Mar 2, 2024
0f25341
Merge branch 'main' of https://github.com/Azure/communication-ui-libr…
JoshuaLai Mar 4, 2024
f11bfcb
Remove the InlineImageMetadata type
JoshuaLai Mar 4, 2024
d3bc3d3
Change files
JoshuaLai Mar 4, 2024
dca8589
Duplicate change files for beta release
JoshuaLai Mar 4, 2024
45d9ac2
Update storybook removing reference to inline image
JoshuaLai Mar 4, 2024
c5c9550
Merge branch 'main' into feature/removeInlineImageMetadata
JoshuaLai Mar 4, 2024
63f24f3
Removing and cleaning up Storybook
JoshuaLai Mar 4, 2024
1830c0b
Merge branch 'feature/removeInlineImageMetadata' of https://github.co…
JoshuaLai Mar 4, 2024
743c04f
Clean up storybook reference
JoshuaLai Mar 4, 2024
c405456
Clean up commented code
JoshuaLai Mar 4, 2024
ee2bcb3
Remove AttachmentMetadata
Leah-Xia-Microsoft Mar 5, 2024
8ccf5cd
Change files
Leah-Xia-Microsoft Mar 5, 2024
c964209
Duplicate change files for beta release
Leah-Xia-Microsoft Mar 5, 2024
06fc3e6
Merge branch 'main' into leahxia/remove-AttachmentMetadata
Leah-Xia-Microsoft Mar 5, 2024
cd704c8
Rename FileMetadata to AttachmentMetadata
Leah-Xia-Microsoft Mar 5, 2024
4ab91fc
Fix stable
Leah-Xia-Microsoft Mar 5, 2024
390f3c7
Remove attachmentType
Leah-Xia-Microsoft Mar 5, 2024
5fc6fde
Remove attachmentType arg
Leah-Xia-Microsoft Mar 5, 2024
2645032
Merge branch 'main' into leahxia/remove-AttachmentMetadata
emlynmac Mar 6, 2024
7cee6c5
Update FileDownloadCards.test.tsx
Leah-Xia-Microsoft Mar 6, 2024
2a37e99
Merge branch 'leahxia/remove-AttachmentMetadata' of https://github.co…
Leah-Xia-Microsoft Mar 6, 2024
7fdef4b
Update FileDownloadCards.test.tsx
Leah-Xia-Microsoft Mar 6, 2024
6cd8379
Merge branch 'main' into leahxia/remove-AttachmentMetadata
Leah-Xia-Microsoft Mar 6, 2024
b21a3f0
Fix build
Leah-Xia-Microsoft Mar 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "minor",
"area": "improvement",
"workstream": "InlineImage",
"comment": "Remove AttachmentMetadata",
"packageName": "@azure/communication-react",
"email": "107075081+Leah-Xia-Microsoft@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "minor",
"area": "improvement",
"workstream": "InlineImage",
"comment": "Remove AttachmentMetadata",
"packageName": "@azure/communication-react",
"email": "107075081+Leah-Xia-Microsoft@users.noreply.github.com",
"dependentChangeType": "patch"
}
17 changes: 7 additions & 10 deletions packages/chat-component-bindings/src/messageThreadSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { DEFAULT_DATA_LOSS_PREVENTION_POLICY_URL } from './utils/constants';
import { ACSKnownMessageType } from './utils/constants';
import { updateMessagesWithAttached } from './utils/updateMessagesWithAttached';
/* @conditional-compile-remove(file-sharing) */
import { FileMetadata } from '@internal/react-components';
import { AttachmentMetadata } from '@internal/react-components';
/* @conditional-compile-remove(file-sharing) */
import { ChatAttachmentType } from '@azure/communication-chat';
import { ChatAttachment } from '@azure/communication-chat';
Expand Down Expand Up @@ -63,7 +63,7 @@ const memoizedAllConvertChatMessage = memoizeFnAll(
);

/* @conditional-compile-remove(file-sharing) */
const extractAttachedFilesMetadata = (metadata: Record<string, string>): FileMetadata[] => {
const extractAttachedFilesMetadata = (metadata: Record<string, string>): AttachmentMetadata[] => {
const fileMetadata = metadata.fileSharingMetadata;
if (!fileMetadata) {
return [];
Expand All @@ -79,18 +79,17 @@ const extractAttachedFilesMetadata = (metadata: Record<string, string>): FileMet
const extractTeamsAttachmentsMetadata = (
attachments: ChatAttachment[]
): {
/* @conditional-compile-remove(file-sharing) */ files: FileMetadata[];
/* @conditional-compile-remove(file-sharing) */ files: AttachmentMetadata[];
} => {
/* @conditional-compile-remove(file-sharing) */
const files: FileMetadata[] = [];
const files: AttachmentMetadata[] = [];
attachments.forEach((attachment) => {
const attachmentType = mapAttachmentType(attachment.attachmentType);
/* @conditional-compile-remove(file-sharing) */
const contentType = extractAttachmentContentTypeFromName(attachment.name);
/* @conditional-compile-remove(file-sharing) */
if (attachmentType === 'file') {
files.push({
attachmentType: attachmentType,
id: attachment.id,
name: attachment.name ?? '',
extension: contentType ?? '',
Expand Down Expand Up @@ -140,9 +139,7 @@ const mapAttachmentType = (attachmentType: ChatAttachmentType): AttachmentType =

/* @conditional-compile-remove(file-sharing) */
const extractAttachmentUrl = (attachment: ChatAttachment): string => {
/* @conditional-compile-remove(file-sharing) */
return attachment.attachmentType === 'file' && attachment.previewUrl ? attachment.previewUrl : attachment.url || '';
return attachment.url || '';
return attachment.previewUrl ? attachment.previewUrl : attachment.url || '';
};
const processChatMessageContent = (message: ChatMessageWithStatus): string | undefined => {
let content = message.content?.message;
Expand Down Expand Up @@ -212,10 +209,10 @@ const extractAttachmentContentTypeFromName = (name?: string): string => {
const extractAttachmentsMetadata = (
message: ChatMessageWithStatus
): {
/* @conditional-compile-remove(file-sharing) */ files: FileMetadata[];
/* @conditional-compile-remove(file-sharing) */ files: AttachmentMetadata[];
} => {
/* @conditional-compile-remove(file-sharing) */
let files: FileMetadata[] = [];
let files: AttachmentMetadata[] = [];

/* @conditional-compile-remove(file-sharing) */
if (message.metadata) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,14 @@ export type AreParamEqual<A extends (props: any) => JSX.Element | undefined, B e
export type AreTypeEqual<A, B> = A extends B ? (B extends A ? true : false) : false;

// @beta
export type AttachmentMetadata = FileMetadata;
export interface AttachmentMetadata {
extension: string;
id: string;
name: string;
// (undocumented)
payload?: Record<string, string>;
url: string;
}

// @public
export type AvatarPersonaData = {
Expand Down Expand Up @@ -1782,7 +1789,7 @@ export interface ChatMessage extends MessageCommon {
// (undocumented)
failureReason?: string;
// @beta
files?: FileMetadata[];
files?: AttachmentMetadata[];
// (undocumented)
messageType: 'chat';
metadata?: Record<string, string>;
Expand Down Expand Up @@ -2869,18 +2876,6 @@ export interface FileDownloadError {
// @beta
export type FileDownloadHandler = (userId: string, fileMetadata: AttachmentMetadata) => Promise<URL | FileDownloadError>;

// @beta
export interface FileMetadata {
// (undocumented)
attachmentType: 'file';
extension: string;
id: string;
name: string;
// (undocumented)
payload?: Record<string, string>;
url: string;
}

// @beta
export interface FileSharingOptions {
accept?: string;
Expand Down
2 changes: 0 additions & 2 deletions packages/communication-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@ export type {
} from '../../react-components/src';
/* @conditional-compile-remove(file-sharing) */
export type { AttachmentMetadata } from '../../react-components/src';
/* @conditional-compile-remove(file-sharing) */
export type { FileMetadata } from '../../react-components/src';
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
export type { ChatAttachmentType } from '../../react-components/src';
/* @conditional-compile-remove(image-overlay) */
Expand Down
23 changes: 9 additions & 14 deletions packages/react-components/review/beta/react-components.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ export type AnnouncerProps = {
};

// @beta
export type AttachmentMetadata = FileMetadata;
export interface AttachmentMetadata {
extension: string;
id: string;
name: string;
// (undocumented)
payload?: Record<string, string>;
url: string;
}

// @internal
export type _AudioIssue = 'NoLocalAudio' | 'NoRemoteAudio' | 'Echo' | 'AudioNoise' | 'LowVolume' | 'AudioStoppedUnexpectedly' | 'DistortedSpeech' | 'AudioInterruption' | 'OtherIssues';
Expand Down Expand Up @@ -467,7 +474,7 @@ export interface ChatMessage extends MessageCommon {
// (undocumented)
failureReason?: string;
// @beta
files?: FileMetadata[];
files?: AttachmentMetadata[];
Comment thread
jpeng-ms marked this conversation as resolved.
// (undocumented)
messageType: 'chat';
metadata?: Record<string, string>;
Expand Down Expand Up @@ -1198,18 +1205,6 @@ export interface FileDownloadError {
// @beta
export type FileDownloadHandler = (userId: string, fileMetadata: AttachmentMetadata) => Promise<URL | FileDownloadError>;

// @beta
export interface FileMetadata {
// (undocumented)
attachmentType: 'file';
extension: string;
id: string;
name: string;
// (undocumented)
payload?: Record<string, string>;
url: string;
}

// @internal
export interface _FileUploadCardsStrings {
removeFile: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ export type AnnouncerProps = {
};

// @beta
export type AttachmentMetadata = FileMetadata;
export interface AttachmentMetadata {
extension: string;
name: string;
url: string;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about id, payload ? are these 2 never GA-ed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about id, payload ? are these 2 never GA-ed?

Yes id and payload is under the feature flag while the rest somehow was released to GA.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about id, payload ? are these 2 never GA-ed?

Actually this is the react components api view not the react communication one.

}

// @public
export interface BaseCustomStyles {
Expand Down Expand Up @@ -970,13 +974,6 @@ export interface FileDownloadError {
// @beta
export type FileDownloadHandler = (userId: string, fileMetadata: AttachmentMetadata) => Promise<URL | FileDownloadError>;

// @beta
export interface FileMetadata {
extension: string;
name: string;
url: string;
}

// @internal
export interface _FileUploadCardsStrings {
removeFile: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useChatMyMessageStyles } from '../styles/MessageThread.styles';
import { ChatMessage } from '../../types';
import { _FileUploadCards } from '../FileUploadCards';
/* @conditional-compile-remove(file-sharing) */
import { FileMetadata } from '../FileDownloadCards';
import { AttachmentMetadata } from '../FileDownloadCards';
import {
chatMessageFailedTagStyle,
editChatMessageFailedTagStyle,
Expand All @@ -38,7 +38,7 @@ export type ChatMessageComponentAsEditBoxProps = {
metadata?: Record<string, string>,
options?: {
/* @conditional-compile-remove(file-sharing) */
attachmentMetadata?: FileMetadata[];
attachmentMetadata?: AttachmentMetadata[];
}
) => void;
message: ChatMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import React from 'react';
import { AttachmentMetadata, _FileDownloadCards } from './FileDownloadCards';
import { FileMetadata } from './FileDownloadCards';
import { render, screen } from '@testing-library/react';
import { registerIcons } from '@fluentui/react';

Expand All @@ -19,13 +18,13 @@ describe('FileDownloadCards should be rendered properly', () => {
});

it('should render if it is FileSharingMetadata', async () => {
const metadata = {
const metadata: AttachmentMetadata = {
name: 'MockFileCard',
extension: 'docx',
url: 'mockUrl',
id: 'mockId',
attachmentType: 'file'
} as FileMetadata;
/* @conditional-compile-remove(file-sharing) */
id: 'mockId'
};

const props = {
userId: 'MockUserId',
Expand Down
73 changes: 25 additions & 48 deletions packages/react-components/src/components/FileDownloadCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ export type ChatAttachmentType =
*
* @beta
*/
export interface FileMetadata {
/* @conditional-compile-remove(file-sharing) */
attachmentType: 'file';
export interface AttachmentMetadata {
/**
* Extension hint, useful for rendering a specific icon.
* An unknown or empty extension will be rendered as a generic icon.
Expand All @@ -55,12 +53,6 @@ export interface FileMetadata {
payload?: Record<string, string>;
}

/**
* Metadata containing information about the uploaded file.
* @beta
*/
export type AttachmentMetadata = FileMetadata;

/**
* Strings of _FileDownloadCards that can be overridden.
*
Expand Down Expand Up @@ -166,16 +158,10 @@ export const _FileDownloadCards = (props: _FileDownloadCardsProps): JSX.Element
[props.strings?.downloadFile, localeStrings.downloadFile]
);

const isFileSharingAttachment = useCallback((attachment: AttachmentMetadata): boolean => {
/* @conditional-compile-remove(file-sharing) */
return attachment.attachmentType === 'file';
return false;
}, []);

/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
const isShowDownloadIcon = useCallback((attachment: AttachmentMetadata): boolean => {
/* @conditional-compile-remove(file-sharing) */
return attachment.attachmentType === 'file' && attachment.payload?.teamsFileAttachment !== 'true';
return attachment.payload?.teamsFileAttachment !== 'true';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are teamsFileAttachments?

return true;
}, []);

Expand All @@ -184,13 +170,13 @@ export const _FileDownloadCards = (props: _FileDownloadCardsProps): JSX.Element
const fileGroupLocaleString = props.strings?.fileCardGroupMessage ?? localeStrings.fileCardGroupMessage;
/* @conditional-compile-remove(file-sharing) */
return _formatString(fileGroupLocaleString, {
fileCount: `${fileMetadata?.filter(isFileSharingAttachment).length ?? 0}`
fileCount: `${fileMetadata?.length ?? 0}`
});
return _formatString(fileGroupLocaleString, {
fileCount: `${fileMetadata?.length ?? 0}`
});
},
[props.strings?.fileCardGroupMessage, localeStrings.fileCardGroupMessage, fileMetadata, isFileSharingAttachment]
[props.strings?.fileCardGroupMessage, localeStrings.fileCardGroupMessage, fileMetadata]
);

const fileDownloadHandler = useCallback(
Expand All @@ -217,7 +203,7 @@ export const _FileDownloadCards = (props: _FileDownloadCardsProps): JSX.Element
if (
!fileMetadata ||
fileMetadata.length === 0 ||
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */ !fileMetadata.some(isFileSharingAttachment)
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */ !fileMetadata
) {
return <></>;
}
Expand All @@ -226,35 +212,26 @@ export const _FileDownloadCards = (props: _FileDownloadCardsProps): JSX.Element
<div style={fileDownloadCardsStyle} data-ui-id="file-download-card-group">
<_FileCardGroup ariaLabel={fileCardGroupDescription()}>
{fileMetadata &&
fileMetadata
.filter((attachment) => {
/* @conditional-compile-remove(file-sharing) */
return isFileSharingAttachment(attachment);
return true;
})
.map((file) => file as unknown as FileMetadata)
.map((file) => (
<TooltipHost content={downloadFileButtonString()} key={file.name}>
<_FileCard
fileName={file.name}
key={file.name}
fileExtension={file.extension}
actionIcon={
showSpinner ? (
<Spinner size={SpinnerSize.medium} aria-live={'polite'} role={'status'} />
) : true &&
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */ isShowDownloadIcon(
file as unknown as AttachmentMetadata
) ? (
<IconButton className={iconButtonClassName} ariaLabel={downloadFileButtonString()}>
<DownloadIconTrampoline />
</IconButton>
) : undefined
}
actionHandler={() => fileDownloadHandler(userId, file as unknown as AttachmentMetadata)}
/>
</TooltipHost>
))}
fileMetadata.map((file) => (
<TooltipHost content={downloadFileButtonString()} key={file.name}>
<_FileCard
fileName={file.name}
key={file.name}
fileExtension={file.extension}
actionIcon={
showSpinner ? (
<Spinner size={SpinnerSize.medium} aria-live={'polite'} role={'status'} />
) : true &&
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */ isShowDownloadIcon(file) ? (
<IconButton className={iconButtonClassName} ariaLabel={downloadFileButtonString()}>
<DownloadIconTrampoline />
</IconButton>
) : undefined
}
actionHandler={() => fileDownloadHandler(userId, file)}
/>
</TooltipHost>
))}
</_FileCardGroup>
</div>
);
Expand Down
6 changes: 3 additions & 3 deletions packages/react-components/src/types/ChatMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { MessageStatus } from '@internal/acs-ui-common';
import { CommunicationParticipant } from './CommunicationParticipant';
/* @conditional-compile-remove(file-sharing) */
import { FileMetadata } from '../components/FileDownloadCards';
import { AttachmentMetadata } from '../components/FileDownloadCards';

/**
* Indicate whether a chat message should be displayed merged with the message before / after it.
Expand Down Expand Up @@ -75,9 +75,9 @@ export interface ChatMessage extends MessageCommon {
/**
* @beta
* A list of file attachments for the message.
* {@link FileMetadata}
* {@link AttachmentMetadata}
*/
files?: FileMetadata[];
files?: AttachmentMetadata[];
}

/**
Expand Down
Loading