Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/appMediaViewerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,7 @@ export default class AppMediaViewerBase<

const isLiveStream = media._ === 'inputGroupCall';
const isDocument = media._ === 'document';
const isVideo = isDocument && media.mime_type && ((['video', 'gif'] as MyDocument['type'][]).includes(media.type) || media.mime_type.indexOf('video/') === 0);
const isVideo = isDocument && media.mime_type && media.mime_type !== 'image/avif' && ((['video', 'gif'] as MyDocument['type'][]).includes(media.type) || media.mime_type.indexOf('video/') === 0);
let isHlsStream: boolean;

this.log('openMedia', media, fromId, prevTargets, nextTargets, isLiveStream, isDocument, isVideo);
Expand Down
3 changes: 2 additions & 1 deletion src/components/popups/newMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ export default class PopupNewMedia extends PopupElement {
const PHOTO_SIDE_LIMIT = 2560;
let url = image.src, scaledBlob: Blob;
if(
mimeType !== 'image/gif' &&
mimeType !== 'image/gif' && mimeType !== 'image/avif' &&
(Math.max(image.naturalWidth, image.naturalHeight) > PHOTO_SIDE_LIMIT || (convertIncompatible && !SERVER_IMAGE_MIME_TYPES.has(mimeType)))
) {
const {blob} = await scaleMediaElement({
Expand Down Expand Up @@ -1413,6 +1413,7 @@ export default class PopupNewMedia extends PopupElement {
params.itemDiv = itemDiv;

const promise = shouldCompress ? this.attachMedia(params) : this.attachDocument(params);

willAttach.sendFileDetails.push(params);
return promise.catch((err) => {
itemDiv.style.backgroundColor = '#000';
Expand Down
4 changes: 2 additions & 2 deletions src/components/wrappers/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default async function wrapVideo({doc, altDoc, container, message, boxWid
}
}
} else {
spanTime.innerText = 'GIF';
spanTime.innerText = (doc.mime_type == "image/avif" && 'AVIF') || 'GIF';

if(!canAutoplay && !noPlayButton) {
needPlayButton = true;
Expand All @@ -186,7 +186,7 @@ export default async function wrapVideo({doc, altDoc, container, message, boxWid
loadPromise: Promise<any>
} = {} as any;

if(doc.mime_type === 'image/gif') {
if(doc.mime_type === 'image/gif' || doc.mime_type === 'image/avif') {
const photoRes = await wrapPhoto({
photo: doc,
message,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/appManagers/appDocsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class AppDocsManager extends AppManager {
}
} else if(doc.mime_type === EXTENSION_MIME_TYPE_MAP.pdf) {
doc.type = 'pdf';
} else if(doc.mime_type === EXTENSION_MIME_TYPE_MAP.gif) {
} else if(doc.mime_type === EXTENSION_MIME_TYPE_MAP.gif || doc.mime_type === EXTENSION_MIME_TYPE_MAP.avif) {
doc.type = 'gif';
} else if(doc.mime_type === EXTENSION_MIME_TYPE_MAP.tgs && doc.file_name === 'AnimatedSticker.tgs') {
doc.type = 'sticker';
Expand Down
3 changes: 3 additions & 0 deletions src/lib/appManagers/appMessagesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,9 @@ export class AppMessagesManager extends AppManager {
if(isDocument) {
file = this.appDocsManager.getDoc((file as MyDocument).id) || file;
}
if(file.type === 'image/avif') {
options.isMedia = null; // telegram server rejects the request if isMedia is true
}

const hadMessageBefore = !!options.groupedMessage;
const message = options.groupedMessage || this.generateOutgoingMessage(peerId, options);
Expand Down