Redirect click from attachment div to preloader
Auto-download: Fix downloading thumb of video
This commit is contained in:
parent
03a21adbdc
commit
72b530aeb3
@ -60,7 +60,7 @@ import { toast } from "../toast";
|
||||
import { getElementByPoint } from "../../helpers/dom/getElementByPoint";
|
||||
import { getMiddleware } from "../../helpers/middleware";
|
||||
import { cancelEvent } from "../../helpers/dom/cancelEvent";
|
||||
import { attachClickEvent } from "../../helpers/dom/clickEvent";
|
||||
import { attachClickEvent, simulateClickEvent } from "../../helpers/dom/clickEvent";
|
||||
import htmlToDocumentFragment from "../../helpers/dom/htmlToDocumentFragment";
|
||||
import positionElementByIndex from "../../helpers/dom/positionElementByIndex";
|
||||
import reflowScrollableElement from "../../helpers/dom/reflowScrollableElement";
|
||||
@ -1387,6 +1387,13 @@ export default class ChatBubbles {
|
||||
return;
|
||||
}
|
||||
|
||||
const preloader = (groupedItem || bubble).querySelector<HTMLElement>('.preloader-container');
|
||||
if(preloader) {
|
||||
simulateClickEvent(preloader);
|
||||
cancelEvent(e);
|
||||
return;
|
||||
}
|
||||
|
||||
const SINGLE_MEDIA_CLASSNAME = 'webpage';
|
||||
const isSingleMedia = bubble.classList.contains(SINGLE_MEDIA_CLASSNAME);
|
||||
|
||||
@ -3212,7 +3219,7 @@ export default class ChatBubbles {
|
||||
isOut,
|
||||
group: CHAT_ANIMATION_GROUP,
|
||||
loadPromises,
|
||||
autoDownloadSize: this.chat.autoDownload.video,
|
||||
autoDownload: this.chat.autoDownload,
|
||||
});
|
||||
//}
|
||||
} else {
|
||||
@ -3401,7 +3408,7 @@ export default class ChatBubbles {
|
||||
middleware: this.getMiddleware(),
|
||||
group: CHAT_ANIMATION_GROUP,
|
||||
loadPromises,
|
||||
autoDownloadSize: this.chat.autoDownload.video,
|
||||
autoDownload: this.chat.autoDownload,
|
||||
searchContext: isRound ? {
|
||||
peerId: this.peerId,
|
||||
inputFilter: {_: 'inputMessagesFilterRoundVoice'},
|
||||
|
@ -83,7 +83,7 @@ mediaSizes.addEventListener('changeScreen', (from, to) => {
|
||||
}
|
||||
});
|
||||
|
||||
export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTail, isOut, middleware, lazyLoadQueue, noInfo, group, onlyPreview, withoutPreloader, loadPromises, noPlayButton, autoDownloadSize, size, searchContext}: {
|
||||
export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTail, isOut, middleware, lazyLoadQueue, noInfo, group, onlyPreview, withoutPreloader, loadPromises, noPlayButton, size, searchContext, autoDownload}: {
|
||||
doc: MyDocument,
|
||||
container?: HTMLElement,
|
||||
message?: Message.message,
|
||||
@ -99,10 +99,11 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai
|
||||
onlyPreview?: boolean,
|
||||
withoutPreloader?: boolean,
|
||||
loadPromises?: Promise<any>[],
|
||||
autoDownloadSize?: number,
|
||||
autoDownload?: ChatAutoDownloadSettings,
|
||||
size?: PhotoSize,
|
||||
searchContext?: MediaSearchContext,
|
||||
}) {
|
||||
const autoDownloadSize = autoDownload?.video;
|
||||
let noAutoDownload = autoDownloadSize === 0;
|
||||
const isAlbumItem = !(boxWidth && boxHeight);
|
||||
const canAutoplay = /* doc.sticker || */(
|
||||
@ -373,7 +374,7 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai
|
||||
middleware,
|
||||
withoutPreloader: true,
|
||||
loadPromises,
|
||||
autoDownloadSize,
|
||||
autoDownloadSize: autoDownload?.photo,
|
||||
size
|
||||
});
|
||||
|
||||
@ -1982,7 +1983,6 @@ export function wrapAlbum({groupId, attachmentDiv, middleware, uploading, lazyLo
|
||||
div.dataset.peerId = '' + message.peerId;
|
||||
const mediaDiv = div.firstElementChild as HTMLElement;
|
||||
const isPhoto = media._ === 'photo';
|
||||
const autoDownloadSize = autoDownload ? autoDownload[isPhoto ? 'photo' : 'video'] : undefined;
|
||||
if(isPhoto) {
|
||||
wrapPhoto({
|
||||
photo: media,
|
||||
@ -1995,7 +1995,7 @@ export function wrapAlbum({groupId, attachmentDiv, middleware, uploading, lazyLo
|
||||
middleware,
|
||||
size,
|
||||
loadPromises,
|
||||
autoDownloadSize
|
||||
autoDownloadSize: autoDownload.photo
|
||||
});
|
||||
} else {
|
||||
wrapVideo({
|
||||
@ -2009,7 +2009,7 @@ export function wrapAlbum({groupId, attachmentDiv, middleware, uploading, lazyLo
|
||||
lazyLoadQueue,
|
||||
middleware,
|
||||
loadPromises,
|
||||
autoDownloadSize
|
||||
autoDownload
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user