From cb6c1faa86223500bb95a5b46dc3f6e17b8aed2f Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 24 Sep 2024 14:48:33 +0200 Subject: [PATCH] Sticker View: Disable grouped video custom emoji on mobile --- src/components/common/CustomEmoji.tsx | 3 +++ src/components/common/StickerButton.tsx | 1 + src/components/common/StickerView.tsx | 19 ++++++++++++------- .../reactions/ReactionAnimatedEmoji.tsx | 1 + 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/components/common/CustomEmoji.tsx b/src/components/common/CustomEmoji.tsx index 24a5746b8..0a1c08338 100644 --- a/src/components/common/CustomEmoji.tsx +++ b/src/components/common/CustomEmoji.tsx @@ -27,6 +27,7 @@ type OwnProps = { size?: number; isBig?: boolean; noPlay?: boolean; + noVideoOnMobile?: boolean; loopLimit?: number; isSelectable?: boolean; withSharedAnimation?: boolean; @@ -52,6 +53,7 @@ const CustomEmoji: FC = ({ size = STICKER_SIZE, isBig, noPlay, + noVideoOnMobile, loopLimit, isSelectable, withSharedAnimation, @@ -142,6 +144,7 @@ const CustomEmoji: FC = ({ isSmall={!isBig} size={size} noPlay={noPlay || !(shouldPlay && canPlay)} + noVideoOnMobile={noVideoOnMobile} thumbClassName={styles.thumb} fullMediaClassName={styles.media} shouldLoop diff --git a/src/components/common/StickerButton.tsx b/src/components/common/StickerButton.tsx index 7e165a0d5..22ba6b55b 100644 --- a/src/components/common/StickerButton.tsx +++ b/src/components/common/StickerButton.tsx @@ -299,6 +299,7 @@ const StickerButton = ; withTranslucentThumb?: boolean; // With shared canvas thumbs are opaque by default to provide better transition effect @@ -73,6 +74,7 @@ const StickerView: FC = ({ observeIntersectionForPlaying, noLoad, noPlay, + noVideoOnMobile, withSharedAnimation, withTranslucentThumb, sharedCanvasRef, @@ -83,8 +85,11 @@ const StickerView: FC = ({ id, isLottie, stickerSetInfo, emoji, } = sticker; const [isVideoBroken, markVideoBroken] = useFlag(); - const isUnsupportedVideo = sticker.isVideo && !IS_WEBM_SUPPORTED; - const isVideo = sticker.isVideo && !isUnsupportedVideo; + const isUnsupportedVideo = sticker.isVideo && ( + !IS_WEBM_SUPPORTED + || (noVideoOnMobile && (IS_IOS || IS_ANDROID)) + ); + const isVideo = sticker.isVideo; const isStatic = !isLottie && !isVideo; const previewMediaHash = getStickerMediaHash(sticker, 'preview'); @@ -115,7 +120,7 @@ const StickerView: FC = ({ fullMediaHash === previewMediaHash && (cachedPreview || previewMediaData) )); const fullMediaData = useMedia(fullMediaHash || `sticker${id}`, !shouldLoad || shouldSkipFullMedia); - const shouldRenderFullMedia = isReadyToMountFullMedia && fullMediaData && !isVideoBroken; + const shouldRenderFullMedia = isReadyToMountFullMedia && !shouldSkipFullMedia && fullMediaData && !isVideoBroken; const [isPlayerReady, markPlayerReady] = useFlag(); const isFullMediaReady = shouldRenderFullMedia && (isStatic || isPlayerReady); @@ -137,13 +142,13 @@ const StickerView: FC = ({ useMedia(previewMediaHash, !shouldLoad || !shouldPreloadPreview); const randomIdPrefix = useUniqueId(); - const renderId = [ + const renderId = useMemo(() => ([ (withSharedAnimation ? SHARED_PREFIX : randomIdPrefix), id, size, (withSharedAnimation ? customColor : undefined), dpr, - ].filter(Boolean).join('_'); + ].filter(Boolean).join('_')), [customColor, dpr, id, randomIdPrefix, size, withSharedAnimation]); return ( <> diff --git a/src/components/common/reactions/ReactionAnimatedEmoji.tsx b/src/components/common/reactions/ReactionAnimatedEmoji.tsx index f32d04b09..71f910423 100644 --- a/src/components/common/reactions/ReactionAnimatedEmoji.tsx +++ b/src/components/common/reactions/ReactionAnimatedEmoji.tsx @@ -166,6 +166,7 @@ const ReactionAnimatedEmoji = ({ className={styles.customEmoji} size={size} noPlay={shouldPause} + noVideoOnMobile loopLimit={loopLimit} observeIntersectionForPlaying={observeIntersection} />