From 2ff9e0a05ac65d54f9a341297357f1587b07107d Mon Sep 17 00:00:00 2001 From: David Sanabria Date: Sat, 6 Jul 2024 00:17:24 -0400 Subject: Make confirmation episode list alphabetical Slightly refactored the way the list of episodes was added to the DOM such that it's possible to list them alphabetically rather than in the order of their Promise resolution. --- js/main.js | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/js/main.js b/js/main.js index 7b3b252..ea3d686 100644 --- a/js/main.js +++ b/js/main.js @@ -1085,12 +1085,10 @@ async function setAudioStream(partsId, streamId, row) { "X-Plex-Token": plexToken, "Accept": "application/json" } - }).then((result) => { - $('#progressModal #modalBodyText').append(data.messageAppend); - $(row).siblings().removeClass("table-active"); - $(row).addClass("table-active"); + }).then((_result) => { handleProgress(); - }).catch((e) => console.log(e)); + return data; + }); } for (let k = 0; k < promiseConstructors.length; k++) { @@ -1107,6 +1105,15 @@ async function setAudioStream(partsId, streamId, row) { try { Promise.allSettled(matchPromises).then(() => { + matchPromises.forEach(async (matchPromise) => { + await matchPromise.then((data) => { + $('#progressModal #modalBodyText').append(data.messageAppend); + $(row).siblings().removeClass("table-active"); + $(row).addClass("table-active"); + }).catch((e) => console.log(e)); + }) + }) + .then(() => { $('#modalBodyText .alert').removeClass("alert-warning").addClass("alert-success"); $("#modalBodyText #modalTitleText").text("Processing Complete! You can now close this popup."); $('#modalBodyText #progressBarContainer').hide(); @@ -1394,11 +1401,9 @@ async function setSubtitleStream(partsId, streamId, row) { "X-Plex-Token": plexToken, "Accept": "application/json" } - }).then((result) => { - $('#progressModal #modalBodyText').append(data.messageAppend); - $(row).siblings().removeClass("table-active"); - $(row).addClass("table-active"); + }).then((_result) => { handleProgress(); + return data; }).catch((e) => console.log(e)); } @@ -1416,6 +1421,15 @@ async function setSubtitleStream(partsId, streamId, row) { try { Promise.allSettled(matchPromises).then(() => { + matchPromises.forEach(async (matchPromise) => { + await matchPromise.then((data) => { + $('#progressModal #modalBodyText').append(data.messageAppend); + $(row).siblings().removeClass("table-active"); + $(row).addClass("table-active"); + }).catch((e) => console.log(e)); + }) + }) + .then(() => { $('#modalBodyText .alert').removeClass("alert-warning").addClass("alert-success"); $("#modalBodyText #modalTitleText").text("Processing Complete! You can now close this popup."); $('#modalBodyText #progressBarContainer').hide(); -- cgit v1.2.3