Custom Emoji: Various fixes

This commit is contained in:
Alexander Zinchuk 2022-10-18 14:32:05 +02:00
parent 88f0e36372
commit fc9bd68a16
2 changed files with 9 additions and 1 deletions

View File

@ -18,6 +18,7 @@ import useEnsureCustomEmoji from '../../hooks/useEnsureCustomEmoji';
import { useIsIntersecting } from '../../hooks/useIntersectionObserver'; import { useIsIntersecting } from '../../hooks/useIntersectionObserver';
import useThumbnail from '../../hooks/useThumbnail'; import useThumbnail from '../../hooks/useThumbnail';
import useCustomEmoji from './hooks/useCustomEmoji'; import useCustomEmoji from './hooks/useCustomEmoji';
import safePlay from '../../util/safePlay';
import AnimatedSticker from './AnimatedSticker'; import AnimatedSticker from './AnimatedSticker';
import OptimizedVideo from '../ui/OptimizedVideo'; import OptimizedVideo from '../ui/OptimizedVideo';
@ -85,12 +86,17 @@ const CustomEmoji: FC<OwnProps> = ({
if (loopCountRef.current >= loopLimit) { if (loopCountRef.current >= loopLimit) {
setShouldLoop(false); setShouldLoop(false);
e.currentTarget.currentTime = 0; e.currentTarget.currentTime = 0;
} else {
// Loop manually
safePlay(e.currentTarget);
} }
}, [loopLimit]); }, [loopLimit]);
const handleStickerLoop = useCallback(() => { const handleStickerLoop = useCallback(() => {
if (!loopLimit) return; if (!loopLimit) return;
loopCountRef.current += 1; loopCountRef.current += 1;
// Sticker plays 1 more time after disabling loop // Sticker plays 1 more time after disabling loop
if (loopCountRef.current >= loopLimit - 1) { if (loopCountRef.current >= loopLimit - 1) {
setShouldLoop(false); setShouldLoop(false);
@ -117,7 +123,7 @@ const CustomEmoji: FC<OwnProps> = ({
if (customEmoji.isVideo) { if (customEmoji.isVideo) {
return ( return (
<OptimizedVideo <OptimizedVideo
canPlay={isIntersecting} canPlay={isIntersecting && shouldLoop}
className={styles.media} className={styles.media}
src={mediaData} src={mediaData}
playsInline playsInline

View File

@ -332,6 +332,7 @@ const MiddleHeader: FC<OwnProps & StateProps> = ({
<div className="chat-info-wrapper" onClick={handleHeaderClick}> <div className="chat-info-wrapper" onClick={handleHeaderClick}>
{isUserId(chatId) ? ( {isUserId(chatId) ? (
<PrivateChatInfo <PrivateChatInfo
key={chatId}
userId={chatId} userId={chatId}
typingStatus={typingStatus} typingStatus={typingStatus}
status={connectionStatusText} status={connectionStatusText}
@ -344,6 +345,7 @@ const MiddleHeader: FC<OwnProps & StateProps> = ({
/> />
) : ( ) : (
<GroupChatInfo <GroupChatInfo
key={chatId}
chatId={chatId} chatId={chatId}
typingStatus={typingStatus} typingStatus={typingStatus}
status={connectionStatusText} status={connectionStatusText}