Added Method UpdateSettings to SettingsData

Added Method UpdateSettings to TaskManager (to export data after update)
This commit is contained in:
glax 2023-05-21 22:01:04 +02:00
parent 9afb81cee2
commit 431a602a40

View File

@ -43,6 +43,15 @@ public class TaskManager
taskChecker.Start(); 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) public TaskManager(SettingsData settings, Logger? logger = null)
{ {
this.logger = logger; this.logger = logger;
@ -311,9 +320,9 @@ public class TaskManager
public class SettingsData public class SettingsData
{ {
public string downloadLocation { get; set; } public string downloadLocation { get; private set; }
public string settingsFilePath { get; } public string settingsFilePath { get; }
public Komga? komga { get; set; } public Komga? komga { get; private set; }
public HashSet<TrangaTask> allTasks { get; } public HashSet<TrangaTask> allTasks { get; }
public SettingsData(string downloadLocation, string? settingsFilePath, Komga? komga, HashSet<TrangaTask> allTasks) public SettingsData(string downloadLocation, string? settingsFilePath, Komga? komga, HashSet<TrangaTask> allTasks)
@ -325,5 +334,13 @@ public class TaskManager
this.komga = komga; this.komga = komga;
this.allTasks = allTasks; 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;
}
} }
} }