|
|
|
@ -69,11 +69,7 @@ export function wrapVideo(this: any, doc: MTDocument, container: HTMLDivElement,
@@ -69,11 +69,7 @@ export function wrapVideo(this: any, doc: MTDocument, container: HTMLDivElement,
|
|
|
|
|
let loadVideo = () => { |
|
|
|
|
let promise = appDocsManager.downloadDoc(doc); |
|
|
|
|
|
|
|
|
|
promise.notify = (details: {done: number, total: number}) => { |
|
|
|
|
console.log('doc download', promise, details); |
|
|
|
|
let percents = details.done / details.total * 100; |
|
|
|
|
preloader.setProgress(percents); |
|
|
|
|
}; |
|
|
|
|
preloader.attach(container, true, promise); |
|
|
|
|
|
|
|
|
|
return promise.then(blob => { |
|
|
|
|
if((this.peerID ? this.peerID : this.currentMessageID) != peerID) { |
|
|
|
@ -123,8 +119,6 @@ export function wrapVideo(this: any, doc: MTDocument, container: HTMLDivElement,
@@ -123,8 +119,6 @@ export function wrapVideo(this: any, doc: MTDocument, container: HTMLDivElement,
|
|
|
|
|
|
|
|
|
|
//container.style.width = '';
|
|
|
|
|
//container.style.height = '';
|
|
|
|
|
|
|
|
|
|
preloader.detach(); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -201,30 +195,28 @@ export function wrapDocument(doc: MTDocument, withTime = false): HTMLDivElement
@@ -201,30 +195,28 @@ export function wrapDocument(doc: MTDocument, withTime = false): HTMLDivElement
|
|
|
|
|
|
|
|
|
|
docDiv.addEventListener('click', () => { |
|
|
|
|
if(!promise) { |
|
|
|
|
if(downloadDiv.classList.contains('downloading')) { |
|
|
|
|
return; // means not ready yet
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!preloader) { |
|
|
|
|
preloader = new ProgressivePreloader(downloadDiv, true); |
|
|
|
|
} else { |
|
|
|
|
preloader.attach(downloadDiv, true); |
|
|
|
|
preloader = new ProgressivePreloader(null, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
promise = appDocsManager.saveDocFile(doc.id); |
|
|
|
|
promise.notify = (details: {done: number, total: number}) => { |
|
|
|
|
console.log('docDiv download', promise, details); |
|
|
|
|
let percents = details.done / details.total * 100; |
|
|
|
|
preloader.setProgress(percents); |
|
|
|
|
}; |
|
|
|
|
appDocsManager.saveDocFile(doc.id).then(res => { |
|
|
|
|
promise = res.promise; |
|
|
|
|
|
|
|
|
|
downloadDiv.classList.add('downloading'); |
|
|
|
|
preloader.attach(downloadDiv, true, promise); |
|
|
|
|
|
|
|
|
|
promise.then(() => { |
|
|
|
|
downloadDiv.classList.remove('downloading'); |
|
|
|
|
preloader.detach(); |
|
|
|
|
downloadDiv.remove(); |
|
|
|
|
}); |
|
|
|
|
promise.then(() => { |
|
|
|
|
downloadDiv.classList.remove('downloading'); |
|
|
|
|
downloadDiv.remove(); |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
downloadDiv.classList.add('downloading'); |
|
|
|
|
} else { |
|
|
|
|
downloadDiv.classList.remove('downloading'); |
|
|
|
|
promise.cancel(); |
|
|
|
|
preloader.detach(); |
|
|
|
|
promise = null; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -248,21 +240,25 @@ export function wrapPhoto(this: AppImManager, photo: any, message: any, containe
@@ -248,21 +240,25 @@ export function wrapPhoto(this: AppImManager, photo: any, message: any, containe
|
|
|
|
|
|
|
|
|
|
let preloader = new ProgressivePreloader(container, false); |
|
|
|
|
|
|
|
|
|
let load = () => appPhotosManager.preloadPhoto(photo.id, size).then((blob) => { |
|
|
|
|
if(this.peerID != peerID) { |
|
|
|
|
this.log.warn('peer changed'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
let load = () => { |
|
|
|
|
let promise = appPhotosManager.preloadPhoto(photo.id, size); |
|
|
|
|
|
|
|
|
|
image.src = URL.createObjectURL(blob); |
|
|
|
|
preloader.attach(container, true, promise); |
|
|
|
|
|
|
|
|
|
preloader.detach(); |
|
|
|
|
return promise.then((blob) => { |
|
|
|
|
if(this.peerID != peerID) { |
|
|
|
|
this.log.warn('peer changed'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//image.style.width = '';
|
|
|
|
|
//image.style.height = '';
|
|
|
|
|
//container.style.width = '';
|
|
|
|
|
//container.style.height = '';
|
|
|
|
|
}); |
|
|
|
|
image.src = URL.createObjectURL(blob); |
|
|
|
|
|
|
|
|
|
//image.style.width = '';
|
|
|
|
|
//image.style.height = '';
|
|
|
|
|
//container.style.width = '';
|
|
|
|
|
//container.style.height = '';
|
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
console.log('wrapPhoto', load, container, image); |
|
|
|
|
|
|
|
|
|