Fix image in AvatarLightbox for Note to Self

This commit is contained in:
Fedor Indutny 2024-08-05 11:46:15 -07:00 committed by GitHub
parent 620392e687
commit 1a87989f94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 7 deletions

View file

@ -48,6 +48,13 @@
width: 100%; width: 100%;
} }
&__note_to_self {
-webkit-mask: url('../images/icons/v3/note/note.svg') no-repeat center;
-webkit-mask-size: 70%;
height: 100%;
width: 100%;
}
&__upload { &__upload {
align-items: center; align-items: center;
background: $color-gray-02; background: $color-gray-02;

View file

@ -15,6 +15,7 @@ export type PropsType = {
conversationTitle?: string; conversationTitle?: string;
i18n: LocalizerType; i18n: LocalizerType;
isGroup?: boolean; isGroup?: boolean;
noteToSelf?: boolean;
onClose: () => unknown; onClose: () => unknown;
}; };
@ -24,6 +25,7 @@ export function AvatarLightbox({
conversationTitle, conversationTitle,
i18n, i18n,
isGroup, isGroup,
noteToSelf,
onClose, onClose,
}: PropsType): JSX.Element { }: PropsType): JSX.Element {
return ( return (
@ -47,6 +49,7 @@ export function AvatarLightbox({
conversationTitle={conversationTitle} conversationTitle={conversationTitle}
i18n={i18n} i18n={i18n}
isGroup={isGroup} isGroup={isGroup}
noteToSelf={noteToSelf}
style={{ style={{
fontSize: '16em', fontSize: '16em',
width: 'auto', width: 'auto',

View file

@ -21,6 +21,7 @@ export type PropsType = {
i18n: LocalizerType; i18n: LocalizerType;
isEditable?: boolean; isEditable?: boolean;
isGroup?: boolean; isGroup?: boolean;
noteToSelf?: boolean;
onAvatarLoaded?: (avatarBuffer: Uint8Array) => unknown; onAvatarLoaded?: (avatarBuffer: Uint8Array) => unknown;
onClear?: () => unknown; onClear?: () => unknown;
onClick?: () => unknown; onClick?: () => unknown;
@ -41,6 +42,7 @@ export function AvatarPreview({
i18n, i18n,
isEditable, isEditable,
isGroup, isGroup,
noteToSelf,
onAvatarLoaded, onAvatarLoaded,
onClear, onClear,
onClick, onClick,
@ -117,6 +119,8 @@ export function AvatarPreview({
let encodedPath: string | undefined; let encodedPath: string | undefined;
if (avatarValue && !objectUrl) { if (avatarValue && !objectUrl) {
imageStatus = ImageStatus.Loading; imageStatus = ImageStatus.Loading;
} else if (noteToSelf) {
imageStatus = ImageStatus.Nothing;
} else if (objectUrl) { } else if (objectUrl) {
encodedPath = objectUrl; encodedPath = objectUrl;
imageStatus = ImageStatus.HasImage; imageStatus = ImageStatus.HasImage;
@ -149,6 +153,23 @@ export function AvatarPreview({
} }
if (imageStatus === ImageStatus.Nothing) { if (imageStatus === ImageStatus.Nothing) {
let content: JSX.Element | string | undefined;
if (isGroup) {
content = (
<div
className={`BetterAvatarBubble--${avatarColor}--icon AvatarPreview__group`}
/>
);
} else if (noteToSelf) {
content = (
<div
className={`BetterAvatarBubble--${avatarColor}--icon AvatarPreview__note_to_self`}
/>
);
} else {
content = getInitials(conversationTitle);
}
return ( return (
<div className="AvatarPreview"> <div className="AvatarPreview">
<div <div
@ -156,13 +177,7 @@ export function AvatarPreview({
{...clickProps} {...clickProps}
style={componentStyle} style={componentStyle}
> >
{isGroup ? ( {content}
<div
className={`BetterAvatarBubble--${avatarColor}--icon AvatarPreview__group`}
/>
) : (
getInitials(conversationTitle)
)}
{isEditable && <div className="AvatarPreview__upload" />} {isEditable && <div className="AvatarPreview__upload" />}
</div> </div>
</div> </div>

View file

@ -111,6 +111,7 @@ export function ConversationDetailsHeader({
conversationTitle={conversation.title} conversationTitle={conversation.title}
i18n={i18n} i18n={i18n}
isGroup={isGroup} isGroup={isGroup}
noteToSelf={isMe}
onClose={() => { onClose={() => {
setActiveModal(undefined); setActiveModal(undefined);
}} }}