From e1ca21fc469fdf64980918c429d9e2613200a4d7 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Thu, 15 Sep 2022 10:17:59 +0200 Subject: [PATCH] Settings: Fix various flickers --- src/components/common/AnimatedIcon.tsx | 2 +- .../common/AnimatedIconFromSticker.tsx | 1 + .../common/AnimatedIconWithPreview.tsx | 23 +++++++++++---- .../left/settings/SettingsPrivacy.tsx | 29 +++++++------------ 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/components/common/AnimatedIcon.tsx b/src/components/common/AnimatedIcon.tsx index d9917834..2a25f398 100644 --- a/src/components/common/AnimatedIcon.tsx +++ b/src/components/common/AnimatedIcon.tsx @@ -55,7 +55,7 @@ function AnimatedIcon(props: OwnProps) { return ( - & { previewUrl?: string; thumbDataUri?: string }; + & { previewUrl?: string; thumbDataUri?: string; noPreviewTransition?: boolean }; + +const loadedPreviewUrls = new Set(); function AnimatedIconWithPreview(props: OwnProps) { const { - previewUrl, thumbDataUri, className, ...otherProps + previewUrl, thumbDataUri, noPreviewTransition, className, ...otherProps } = props; - const transitionClassNames = useMediaTransition(previewUrl); + const [isPreviewLoaded, markPreviewLoaded] = useFlag(loadedPreviewUrls.has(previewUrl)); + const previewClassNames = useMediaTransition(noPreviewTransition || isPreviewLoaded); const [isAnimationReady, markAnimationReady] = useFlag(false); + + const handlePreviewLoad = useCallback(() => { + markPreviewLoaded(); + loadedPreviewUrls.add(previewUrl); + }, [markPreviewLoaded, previewUrl]); + const { size } = props; return ( @@ -34,7 +43,11 @@ function AnimatedIconWithPreview(props: OwnProps) { )} {!isAnimationReady && ( // eslint-disable-next-line jsx-a11y/alt-text - + )} {/* eslint-disable-next-line react/jsx-props-no-spreading */} diff --git a/src/components/left/settings/SettingsPrivacy.tsx b/src/components/left/settings/SettingsPrivacy.tsx index 4c5d32eb..8f416d4b 100644 --- a/src/components/left/settings/SettingsPrivacy.tsx +++ b/src/components/left/settings/SettingsPrivacy.tsx @@ -137,29 +137,20 @@ const SettingsPrivacy: FC = ({
onScreenSelect(SettingsScreens.PrivacyBlockedUsers)} > -
- {lang('BlockedUsers')} - {blockedCount > 0 && ( - - {lang('Users', blockedCount)} - - )} -
+ {lang('BlockedUsers')} + {blockedCount || ''} +
+ onScreenSelect(SettingsScreens.ActiveWebsites)} + > + {lang('PrivacySettings.WebSessions')} + {webAuthCount || ''} - {webAuthCount > 0 && ( - onScreenSelect(SettingsScreens.ActiveWebsites)} - > - {lang('PrivacySettings.WebSessions')} - {webAuthCount} - - )}