Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hideAvatar to onFetchAvatarPersonaData API #5646

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -136,11 +136,12 @@ export const FluentChatMessageComponent = (props: FluentChatMessageComponentWrap
renderedAvatar = avatarComponent;
}
}
return (
return !renderedAvatar?.props ? (
<div className={mergeStyles(chatAvatarStyle)}>
{renderedAvatar ? renderedAvatar : <Persona {...personaOptions} />}
</div>
);
) : // When pass undefined to FluentChatMessage component, it will remove the unnecessary left margin
undefined;
}, [message.senderDisplayName, message.senderId, onRenderAvatar, shouldShowAvatar]);

const setMessageContainerRef = useCallback((node: HTMLDivElement | null) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export type AvatarPersonaData = {
* It has '?' in place of initials, with static font and background colors
*/
showUnknownPersonaCoin?: boolean;
/**
* If true, hide the entire avatar avatar element.
*/
hideAvatar?: boolean;
};

/**
Expand Down Expand Up @@ -107,7 +111,7 @@ export const AvatarPersona = (props: AvatarPersonaProps): JSX.Element => {
mergeStyles(activePersona, props.styles);
}

return (
return !data?.hideAvatar ? (
<Persona
{...props}
className={activePersona}
Expand All @@ -120,6 +124,8 @@ export const AvatarPersona = (props: AvatarPersonaProps): JSX.Element => {
showOverflowTooltip={showOverflowTooltip ?? false}
showUnknownPersonaCoin={data?.showUnknownPersonaCoin ?? props.showUnknownPersonaCoin ?? false}
/>
) : (
<></>
);
};

Expand Down
3 changes: 2 additions & 1 deletion samples/Chat/src/app/ChatScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export const ChatScreen = (props: ChatScreenProps): JSX.Element => {
new Promise((resolve) => {
return resolve({
imageInitials: emoji,
initialsColor: emoji ? getBackgroundColor(emoji)?.backgroundColor : undefined
initialsColor: emoji ? getBackgroundColor(emoji)?.backgroundColor : undefined,
hideAvatar: true
});
})
);
Expand Down
Loading