From 431a602a40e24f9ec0603118f82037cb705812ce Mon Sep 17 00:00:00 2001 From: glax Date: Sun, 21 May 2023 22:01:04 +0200 Subject: [PATCH] Added Method UpdateSettings to SettingsData Added Method UpdateSettings to TaskManager (to export data after update) --- Tranga/TaskManager.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Tranga/TaskManager.cs b/Tranga/TaskManager.cs index 76dffd1..74121c9 100644 --- a/Tranga/TaskManager.cs +++ b/Tranga/TaskManager.cs @@ -43,6 +43,15 @@ public class TaskManager taskChecker.Start(); } + public void UpdateSettings(string? downloadLocation, string? komgaUrl, string? komgaAuth) + { + Komga? komga = null; + if (komgaUrl is not null && komgaAuth is not null) + komga = new Komga(komgaUrl, komgaAuth, null); + settings.UpdateSettings(downloadLocation, komga); + ExportData(); + } + public TaskManager(SettingsData settings, Logger? logger = null) { this.logger = logger; @@ -311,9 +320,9 @@ public class TaskManager public class SettingsData { - public string downloadLocation { get; set; } + public string downloadLocation { get; private set; } public string settingsFilePath { get; } - public Komga? komga { get; set; } + public Komga? komga { get; private set; } public HashSet allTasks { get; } public SettingsData(string downloadLocation, string? settingsFilePath, Komga? komga, HashSet allTasks) @@ -325,5 +334,13 @@ public class TaskManager this.komga = komga; this.allTasks = allTasks; } + + public void UpdateSettings(string? pDownloadLocation, Komga? pKomga) + { + if(pDownloadLocation is not null) + this.downloadLocation = pDownloadLocation; + if(pKomga is not null) + this.komga = pKomga; + } } } \ No newline at end of file