Display .webm as unsupported in Safari
This commit is contained in:
parent
01eab0e1bb
commit
3e3f545477
6
src/environment/webmSupport.ts
Normal file
6
src/environment/webmSupport.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { IS_APPLE_MOBILE, IS_SAFARI } from "./userAgent";
|
||||
|
||||
const IS_WEBM_SUPPORTED = !!document.createElement('video').canPlayType('video/webm') && !IS_SAFARI && !IS_APPLE_MOBILE;
|
||||
|
||||
(window as any).IS_WEBM_SUPPORTED = IS_WEBM_SUPPORTED;
|
||||
export default IS_WEBM_SUPPORTED;
|
@ -23,6 +23,7 @@ import { MOUNT_CLASS_TO } from '../../config/debug';
|
||||
import { getFullDate } from '../../helpers/date';
|
||||
import rootScope from '../rootScope';
|
||||
import IS_WEBP_SUPPORTED from '../../environment/webpSupport';
|
||||
import IS_WEBM_SUPPORTED from '../../environment/webmSupport';
|
||||
|
||||
export type MyDocument = Document.document;
|
||||
|
||||
@ -97,7 +98,8 @@ export class AppDocsManager {
|
||||
// 'audioPerformer', 'sticker', 'stickerEmoji', 'stickerEmojiRaw',
|
||||
// 'stickerSetInput', 'stickerThumbConverted', 'animated', 'supportsStreaming']);
|
||||
|
||||
doc.attributes.forEach(attribute => {
|
||||
for(let i = 0, length = doc.attributes.length; i < length; ++i) {
|
||||
const attribute = doc.attributes[i];
|
||||
switch(attribute._) {
|
||||
case 'documentAttributeFilename':
|
||||
doc.file_name = RichTextProcessor.wrapPlainText(attribute.file_name);
|
||||
@ -145,6 +147,10 @@ export class AppDocsManager {
|
||||
doc.type = 'sticker';
|
||||
doc.sticker = 1;
|
||||
} else if(doc.mime_type === 'video/webm') {
|
||||
if(!IS_WEBM_SUPPORTED) {
|
||||
return;
|
||||
}
|
||||
|
||||
doc.type = 'sticker';
|
||||
doc.sticker = 3;
|
||||
doc.animated = true;
|
||||
@ -165,7 +171,7 @@ export class AppDocsManager {
|
||||
doc.animated = true;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(!doc.mime_type) {
|
||||
const ext = (doc.file_name || '').split('.').pop();
|
||||
|
@ -2539,6 +2539,7 @@ export class AppMessagesManager {
|
||||
} */
|
||||
|
||||
if(isMessage && message.media) {
|
||||
let unsupported = false;
|
||||
switch(message.media._) {
|
||||
case 'messageMediaEmpty': {
|
||||
delete message.media;
|
||||
@ -2547,7 +2548,7 @@ export class AppMessagesManager {
|
||||
|
||||
case 'messageMediaPhoto': {
|
||||
if(message.media.ttl_seconds) {
|
||||
message.media = {_: 'messageMediaUnsupported'};
|
||||
unsupported = true;
|
||||
} else {
|
||||
message.media.photo = appPhotosManager.savePhoto(message.media.photo, mediaContext);
|
||||
}
|
||||
@ -2568,9 +2569,14 @@ export class AppMessagesManager {
|
||||
|
||||
case 'messageMediaDocument': {
|
||||
if(message.media.ttl_seconds) {
|
||||
message.media = {_: 'messageMediaUnsupported'};
|
||||
unsupported = true;
|
||||
} else {
|
||||
message.media.document = appDocsManager.saveDoc(message.media.document, mediaContext); // 11.04.2020 warning
|
||||
const originalDoc = message.media.document;
|
||||
message.media.document = appDocsManager.saveDoc(originalDoc, mediaContext); // 11.04.2020 warning
|
||||
|
||||
if(!message.media.document && originalDoc._ !== 'documentEmpty') {
|
||||
unsupported = true;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
@ -2588,17 +2594,23 @@ export class AppMessagesManager {
|
||||
break; */
|
||||
|
||||
case 'messageMediaInvoice': {
|
||||
unsupported = true;
|
||||
message.media = {_: 'messageMediaUnsupported'};
|
||||
break;
|
||||
}
|
||||
|
||||
case 'messageMediaUnsupported': {
|
||||
message.message = '';
|
||||
delete message.entities;
|
||||
delete message.totalEntities;
|
||||
unsupported = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(unsupported) {
|
||||
message.media = {_: 'messageMediaUnsupported'};
|
||||
message.message = '';
|
||||
delete message.entities;
|
||||
delete message.totalEntities;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isMessage && message.action) {
|
||||
|
@ -20,6 +20,7 @@ import { getEmojiToneIndex } from '../../vendor/emoji';
|
||||
import RichTextProcessor from '../richtextprocessor';
|
||||
import assumeType from '../../helpers/assumeType';
|
||||
import fixBase64String from '../../helpers/fixBase64String';
|
||||
import IS_WEBM_SUPPORTED from '../../environment/webmSupport';
|
||||
|
||||
const CACHE_TIME = 3600e3;
|
||||
|
||||
@ -215,6 +216,7 @@ export class AppStickersManager {
|
||||
method: 'messages.getRecentStickers',
|
||||
processResult: (res) => {
|
||||
assumeType<MessagesRecentStickers.messagesRecentStickers>(res);
|
||||
|
||||
this.saveStickers(res.stickers);
|
||||
return res;
|
||||
}
|
||||
@ -379,6 +381,13 @@ export class AppStickersManager {
|
||||
method: 'messages.getFeaturedStickers',
|
||||
processResult: (res) => {
|
||||
assumeType<MessagesFeaturedStickers.messagesFeaturedStickers>(res);
|
||||
|
||||
forEachReverse(res.sets, (covered, idx, arr) => {
|
||||
if(covered.set.pFlags.videos && !IS_WEBM_SUPPORTED) {
|
||||
arr.splice(idx, 1);
|
||||
}
|
||||
});
|
||||
|
||||
res.sets.forEach(covered => {
|
||||
this.saveStickerSet({set: covered.set, documents: [], packs: []}, covered.set.id);
|
||||
});
|
||||
@ -430,6 +439,12 @@ export class AppStickersManager {
|
||||
processResult: (res) => {
|
||||
assumeType<MessagesFoundStickerSets.messagesFoundStickerSets>(res);
|
||||
|
||||
forEachReverse(res.sets, (covered, idx, arr) => {
|
||||
if(covered.set.pFlags.videos && !IS_WEBM_SUPPORTED) {
|
||||
arr.splice(idx, 1);
|
||||
}
|
||||
});
|
||||
|
||||
res.sets.forEach(covered => {
|
||||
this.saveStickerSet({set: covered.set, documents: [], packs: []}, covered.set.id);
|
||||
});
|
||||
@ -452,7 +467,20 @@ export class AppStickersManager {
|
||||
}
|
||||
|
||||
public getAllStickers() {
|
||||
return apiManager.invokeApiHashable({method: 'messages.getAllStickers'});
|
||||
return apiManager.invokeApiHashable({
|
||||
method: 'messages.getAllStickers',
|
||||
processResult: (allStickers) => {
|
||||
assumeType<MessagesAllStickers.messagesAllStickers>(allStickers);
|
||||
|
||||
forEachReverse(allStickers.sets, (stickerSet, idx, arr) => {
|
||||
if(stickerSet.pFlags.videos && !IS_WEBM_SUPPORTED) {
|
||||
arr.splice(idx, 1);
|
||||
}
|
||||
});
|
||||
|
||||
return allStickers;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public preloadStickerSets() {
|
||||
@ -471,7 +499,8 @@ export class AppStickersManager {
|
||||
method: 'messages.getStickers',
|
||||
params: {
|
||||
emoticon
|
||||
}
|
||||
},
|
||||
processResult: (stickers) => stickers
|
||||
}),
|
||||
includeOurStickers ? this.preloadStickerSets() : [],
|
||||
includeOurStickers ? this.getRecentStickers() : undefined
|
||||
@ -519,6 +548,12 @@ export class AppStickersManager {
|
||||
|
||||
const stickers = [...new Set(cachedStickersAnimated.concat(cachedStickersStatic, foundStickers))]/* .filter(doc => !doc.animated) */;
|
||||
|
||||
forEachReverse(stickers, (sticker, idx, arr) => {
|
||||
if(sticker.sticker === 3 && !IS_WEBM_SUPPORTED) {
|
||||
arr.splice(idx, 1);
|
||||
}
|
||||
});
|
||||
|
||||
return stickers;
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user