Reaction: Fix effect playback (#5152)

This commit is contained in:
zubiden 2024-11-09 15:40:13 +04:00 committed by Alexander Zinchuk
parent e678824a10
commit 5c9c5f0cd8

View File

@ -10,7 +10,7 @@ import type {
} from '../../../api/types'; } from '../../../api/types';
import type { ObserveFn } from '../../../hooks/useIntersectionObserver'; import type { ObserveFn } from '../../../hooks/useIntersectionObserver';
import { isSameReaction } from '../../../global/helpers'; import { getStickerHashById, isSameReaction } from '../../../global/helpers';
import { selectPerformanceSettingsValue, selectTabState } from '../../../global/selectors'; import { selectPerformanceSettingsValue, selectTabState } from '../../../global/selectors';
import buildClassName from '../../../util/buildClassName'; import buildClassName from '../../../util/buildClassName';
import { roundToNearestEven } from '../../../util/math'; import { roundToNearestEven } from '../../../util/math';
@ -112,11 +112,11 @@ const ReactionAnimatedEmoji = ({
const isIntersecting = useIsIntersecting(ref, observeIntersection); const isIntersecting = useIsIntersecting(ref, observeIntersection);
const mediaHashCenterIcon = centerIconId && `sticker${centerIconId}`; const mediaHashCenterIcon = centerIconId && getStickerHashById(centerIconId);
const mediaHashEffect = effectId && `sticker${effectId}`; const mediaHashEffect = effectId && getStickerHashById(effectId);
const mediaDataCenterIcon = useMedia(mediaHashCenterIcon, !centerIconId); const mediaDataCenterIcon = useMedia(mediaHashCenterIcon);
const mediaDataEffect = useMedia(mediaHashEffect, !effectId); const mediaDataEffect = useMedia(mediaHashEffect);
const activeReaction = useMemo(() => ( const activeReaction = useMemo(() => (
activeReactions?.find((active) => isSameReaction(active, reaction)) activeReactions?.find((active) => isSameReaction(active, reaction))
@ -173,6 +173,7 @@ const ReactionAnimatedEmoji = ({
noVideoOnMobile noVideoOnMobile
loopLimit={loopLimit} loopLimit={loopLimit}
observeIntersectionForPlaying={observeIntersection} observeIntersectionForPlaying={observeIntersection}
forceAlways
/> />
)} )}
{shouldRenderCenter && !isCustom && ( {shouldRenderCenter && !isCustom && (
@ -185,6 +186,7 @@ const ReactionAnimatedEmoji = ({
noLoop={!shouldLoop} noLoop={!shouldLoop}
onLoad={markAnimationLoaded} onLoad={markAnimationLoaded}
onEnded={unmarkAnimationLoaded} onEnded={unmarkAnimationLoaded}
forceAlways
/> />
)} )}
{shouldRenderEffect && ( {shouldRenderEffect && (
@ -197,6 +199,7 @@ const ReactionAnimatedEmoji = ({
play={isIntersecting} play={isIntersecting}
noLoop noLoop
onEnded={handleEnded} onEnded={handleEnded}
forceAlways
/> />
{isCustom && !assignedEffectId && isIntersecting && ( {isCustom && !assignedEffectId && isIntersecting && (
<CustomEmojiEffect <CustomEmojiEffect