From c3a15a354b553a8993cb45bc1f027e962c70dc3c Mon Sep 17 00:00:00 2001 From: db-2001 Date: Mon, 30 Oct 2023 13:29:39 -0400 Subject: [PATCH] Preliminary fix for update button deleting all mangas --- Website/interaction.js | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Website/interaction.js b/Website/interaction.js index 9e22f0b..1dfaea7 100644 --- a/Website/interaction.js +++ b/Website/interaction.js @@ -99,6 +99,19 @@ function ResetContent(){ add.appendChild(plus); add.addEventListener("click", () => ShowNewMangaSearch()); tasksContent.appendChild(add); + + //Populate with the monitored mangas + GetMonitorJobs().then((json) => { + //console.log(json); + json.forEach(job => { + var mangaView = CreateManga(job.manga, job.mangaConnector.name); + mangaView.addEventListener("click", (event) => { + ShowMangaWindow(job, job.manga, event, false); + }); + tasksContent.appendChild(mangaView); + }); + monitoringJobsCount = json.length; + }); } function ShowNewMangaSearch(){ @@ -158,6 +171,7 @@ createMonitorJobButton.addEventListener("click", () => { CreateMonitorJob(newMangaConnector.value, selectedManga.internalId, newMangaTranslatedLanguage.value); UpdateJobs(); mangaViewerPopup.style.display = "none"; + ResetContent(); }); startJobButton.addEventListener("click", () => { StartJob(selectedJob.id); @@ -171,6 +185,7 @@ deleteJobButton.addEventListener("click", () => { RemoveJob(selectedJob.id); UpdateJobs(); mangaViewerPopup.style.display = "none"; + ResetContent(); }); function ShowMangaWindow(job, manga, event, add){ @@ -377,21 +392,8 @@ function utf8_to_b64(str) { } function UpdateJobs(){ - GetMonitorJobs().then((json) => { - if(monitoringJobsCount != json.length){ - ResetContent(); - //console.log(json); - json.forEach(job => { - var mangaView = CreateManga(job.manga, job.mangaConnector.name); - mangaView.addEventListener("click", (event) => { - ShowMangaWindow(job, job.manga, event, false); - }); - tasksContent.appendChild(mangaView); - }); - monitoringJobsCount = json.length; - } - }); - + + //Get the jobs that are waiting in the queue GetWaitingJobs().then((json) => { jobsQueuedTag.innerText = json.length; @@ -412,6 +414,7 @@ function UpdateJobs(){ jobStatusWaiting.removeChild(child); }); + //Get currently running jobs GetRunningJobs().then((json) => { jobsRunningTag.innerText = json.length;