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