This commit is contained in:
max
2020-02-26 10:35:08 +01:00
parent 81b41be750
commit b212b25a9e

View File

@ -138,7 +138,7 @@ class PreviewThumbnails {
} }
// Resolve promise // Resolve promise
const exec_resolve = () => { const resolvePromise = () => {
// Sort smallest to biggest (e.g., [120p, 480p, 1080p]) // Sort smallest to biggest (e.g., [120p, 480p, 1080p])
this.thumbnails.sort((x, y) => x.height - y.height); this.thumbnails.sort((x, y) => x.height - y.height);
@ -147,11 +147,14 @@ class PreviewThumbnails {
resolve(); resolve();
}; };
// Via callback() // Via callback()
if( typeof(src) == 'function' ) { if (typeof(src) == 'function') {
// Ask // Ask
this.thumbnails = src(); let that = this;
// Resolve src(function(thumbnails) {
exec_resolve(); that.thumbnails = thumbnails;
// Resolve
resolvePromise();
});
} }
// VTT urls // VTT urls
else { else {
@ -160,7 +163,7 @@ class PreviewThumbnails {
// Loop through each src URL. Download and process the VTT file, storing the resulting data in this.thumbnails // Loop through each src URL. Download and process the VTT file, storing the resulting data in this.thumbnails
const promises = urls.map(u => this.getThumbnail(u)); const promises = urls.map(u => this.getThumbnail(u));
// Resolve // Resolve
Promise.all(promises).then(exec_resolve); Promise.all(promises).then(resolvePromise);
} }
}); });
} }