mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 02:08:57 +00:00
Fix gradient showing instead of placeholder when Avatar URL loading fails
This commit is contained in:
@@ -64,7 +64,9 @@ const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
|||||||
blur: overrideProps.blur,
|
blur: overrideProps.blur,
|
||||||
color: overrideProps.color || AvatarColors[0],
|
color: overrideProps.color || AvatarColors[0],
|
||||||
conversationType: overrideProps.conversationType || 'direct',
|
conversationType: overrideProps.conversationType || 'direct',
|
||||||
hasAvatar: Boolean(overrideProps.hasAvatar),
|
hasAvatar:
|
||||||
|
Boolean(overrideProps.hasAvatar) ||
|
||||||
|
(overrideProps.avatarUrl != null && overrideProps.avatarUrl.length > 0),
|
||||||
i18n,
|
i18n,
|
||||||
loading: Boolean(overrideProps.loading),
|
loading: Boolean(overrideProps.loading),
|
||||||
noteToSelf: Boolean(overrideProps.noteToSelf),
|
noteToSelf: Boolean(overrideProps.noteToSelf),
|
||||||
|
|||||||
@@ -144,9 +144,10 @@ export function Avatar({
|
|||||||
}, [avatarUrl]);
|
}, [avatarUrl]);
|
||||||
|
|
||||||
const initials = getInitials(title);
|
const initials = getInitials(title);
|
||||||
const hasImage = !noteToSelf && avatarUrl && !imageBroken;
|
const hasLocalImage = !noteToSelf && avatarUrl && avatarUrl.length > 0;
|
||||||
|
const hasValidImage = hasLocalImage && !imageBroken;
|
||||||
const shouldUseInitials =
|
const shouldUseInitials =
|
||||||
!hasImage &&
|
!hasValidImage &&
|
||||||
conversationType === 'direct' &&
|
conversationType === 'direct' &&
|
||||||
Boolean(initials) &&
|
Boolean(initials) &&
|
||||||
title !== i18n('icu:unknownContact');
|
title !== i18n('icu:unknownContact');
|
||||||
@@ -163,7 +164,7 @@ export function Avatar({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else if (hasImage) {
|
} else if (hasValidImage) {
|
||||||
assertDev(avatarUrl, 'avatarUrl should be defined here');
|
assertDev(avatarUrl, 'avatarUrl should be defined here');
|
||||||
|
|
||||||
assertDev(
|
assertDev(
|
||||||
@@ -207,7 +208,7 @@ export function Avatar({
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (hasAvatar && !hasImage) {
|
} else if (hasAvatar && !hasLocalImage) {
|
||||||
contentsChildren = (
|
contentsChildren = (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user