mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-04 02:28:03 +01:00
Sticker Button: Prevent loading full non-animated sticker
This commit is contained in:
parent
ca3dccba12
commit
954533ac2f
@ -34,7 +34,6 @@ const StickerButton: FC<OwnProps> = ({
|
|||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const { isAnimated } = sticker;
|
|
||||||
const localMediaHash = `sticker${sticker.id}`;
|
const localMediaHash = `sticker${sticker.id}`;
|
||||||
const stickerSelector = `sticker-button-${sticker.id}`;
|
const stickerSelector = `sticker-button-${sticker.id}`;
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ const StickerButton: FC<OwnProps> = ({
|
|||||||
const previewBlobUrl = useMedia(`${localMediaHash}?size=m`, !isIntersecting, ApiMediaFormat.BlobUrl);
|
const previewBlobUrl = useMedia(`${localMediaHash}?size=m`, !isIntersecting, ApiMediaFormat.BlobUrl);
|
||||||
|
|
||||||
const shouldPlay = isIntersecting && !noAnimate;
|
const shouldPlay = isIntersecting && !noAnimate;
|
||||||
const lottieData = useMedia(localMediaHash, !shouldPlay, ApiMediaFormat.Lottie);
|
const lottieData = useMedia(sticker.isAnimated && localMediaHash, !shouldPlay, ApiMediaFormat.Lottie);
|
||||||
const [isAnimationLoaded, markLoaded, unmarkLoaded] = useFlag(Boolean(lottieData));
|
const [isAnimationLoaded, markLoaded, unmarkLoaded] = useFlag(Boolean(lottieData));
|
||||||
const canAnimatedPlay = isAnimationLoaded && shouldPlay;
|
const canAnimatedPlay = isAnimationLoaded && shouldPlay;
|
||||||
|
|
||||||
@ -76,7 +75,7 @@ const StickerButton: FC<OwnProps> = ({
|
|||||||
|
|
||||||
const fullClassName = buildClassName(
|
const fullClassName = buildClassName(
|
||||||
'StickerButton',
|
'StickerButton',
|
||||||
isAnimated && 'animated',
|
sticker.isAnimated && 'animated',
|
||||||
stickerSelector,
|
stickerSelector,
|
||||||
className,
|
className,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user