This commit is contained in:
max 2020-02-26 10:41:26 +01:00
parent b212b25a9e
commit ace682abbd

View File

@ -138,7 +138,7 @@ class PreviewThumbnails {
} }
// Resolve promise // Resolve promise
const resolvePromise = () => { const sortAndResolve = () => {
// 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,13 +147,13 @@ class PreviewThumbnails {
resolve(); resolve();
}; };
// Via callback() // Via callback()
if (typeof(src) == 'function') { if (is.function(src)) {
// Ask // Ask
let that = this; let that = this;
src(function(thumbnails) { src(function(thumbnails) {
that.thumbnails = thumbnails; that.thumbnails = thumbnails;
// Resolve // Resolve
resolvePromise(); sortAndResolve();
}); });
} }
// VTT urls // VTT urls
@ -163,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(resolvePromise); Promise.all(promises).then(sortAndResolve);
} }
}); });
} }