From e5d7fdf9b4b813656461d5162a3910cf87a117af Mon Sep 17 00:00:00 2001 From: glax Date: Fri, 19 May 2023 16:35:53 +0200 Subject: [PATCH] ExportTasks every time a task is added/removed --- Tranga/TaskManager.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Tranga/TaskManager.cs b/Tranga/TaskManager.cs index 134afc7..b8ee015 100644 --- a/Tranga/TaskManager.cs +++ b/Tranga/TaskManager.cs @@ -34,19 +34,23 @@ public class TaskManager } } - public bool AddTask(TrangaTask.Task task, Connector connector, Publication? publication, TimeSpan reoccurrence, + public void AddTask(TrangaTask.Task task, Connector connector, Publication? publication, TimeSpan reoccurrence, string language = "") { - if(!_allTasks.Any(trangaTask => trangaTask.task != task && trangaTask.connectorName != connector.name && trangaTask.publication?.downloadUrl != publication?.downloadUrl)) - return _allTasks.Add(new TrangaTask(connector.name, task, publication, reoccurrence, language)); - return false; + if (!_allTasks.Any(trangaTask => trangaTask.task != task && trangaTask.connectorName != connector.name && + trangaTask.publication?.downloadUrl != publication?.downloadUrl)) + { + _allTasks.Add(new TrangaTask(connector.name, task, publication, reoccurrence, language)); + ExportTasks(Directory.GetCurrentDirectory()); + } } - public bool RemoveTask(TrangaTask.Task task, string connectorName, Publication? publication) + public void RemoveTask(TrangaTask.Task task, string connectorName, Publication? publication) { - return (_allTasks.RemoveWhere(trangaTask => - trangaTask.task == task && trangaTask.connectorName == connectorName && trangaTask.publication?.downloadUrl == publication?.downloadUrl) - > 0); + _allTasks.RemoveWhere(trangaTask => + trangaTask.task == task && trangaTask.connectorName == connectorName && + trangaTask.publication?.downloadUrl == publication?.downloadUrl); + ExportTasks(Directory.GetCurrentDirectory()); } public Dictionary GetAvailableConnectors()