From c9537a996371217c675d1ae374e9b7853f1d4164 Mon Sep 17 00:00:00 2001 From: glax Date: Fri, 26 May 2023 13:39:42 +0200 Subject: [PATCH] #24 --- Tranga/TaskManager.cs | 13 +++++-------- Website/interaction.js | 15 +++++++++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Tranga/TaskManager.cs b/Tranga/TaskManager.cs index 09ba120..ddf35b5 100644 --- a/Tranga/TaskManager.cs +++ b/Tranga/TaskManager.cs @@ -141,14 +141,11 @@ public class TaskManager TrangaTask newTask; if (task == TrangaTask.Task.UpdateKomgaLibrary) { - newTask = new TrangaTask(task, null, null, reoccurrence, language); - - //Check if same task already exists - // ReSharper disable once SimplifyLinqExpressionUseAll readabilty - if (!_allTasks.Any(trangaTask => trangaTask.task == task)) - { - _allTasks.Add(newTask); - } + newTask = new TrangaTask(task, null, null, reoccurrence); + logger?.WriteLine(this.GetType().ToString(), $"Removing old {task}-Task."); + //Only one UpdateKomgaLibrary Task + _allTasks.RemoveWhere(trangaTask => trangaTask.task is TrangaTask.Task.UpdateKomgaLibrary); + _allTasks.Add(newTask); } else { diff --git a/Website/interaction.js b/Website/interaction.js index 1848740..7597be2 100644 --- a/Website/interaction.js +++ b/Website/interaction.js @@ -227,6 +227,7 @@ function GetSettingsClick(){ }); GetKomgaTask().then(json => { + settingKomgaTime.value = json[0].reoccurrence; if(json.length > 0) settingKomgaConfigured.innerText = "✅"; else @@ -235,11 +236,17 @@ function GetSettingsClick(){ } function UpdateKomgaSettings(){ - var auth = utf8_to_b64(`${settingKomgaUser.value}:${settingKomgaPass.value}`); - console.log(auth); - UpdateSettings("", settingKomgaUrl.value, auth); + if(settingKomgaUser.value != "" && settingKomgaPass != ""){ + var auth = utf8_to_b64(`${settingKomgaUser.value}:${settingKomgaPass.value}`); + console.log(auth); + + if(settingKomgaUrl.value != "") + UpdateSettings("", settingKomgaUrl.value, auth); + else + UpdateSettings("", settingKomgaUrl.placeholder, auth); + } CreateTask("UpdateKomgaLibrary", settingKomgaTime.value, "","",""); - setTimeout(() => GetSettingsClick(), 500); + setTimeout(() => GetSettingsClick(), 100); } function utf8_to_b64( str ) {