Skip to content

Commit

Permalink
πŸ› Correctly queue follow-up getScript requests
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Jul 25, 2024
1 parent f455ed2 commit d55a8fc
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/client/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -2317,7 +2317,7 @@ Scene.setMethod(function _setPageTitle(title) {
*
* @author Jelle De Loecker <[email protected]>
* @since 1.0.0
* @version 2.3.15
* @version 2.4.0
*
* @param {Object} options
* @param {Boolean} force Force a reload if already loaded?
Expand Down Expand Up @@ -2347,11 +2347,29 @@ Scene.setMethod(function getScript(options, force) {
let tasks = [];

for (let entry of path) {
let task_pledge = that.getScript(entry, force);

if (task_pledge && !task_pledge.is_done) {
// If this is the first script, already start getting it now
if (!tasks.length) {
let task_pledge = that.getScript(entry, force);

if (!task_pledge || task_pledge.is_done) {
continue;
}

tasks.push(task_pledge);
continue;
}

// Other scripts should be queued
tasks.push(next => {
let task_pledge = that.getScript(entry, force);

if (!task_pledge || task_pledge.is_done) {
return next();
}

Classes.Pledge.Swift.done(task_pledge, next);
});
}

if (!tasks.length) {
Expand Down

0 comments on commit d55a8fc

Please sign in to comment.