mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-26 20:34:44 +01:00
Settings: Fix various flickers
This commit is contained in:
parent
1da2a9fad5
commit
e1ca21fc46
@ -55,7 +55,7 @@ function AnimatedIcon(props: OwnProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<AnimatedSticker
|
<AnimatedSticker
|
||||||
className={buildClassName(className, transitionClassNames, 'shown')}
|
className={buildClassName(className, transitionClassNames)}
|
||||||
size={size}
|
size={size}
|
||||||
play={play === true ? playKey : play}
|
play={play === true ? playKey : play}
|
||||||
noLoop={noLoop}
|
noLoop={noLoop}
|
||||||
|
@ -31,6 +31,7 @@ function AnimatedIconFromSticker(props: OwnProps) {
|
|||||||
<AnimatedIconWithPreview
|
<AnimatedIconWithPreview
|
||||||
tgsUrl={tgsUrl}
|
tgsUrl={tgsUrl}
|
||||||
previewUrl={previewBlobUrl}
|
previewUrl={previewBlobUrl}
|
||||||
|
noPreviewTransition
|
||||||
thumbDataUri={thumbDataUri}
|
thumbDataUri={thumbDataUri}
|
||||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { memo } from '../../lib/teact/teact';
|
import React, { memo, useCallback } from '../../lib/teact/teact';
|
||||||
|
|
||||||
import type { OwnProps as AnimatedIconProps } from './AnimatedIcon';
|
import type { OwnProps as AnimatedIconProps } from './AnimatedIcon';
|
||||||
|
|
||||||
@ -12,15 +12,24 @@ import buildStyle from '../../util/buildStyle';
|
|||||||
|
|
||||||
type OwnProps =
|
type OwnProps =
|
||||||
Partial<AnimatedIconProps>
|
Partial<AnimatedIconProps>
|
||||||
& { previewUrl?: string; thumbDataUri?: string };
|
& { previewUrl?: string; thumbDataUri?: string; noPreviewTransition?: boolean };
|
||||||
|
|
||||||
|
const loadedPreviewUrls = new Set();
|
||||||
|
|
||||||
function AnimatedIconWithPreview(props: OwnProps) {
|
function AnimatedIconWithPreview(props: OwnProps) {
|
||||||
const {
|
const {
|
||||||
previewUrl, thumbDataUri, className, ...otherProps
|
previewUrl, thumbDataUri, noPreviewTransition, className, ...otherProps
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const transitionClassNames = useMediaTransition(previewUrl);
|
const [isPreviewLoaded, markPreviewLoaded] = useFlag(loadedPreviewUrls.has(previewUrl));
|
||||||
|
const previewClassNames = useMediaTransition(noPreviewTransition || isPreviewLoaded);
|
||||||
const [isAnimationReady, markAnimationReady] = useFlag(false);
|
const [isAnimationReady, markAnimationReady] = useFlag(false);
|
||||||
|
|
||||||
|
const handlePreviewLoad = useCallback(() => {
|
||||||
|
markPreviewLoaded();
|
||||||
|
loadedPreviewUrls.add(previewUrl);
|
||||||
|
}, [markPreviewLoaded, previewUrl]);
|
||||||
|
|
||||||
const { size } = props;
|
const { size } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -34,7 +43,11 @@ function AnimatedIconWithPreview(props: OwnProps) {
|
|||||||
)}
|
)}
|
||||||
{!isAnimationReady && (
|
{!isAnimationReady && (
|
||||||
// eslint-disable-next-line jsx-a11y/alt-text
|
// eslint-disable-next-line jsx-a11y/alt-text
|
||||||
<img src={previewUrl} className={buildClassName(styles.preview, transitionClassNames)} />
|
<img
|
||||||
|
src={previewUrl}
|
||||||
|
className={buildClassName(styles.preview, previewClassNames)}
|
||||||
|
onLoad={handlePreviewLoad}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
|
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
|
||||||
<AnimatedIcon {...otherProps} onLoad={markAnimationReady} noTransition />
|
<AnimatedIcon {...otherProps} onLoad={markAnimationReady} noTransition />
|
||||||
|
@ -137,29 +137,20 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
|
|||||||
<div className="settings-item pt-3">
|
<div className="settings-item pt-3">
|
||||||
<ListItem
|
<ListItem
|
||||||
icon="delete-user"
|
icon="delete-user"
|
||||||
narrow
|
|
||||||
// eslint-disable-next-line react/jsx-no-bind
|
// eslint-disable-next-line react/jsx-no-bind
|
||||||
onClick={() => onScreenSelect(SettingsScreens.PrivacyBlockedUsers)}
|
onClick={() => onScreenSelect(SettingsScreens.PrivacyBlockedUsers)}
|
||||||
>
|
>
|
||||||
<div className="multiline-menu-item">
|
{lang('BlockedUsers')}
|
||||||
<span className="title">{lang('BlockedUsers')}</span>
|
<span className="settings-item__current-value">{blockedCount || ''}</span>
|
||||||
{blockedCount > 0 && (
|
|
||||||
<span className="subtitle" dir="auto">
|
|
||||||
{lang('Users', blockedCount)}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</ListItem>
|
</ListItem>
|
||||||
{webAuthCount > 0 && (
|
|
||||||
<ListItem
|
<ListItem
|
||||||
icon="web"
|
icon="web"
|
||||||
// eslint-disable-next-line react/jsx-no-bind
|
// eslint-disable-next-line react/jsx-no-bind
|
||||||
onClick={() => onScreenSelect(SettingsScreens.ActiveWebsites)}
|
onClick={() => onScreenSelect(SettingsScreens.ActiveWebsites)}
|
||||||
>
|
>
|
||||||
{lang('PrivacySettings.WebSessions')}
|
{lang('PrivacySettings.WebSessions')}
|
||||||
<span className="settings-item__current-value">{webAuthCount}</span>
|
<span className="settings-item__current-value">{webAuthCount || ''}</span>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
)}
|
|
||||||
<ListItem
|
<ListItem
|
||||||
icon="key"
|
icon="key"
|
||||||
narrow
|
narrow
|
||||||
|
Loading…
Reference in New Issue
Block a user