diff --git a/src/components/chatInput.ts b/src/components/chatInput.ts index ed52315f..bbec650b 100644 --- a/src/components/chatInput.ts +++ b/src/components/chatInput.ts @@ -92,7 +92,8 @@ export class ChatInput { encoderSampleRate: 48000, monitorGain: 0, numberOfChannels: 1, - recordingGain: 1 + recordingGain: 1, + reuseWorker: true }); } catch(err) { this.btnSend.classList.remove('tgico-microphone2'); diff --git a/src/components/emoticonsDropdown.ts b/src/components/emoticonsDropdown.ts index 2deae6b3..0ff36f0c 100644 --- a/src/components/emoticonsDropdown.ts +++ b/src/components/emoticonsDropdown.ts @@ -345,7 +345,7 @@ const initEmoticonsDropdown = (pageEl: HTMLDivElement, let prevCategoryIndex = 0; let stickersScroll = new Scrollable(contentStickersDiv, 'y', 'STICKERS', undefined, undefined, 2); stickersScroll.container.addEventListener('scroll', (e) => { - lottieLoader.checkAnimations(); + lottieLoader.checkAnimations(false, EMOTICONSSTICKERGROUP); prevCategoryIndex = emoticonsContentOnScroll(menu, heights, prevCategoryIndex, stickersScroll.container, menuScroll); }); diff --git a/src/components/lazyLoadQueue.ts b/src/components/lazyLoadQueue.ts index 4bdb5871..a9ce6f26 100644 --- a/src/components/lazyLoadQueue.ts +++ b/src/components/lazyLoadQueue.ts @@ -13,7 +13,7 @@ export default class LazyLoadQueue { private unlockResolve: () => void = null; private log = console.log.bind(console, '[LL]:'); - private debug = true; + private debug = false; private observer: IntersectionObserver; diff --git a/src/components/preloader.ts b/src/components/preloader.ts index 12994891..55974900 100644 --- a/src/components/preloader.ts +++ b/src/components/preloader.ts @@ -61,7 +61,7 @@ export default class ProgressivePreloader { promise.notify = (details: {done: number, total: number}) => { if(tempID != this.tempID) return; - console.log('preloader download', promise, details); + //console.log('preloader download', promise, details); let percents = details.done / details.total * 100; this.setProgress(percents); }; @@ -116,7 +116,7 @@ export default class ProgressivePreloader { } let totalLength = this.circle.getTotalLength(); - console.log('setProgress', (percents / 100 * totalLength)); + //console.log('setProgress', (percents / 100 * totalLength)); this.circle.style.strokeDasharray = '' + Math.max(5, percents / 100 * totalLength) + ', 200'; } } diff --git a/src/components/wrappers.ts b/src/components/wrappers.ts index a38f7369..fe46e25b 100644 --- a/src/components/wrappers.ts +++ b/src/components/wrappers.ts @@ -2,12 +2,10 @@ import appPhotosManager from '../lib/appManagers/appPhotosManager'; //import CryptoWorker from '../lib/crypto/cryptoworker'; import apiManager from '../lib/mtproto/mtprotoworker'; import LottieLoader from '../lib/lottieLoader'; -import appStickersManager from "../lib/appManagers/appStickersManager"; import appDocsManager from "../lib/appManagers/appDocsManager"; import { formatBytes, getEmojiToneIndex } from "../lib/utils"; import ProgressivePreloader from './preloader'; import LazyLoadQueue from './lazyLoadQueue'; -import apiFileManager from '../lib/mtproto/apiFileManager'; import VideoPlayer, { MediaProgressLine } from '../lib/mediaPlayer'; import { RichTextProcessor } from '../lib/richtextprocessor'; import { CancellablePromise } from '../lib/polyfill'; @@ -30,6 +28,10 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai middleware: () => boolean, lazyLoadQueue: LazyLoadQueue }) { + if(doc.type == 'video') { + return wrapPhoto(doc, message, container, boxWidth, boxHeight, withTail, isOut, lazyLoadQueue, middleware); + } + let img: HTMLImageElement; if(withTail) { img = wrapMediaWithTail(doc, message, container, boxWidth, boxHeight, isOut); @@ -49,7 +51,7 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai if(!img || img.tagName != 'IMG') { container.append(img = new Image()); } - } + } let video = document.createElement('video'); let source = document.createElement('source'); @@ -95,17 +97,19 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai return; } - console.log('loaded doc:', doc, doc.url, container); + //console.log('loaded doc:', doc, doc.url, container); renderImageFromUrl(source, doc.url); source.type = doc.mime_type; video.append(source); + video.setAttribute('playsinline', ''); if(img && img.parentElement) { img.remove(); } if(doc.type == 'gif') { + video.muted = true; video.autoplay = true; video.loop = true; video.play(); @@ -687,7 +691,7 @@ function wrapMediaWithTail(photo: any, message: {mid: number, message: string}, return img; } -export function wrapPhoto(photoID: string, message: any, container: HTMLDivElement, boxWidth = mediaSizes.active.regular.width, boxHeight = mediaSizes.active.regular.height, withTail = true, isOut = false, lazyLoadQueue: LazyLoadQueue, middleware: () => boolean, size: MTPhotoSize = null) { +export function wrapPhoto(photoID: any, message: any, container: HTMLDivElement, boxWidth = mediaSizes.active.regular.width, boxHeight = mediaSizes.active.regular.height, withTail = true, isOut = false, lazyLoadQueue: LazyLoadQueue, middleware: () => boolean, size: MTPhotoSize = null) { let photo = appPhotosManager.getPhoto(photoID); let image: HTMLImageElement; @@ -734,7 +738,7 @@ export function wrapPhoto(photoID: string, message: any, container: HTMLDivEleme return promise.then(() => { if(middleware && !middleware()) return; - renderImageFromUrl(image || container, photo.url); + renderImageFromUrl(image || container, photo._ == 'photo' ? photo.url : appPhotosManager.getDocumentCachedThumb(photo.id).url); }); }; @@ -865,8 +869,8 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o loop: !emoji, autoplay: true, animationData: JSON.parse(json), - width: !emoji ? 200 : 140, - height: !emoji ? 200 : 140 + width: !emoji ? 200 : undefined, + height: !emoji ? 200 : undefined }, group, toneIndex); animation.addListener('ready', () => { @@ -932,31 +936,34 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o return lazyLoadQueue && (!doc.downloaded || stickerType == 2) ? (lazyLoadQueue.push({div, load, wasSeen: group == 'chat' && stickerType != 2}), Promise.resolve()) : load(); } -export function wrapReply(title: string, subtitle: string, message?: any) { - let div = document.createElement('div'); - div.classList.add('reply'); +export function wrapReply(title: string, subtitle: string, message?: any, isPinned?: boolean) { + const prefix = isPinned ? 'pinned-message' : 'reply'; + const div = document.createElement('div'); + div.classList.add(prefix); - let replyBorder = document.createElement('div'); - replyBorder.classList.add('reply-border'); + const replyBorder = document.createElement('div'); + replyBorder.classList.add(prefix + '-border'); - let replyContent = document.createElement('div'); - replyContent.classList.add('reply-content'); + const replyContent = document.createElement('div'); + replyContent.classList.add(prefix + '-content'); - let replyTitle = document.createElement('div'); - replyTitle.classList.add('reply-title'); + const replyTitle = document.createElement('div'); + replyTitle.classList.add(prefix + '-title'); - let replySubtitle = document.createElement('div'); - replySubtitle.classList.add('reply-subtitle'); + const replySubtitle = document.createElement('div'); + replySubtitle.classList.add(prefix + '-subtitle'); replyTitle.innerHTML = title ? RichTextProcessor.wrapEmojiText(title) : ''; - let media = message && message.media; + const media = message && message.media; if(media) { replySubtitle.innerHTML = message.rReply; + + console.log('wrap reply', media); if(media.photo || (media.document && ['video'].indexOf(media.document.type) !== -1)) { let replyMedia = document.createElement('div'); - replyMedia.classList.add('reply-media'); + replyMedia.classList.add(prefix + '-media'); let photo = media.photo || media.document; @@ -971,7 +978,7 @@ export function wrapReply(title: string, subtitle: string, message?: any) { }); replyContent.append(replyMedia); - div.classList.add('is-reply-media'); + div.classList.add('is-media'); } } else { replySubtitle.innerHTML = subtitle ? RichTextProcessor.wrapEmojiText(subtitle) : ''; diff --git a/src/index.hbs b/src/index.hbs index aad17ae3..3d37be1a 100644 --- a/src/index.hbs +++ b/src/index.hbs @@ -394,13 +394,6 @@ -