|
|
@ -564,8 +564,8 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o |
|
|
|
|
|
|
|
|
|
|
|
const toneIndex = emoji ? getEmojiToneIndex(emoji) : -1; |
|
|
|
const toneIndex = emoji ? getEmojiToneIndex(emoji) : -1; |
|
|
|
|
|
|
|
|
|
|
|
if(doc.thumbs?.length && !div.firstElementChild && (!doc.downloaded || stickerType == 2 || onlyThumb) && toneIndex <= 0/* && doc.thumbs[0]._ != 'photoSizeEmpty' */) { |
|
|
|
if((doc.thumbs?.length || doc.stickerCachedThumbs) && !div.firstElementChild && (!doc.downloaded || stickerType == 2 || onlyThumb)/* && doc.thumbs[0]._ != 'photoSizeEmpty' */) { |
|
|
|
const thumb = doc.thumbs[0]; |
|
|
|
const thumb = doc.stickerCachedThumbs && doc.stickerCachedThumbs[toneIndex] || doc.thumbs[0]; |
|
|
|
|
|
|
|
|
|
|
|
//console.log('wrap sticker', thumb, div);
|
|
|
|
//console.log('wrap sticker', thumb, div);
|
|
|
|
|
|
|
|
|
|
|
@ -580,23 +580,29 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o |
|
|
|
img = new Image(); |
|
|
|
img = new Image(); |
|
|
|
renderImageFromUrl(img, thumb.url, afterRender); |
|
|
|
renderImageFromUrl(img, thumb.url, afterRender); |
|
|
|
} else if('bytes' in thumb) { |
|
|
|
} else if('bytes' in thumb) { |
|
|
|
img = new Image(); |
|
|
|
if(thumb._ == 'photoPathSize') { |
|
|
|
|
|
|
|
//if(!doc.w) console.error('no w', doc);
|
|
|
|
if((webpWorkerController.isWebpSupported() || doc.pFlags.stickerThumbConverted || thumb.url)/* && false */) { |
|
|
|
div.innerHTML = `<svg class="rlottie-vector" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 ${doc.w || 512} ${doc.h || 512}" xml:space="preserve">
|
|
|
|
renderImageFromUrl(img, appPhotosManager.getPreviewURLFromThumb(thumb, true), afterRender); |
|
|
|
<path d="${appPhotosManager.getPathFromPhotoPathSize(thumb)}"/> |
|
|
|
} else { |
|
|
|
</svg>`;
|
|
|
|
webpWorkerController.convert(doc.id, thumb.bytes as Uint8Array).then(bytes => { |
|
|
|
} else if(toneIndex <= 0) { |
|
|
|
thumb.bytes = bytes; |
|
|
|
img = new Image(); |
|
|
|
doc.pFlags.stickerThumbConverted = true; |
|
|
|
if((webpWorkerController.isWebpSupported() || doc.pFlags.stickerThumbConverted || thumb.url)/* && false */) { |
|
|
|
|
|
|
|
renderImageFromUrl(img, appPhotosManager.getPreviewURLFromThumb(thumb, true), afterRender); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
webpWorkerController.convert(doc.id, thumb.bytes as Uint8Array).then(bytes => { |
|
|
|
|
|
|
|
thumb.bytes = bytes; |
|
|
|
|
|
|
|
doc.pFlags.stickerThumbConverted = true; |
|
|
|
|
|
|
|
|
|
|
|
if(middleware && !middleware()) return; |
|
|
|
if(middleware && !middleware()) return; |
|
|
|
|
|
|
|
|
|
|
|
if(!div.childElementCount) { |
|
|
|
if(!div.childElementCount) { |
|
|
|
renderImageFromUrl(img, appPhotosManager.getPreviewURLFromThumb(thumb, true), afterRender); |
|
|
|
renderImageFromUrl(img, appPhotosManager.getPreviewURLFromThumb(thumb, true), afterRender); |
|
|
|
} |
|
|
|
} |
|
|
|
}).catch(() => {}); |
|
|
|
}).catch(() => {}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if(stickerType == 2 && (withThumb || onlyThumb)) { |
|
|
|
} else if(stickerType == 2 && (withThumb || onlyThumb) && toneIndex <= 0) { |
|
|
|
img = new Image(); |
|
|
|
img = new Image(); |
|
|
|
|
|
|
|
|
|
|
|
const load = () => { |
|
|
|
const load = () => { |
|
|
@ -637,6 +643,9 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o |
|
|
|
console.log('loaded sticker:', doc, div); |
|
|
|
console.log('loaded sticker:', doc, div); |
|
|
|
} */ |
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//await new Promise((resolve) => setTimeout(resolve, 500));
|
|
|
|
|
|
|
|
//return;
|
|
|
|
|
|
|
|
|
|
|
|
//console.time('download sticker' + doc.id);
|
|
|
|
//console.time('download sticker' + doc.id);
|
|
|
|
|
|
|
|
|
|
|
|
//appDocsManager.downloadDocNew(doc.id).promise.then(res => res.json()).then(async(json) => {
|
|
|
|
//appDocsManager.downloadDocNew(doc.id).promise.then(res => res.json()).then(async(json) => {
|
|
|
@ -649,7 +658,7 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o |
|
|
|
//console.log('loaded sticker:', doc, div/* , blob */);
|
|
|
|
//console.log('loaded sticker:', doc, div/* , blob */);
|
|
|
|
if(middleware && !middleware()) return; |
|
|
|
if(middleware && !middleware()) return; |
|
|
|
|
|
|
|
|
|
|
|
let animation = await LottieLoader.loadAnimationWorker/* loadAnimation */({ |
|
|
|
let animation = await LottieLoader.loadAnimationWorker({ |
|
|
|
container: div, |
|
|
|
container: div, |
|
|
|
loop: loop && !emoji, |
|
|
|
loop: loop && !emoji, |
|
|
|
autoplay: play, |
|
|
|
autoplay: play, |
|
|
@ -661,12 +670,29 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o |
|
|
|
//const deferred = deferredPromise<void>();
|
|
|
|
//const deferred = deferredPromise<void>();
|
|
|
|
|
|
|
|
|
|
|
|
animation.addListener('firstFrame', () => { |
|
|
|
animation.addListener('firstFrame', () => { |
|
|
|
if(div.firstElementChild && div.firstElementChild.tagName == 'IMG') { |
|
|
|
const element = div.firstElementChild; |
|
|
|
div.firstElementChild.remove(); |
|
|
|
const needFadeIn = !element || element.tagName === 'svg'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const cb = () => { |
|
|
|
|
|
|
|
if(element && element != animation.canvas) { |
|
|
|
|
|
|
|
element.remove(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!needFadeIn) { |
|
|
|
|
|
|
|
cb(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
animation.canvas.classList.add('fade-in'); |
|
|
|
animation.canvas.classList.add('fade-in'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(element) { |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
cb(); |
|
|
|
|
|
|
|
}, element.tagName === 'svg' ? 50 : 200); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
appDocsManager.saveLottiePreview(doc, animation.canvas, toneIndex); |
|
|
|
|
|
|
|
|
|
|
|
//deferred.resolve();
|
|
|
|
//deferred.resolve();
|
|
|
|
}, true); |
|
|
|
}, true); |
|
|
|
|
|
|
|
|
|
|
|