diff --git a/src/components/common/ProfilePhoto.tsx b/src/components/common/ProfilePhoto.tsx index d856cb032..d1272d2a4 100644 --- a/src/components/common/ProfilePhoto.tsx +++ b/src/components/common/ProfilePhoto.tsx @@ -110,7 +110,7 @@ const ProfilePhoto: FC = ({ disablePictureInPicture loop playsInline - onPlay={markVideoReady} + onReady={markVideoReady} /> ) : ( = ({ muted loop={!loopLimit} disablePictureInPicture - onPlay={markPlayerReady} + onReady={markPlayerReady} onEnded={onVideoEnded} /> ) : ( diff --git a/src/components/mediaViewer/helpers/ghostAnimation.ts b/src/components/mediaViewer/helpers/ghostAnimation.ts index 0ed68631b..616f50d51 100644 --- a/src/components/mediaViewer/helpers/ghostAnimation.ts +++ b/src/components/mediaViewer/helpers/ghostAnimation.ts @@ -338,7 +338,7 @@ function getNodes(origin: MediaViewerOrigin, message?: ApiMessage) { return { container, - mediaEl: mediaEls?.[mediaEls.length - 1], + mediaEl: mediaEls?.[0], }; } diff --git a/src/components/mediaViewer/hooks/useMediaProps.ts b/src/components/mediaViewer/hooks/useMediaProps.ts index d7d185b64..89756c290 100644 --- a/src/components/mediaViewer/hooks/useMediaProps.ts +++ b/src/components/mediaViewer/hooks/useMediaProps.ts @@ -73,7 +73,7 @@ export const useMediaProps = ({ return getChatAvatarHash(avatarOwner, isFull ? 'big' : 'normal'); } } - return message && getMessageMediaHash(message, isFull ? 'viewerFull' : 'viewerPreview'); + return message && getMessageMediaHash(message, isFull ? 'full' : 'preview'); }, [avatarOwner, message, avatarMedia, mediaId]); const pictogramBlobUrl = useMedia( @@ -97,7 +97,7 @@ export const useMediaProps = ({ } = useMediaWithLoadProgress( getMediaHash(true), undefined, - message && getMessageMediaFormat(message, 'viewerFull'), + message && getMessageMediaFormat(message, 'full'), undefined, delay, ); diff --git a/src/components/middle/MessageListContent.tsx b/src/components/middle/MessageListContent.tsx index 76a627b4c..9e9475c47 100644 --- a/src/components/middle/MessageListContent.tsx +++ b/src/components/middle/MessageListContent.tsx @@ -81,9 +81,9 @@ const MessageListContent: FC = ({ const { openHistoryCalendar } = getActions(); const { - observeIntersectionForMedia, observeIntersectionForReading, - observeIntersectionForAnimatedStickers, + observeIntersectionForLoading, + observeIntersectionForPlaying, } = useMessageObservers(type, containerRef, memoFirstUnreadIdRef); const { @@ -144,8 +144,8 @@ const MessageListContent: FC = ({ key={message.id} message={message} observeIntersectionForReading={observeIntersectionForReading} - observeIntersectionForLoading={observeIntersectionForMedia} - observeIntersectionForPlaying={observeIntersectionForAnimatedStickers} + observeIntersectionForLoading={observeIntersectionForLoading} + observeIntersectionForPlaying={observeIntersectionForPlaying} memoFirstUnreadIdRef={memoFirstUnreadIdRef} appearanceOrder={messageCountToAnimate - ++appearanceIndex} isLastInList={isLastInList} @@ -196,8 +196,8 @@ const MessageListContent: FC = ({ key={key} message={message} observeIntersectionForBottom={observeIntersectionForReading} - observeIntersectionForMedia={observeIntersectionForMedia} - observeIntersectionForAnimatedStickers={observeIntersectionForAnimatedStickers} + observeIntersectionForLoading={observeIntersectionForLoading} + observeIntersectionForPlaying={observeIntersectionForPlaying} album={album} noAvatars={noAvatars} withAvatar={position.isLastInGroup && withUsers && !isOwn && !(message.id === threadTopMessageId)} diff --git a/src/components/middle/hooks/useMessageObservers.ts b/src/components/middle/hooks/useMessageObservers.ts index 6a51d5837..e1922764b 100644 --- a/src/components/middle/hooks/useMessageObservers.ts +++ b/src/components/middle/hooks/useMessageObservers.ts @@ -7,9 +7,9 @@ import { IS_ANDROID, IS_SINGLE_COLUMN_LAYOUT } from '../../../util/environment'; import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver'; import useBackgroundMode from '../../../hooks/useBackgroundMode'; -const INTERSECTION_THROTTLE_FOR_MEDIA = IS_ANDROID ? 1000 : 350; -const INTERSECTION_MARGIN_FOR_MEDIA = IS_SINGLE_COLUMN_LAYOUT ? 300 : 500; const INTERSECTION_THROTTLE_FOR_READING = 150; +const INTERSECTION_THROTTLE_FOR_MEDIA = IS_ANDROID ? 1000 : 350; +const INTERSECTION_MARGIN_FOR_LOADING = IS_SINGLE_COLUMN_LAYOUT ? 300 : 500; export default function useMessageObservers( type: MessageListType, @@ -18,14 +18,6 @@ export default function useMessageObservers( ) { const { markMessageListRead, markMentionsRead, animateUnreadReaction } = getActions(); - const { - observe: observeIntersectionForMedia, - } = useIntersectionObserver({ - rootRef: containerRef, - throttleMs: INTERSECTION_THROTTLE_FOR_MEDIA, - margin: INTERSECTION_MARGIN_FOR_MEDIA, - }); - const { observe: observeIntersectionForReading, freeze: freezeForReading, unfreeze: unfreezeForReading, } = useIntersectionObserver({ @@ -78,14 +70,22 @@ export default function useMessageObservers( useBackgroundMode(freezeForReading, unfreezeForReading); - const { observe: observeIntersectionForAnimatedStickers } = useIntersectionObserver({ + const { + observe: observeIntersectionForLoading, + } = useIntersectionObserver({ + rootRef: containerRef, + throttleMs: INTERSECTION_THROTTLE_FOR_MEDIA, + margin: INTERSECTION_MARGIN_FOR_LOADING, + }); + + const { observe: observeIntersectionForPlaying } = useIntersectionObserver({ rootRef: containerRef, throttleMs: INTERSECTION_THROTTLE_FOR_MEDIA, }); return { - observeIntersectionForMedia, observeIntersectionForReading, - observeIntersectionForAnimatedStickers, + observeIntersectionForLoading, + observeIntersectionForPlaying, }; } diff --git a/src/components/middle/message/Album.tsx b/src/components/middle/message/Album.tsx index 569f9bb12..a5d089fde 100644 --- a/src/components/middle/message/Album.tsx +++ b/src/components/middle/message/Album.tsx @@ -84,7 +84,7 @@ const Album: FC = ({ = ({ = ({ message, chatUsername, observeIntersectionForBottom, - observeIntersectionForMedia, - observeIntersectionForAnimatedStickers, + observeIntersectionForLoading, + observeIntersectionForPlaying, album, noAvatars, withAvatar, @@ -634,7 +634,7 @@ const Message: FC = ({ text={hiddenName} lastSyncTime={lastSyncTime} onClick={(avatarUser || avatarChat) ? handleAvatarClick : undefined} - observeIntersection={observeIntersectionForMedia} + observeIntersection={observeIntersectionForLoading} animationLevel={animationLevel} withVideo /> @@ -693,16 +693,16 @@ const Message: FC = ({ noUserColors={isOwn} isProtected={isProtected} sender={replyMessageSender} - observeIntersectionForLoading={observeIntersectionForMedia} - observeIntersectionForPlaying={observeIntersectionForAnimatedStickers} + observeIntersectionForLoading={observeIntersectionForLoading} + observeIntersectionForPlaying={observeIntersectionForPlaying} onClick={handleReplyClick} /> )} {sticker && ( = ({ customEmojiId={animatedCustomEmoji} withEffects={isUserId(chatId)} isOwn={isOwn} - observeIntersection={observeIntersectionForMedia} + observeIntersection={observeIntersectionForLoading} lastSyncTime={lastSyncTime} forceLoadPreview={isLocal} messageId={messageId} @@ -732,7 +732,7 @@ const Message: FC = ({ emoji={animatedEmoji} withEffects={isUserId(chatId)} isOwn={isOwn} - observeIntersection={observeIntersectionForMedia} + observeIntersection={observeIntersectionForLoading} lastSyncTime={lastSyncTime} forceLoadPreview={isLocal} messageId={messageId} @@ -744,7 +744,7 @@ const Message: FC = ({ = ({ {!isAlbum && photo && ( = ({ {!isAlbum && video && video.isRound && ( = ({ {!isAlbum && video && !video.isRound && (