From 206e9d063db1e94c8fb6f428ed7a87810aa962d9 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Sun, 7 Aug 2022 21:16:05 +0200 Subject: [PATCH] Media Viewer: Fix flickering profile picture (#1987) --- src/components/mediaViewer/hooks/useMediaProps.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/mediaViewer/hooks/useMediaProps.ts b/src/components/mediaViewer/hooks/useMediaProps.ts index 9f47975b..d7d185b6 100644 --- a/src/components/mediaViewer/hooks/useMediaProps.ts +++ b/src/components/mediaViewer/hooks/useMediaProps.ts @@ -63,15 +63,18 @@ export const useMediaProps = ({ if (avatarMedia) { if (avatarMedia.isVideo && isFull) { return getVideoAvatarMediaHash(avatarMedia); + } else if (mediaId === 0) { + // Show preloaded avatar if this is the first media (when user clicks on profile info avatar) + return getChatAvatarHash(avatarOwner, isFull ? 'big' : 'normal'); } else { return `photo${avatarMedia.id}?size=c`; } } else { - return getChatAvatarHash(avatarOwner!, isFull ? 'big' : 'normal'); + return getChatAvatarHash(avatarOwner, isFull ? 'big' : 'normal'); } } return message && getMessageMediaHash(message, isFull ? 'viewerFull' : 'viewerPreview'); - }, [avatarOwner, avatarMedia, message]); + }, [avatarOwner, message, avatarMedia, mediaId]); const pictogramBlobUrl = useMedia( message && (isFromSharedMedia || isFromSearch) && getMessageMediaHash(message, 'pictogram'),