mirror of
https://github.com/danog/telegram-tt.git
synced 2025-01-22 05:11:55 +01:00
Message / Album: Fix video auto-play
This commit is contained in:
parent
d7e6ebfe06
commit
7e7eabdc42
@ -6,11 +6,16 @@ import { IAlbum, ISettings } from '../../../types';
|
|||||||
import { AlbumRectPart, IAlbumLayout } from './helpers/calculateAlbumLayout';
|
import { AlbumRectPart, IAlbumLayout } from './helpers/calculateAlbumLayout';
|
||||||
|
|
||||||
import { getMessageContent } from '../../../modules/helpers';
|
import { getMessageContent } from '../../../modules/helpers';
|
||||||
import { withGlobal } from '../../../lib/teact/teactn';
|
import { getGlobal, withGlobal } from '../../../lib/teact/teactn';
|
||||||
import { pick } from '../../../util/iteratees';
|
import { pick } from '../../../util/iteratees';
|
||||||
import withSelectControl from './hocs/withSelectControl';
|
import withSelectControl from './hocs/withSelectControl';
|
||||||
import { ObserveFn } from '../../../hooks/useIntersectionObserver';
|
import { ObserveFn } from '../../../hooks/useIntersectionObserver';
|
||||||
import { selectActiveDownloadIds, selectTheme } from '../../../modules/selectors';
|
import {
|
||||||
|
selectActiveDownloadIds,
|
||||||
|
selectCanAutoLoadMedia,
|
||||||
|
selectCanAutoPlayMedia,
|
||||||
|
selectTheme,
|
||||||
|
} from '../../../modules/selectors';
|
||||||
|
|
||||||
import Photo from './Photo';
|
import Photo from './Photo';
|
||||||
import Video from './Video';
|
import Video from './Video';
|
||||||
@ -23,8 +28,6 @@ const VideoWithSelect = withSelectControl(Video);
|
|||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
album: IAlbum;
|
album: IAlbum;
|
||||||
observeIntersection: ObserveFn;
|
observeIntersection: ObserveFn;
|
||||||
canAutoLoad?: boolean;
|
|
||||||
canAutoPlay?: boolean;
|
|
||||||
hasCustomAppendix?: boolean;
|
hasCustomAppendix?: boolean;
|
||||||
lastSyncTime?: number;
|
lastSyncTime?: number;
|
||||||
isOwn: boolean;
|
isOwn: boolean;
|
||||||
@ -43,8 +46,6 @@ type DispatchProps = Pick<GlobalActions, 'cancelSendingMessage'>;
|
|||||||
const Album: FC<OwnProps & StateProps & DispatchProps> = ({
|
const Album: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||||
album,
|
album,
|
||||||
observeIntersection,
|
observeIntersection,
|
||||||
canAutoLoad,
|
|
||||||
canAutoPlay,
|
|
||||||
hasCustomAppendix,
|
hasCustomAppendix,
|
||||||
lastSyncTime,
|
lastSyncTime,
|
||||||
isOwn,
|
isOwn,
|
||||||
@ -67,6 +68,10 @@ const Album: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
const uploadProgress = fileUpload?.progress;
|
const uploadProgress = fileUpload?.progress;
|
||||||
const { dimensions, sides } = albumLayout.layout[index];
|
const { dimensions, sides } = albumLayout.layout[index];
|
||||||
|
|
||||||
|
// Ignoring global updates is a known drawback here
|
||||||
|
const canAutoLoad = selectCanAutoLoadMedia(getGlobal(), message);
|
||||||
|
const canAutoPlay = selectCanAutoPlayMedia(getGlobal(), message);
|
||||||
|
|
||||||
if (photo) {
|
if (photo) {
|
||||||
const shouldAffectAppendix = hasCustomAppendix && (
|
const shouldAffectAppendix = hasCustomAppendix && (
|
||||||
// eslint-disable-next-line no-bitwise
|
// eslint-disable-next-line no-bitwise
|
||||||
|
@ -508,8 +508,6 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
album={album!}
|
album={album!}
|
||||||
albumLayout={albumLayout!}
|
albumLayout={albumLayout!}
|
||||||
observeIntersection={observeIntersectionForMedia}
|
observeIntersection={observeIntersectionForMedia}
|
||||||
canAutoLoad={canAutoLoadMedia}
|
|
||||||
canAutoPlay={canAutoPlayMedia}
|
|
||||||
isOwn={isOwn}
|
isOwn={isOwn}
|
||||||
hasCustomAppendix={hasCustomAppendix}
|
hasCustomAppendix={hasCustomAppendix}
|
||||||
lastSyncTime={lastSyncTime}
|
lastSyncTime={lastSyncTime}
|
||||||
@ -892,7 +890,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
threadId,
|
threadId,
|
||||||
isDownloading,
|
isDownloading,
|
||||||
isPinnedList: messageListType === 'pinned',
|
isPinnedList: messageListType === 'pinned',
|
||||||
canAutoLoadMedia: chat ? selectCanAutoLoadMedia(global, message, chat, sender) : undefined,
|
canAutoLoadMedia: selectCanAutoLoadMedia(global, message),
|
||||||
canAutoPlayMedia: selectCanAutoPlayMedia(global, message),
|
canAutoPlayMedia: selectCanAutoPlayMedia(global, message),
|
||||||
autoLoadFileMaxSizeMb: global.settings.byKey.autoLoadFileMaxSizeMb,
|
autoLoadFileMaxSizeMb: global.settings.byKey.autoLoadFileMaxSizeMb,
|
||||||
shouldLoopStickers: selectShouldLoopStickers(global),
|
shouldLoopStickers: selectShouldLoopStickers(global),
|
||||||
|
@ -734,9 +734,14 @@ export function selectNewestMessageWithBotKeyboardButtons(
|
|||||||
return messageId ? chatMessages[messageId] : undefined;
|
return messageId ? chatMessages[messageId] : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function selectCanAutoLoadMedia(
|
export function selectCanAutoLoadMedia(global: GlobalState, message: ApiMessage) {
|
||||||
global: GlobalState, message: ApiMessage, chat: ApiChat, sender?: ApiChat | ApiUser,
|
const chat = selectChat(global, message.chatId);
|
||||||
) {
|
if (!chat) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const sender = selectSender(global, message);
|
||||||
|
|
||||||
const isPhoto = Boolean(getMessagePhoto(message) || getMessageWebPagePhoto(message));
|
const isPhoto = Boolean(getMessagePhoto(message) || getMessageWebPagePhoto(message));
|
||||||
const isVideo = Boolean(getMessageVideo(message) || getMessageWebPageVideo(message));
|
const isVideo = Boolean(getMessageVideo(message) || getMessageWebPageVideo(message));
|
||||||
const isFile = Boolean(getMessageAudio(message) || getMessageVoice(message) || getMessageDocument(message));
|
const isFile = Boolean(getMessageAudio(message) || getMessageVoice(message) || getMessageDocument(message));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user