From 93de471836c513c201a14ba41e5c8aaecf39bdf1 Mon Sep 17 00:00:00 2001 From: glax Date: Thu, 15 Jun 2023 18:22:59 +0200 Subject: [PATCH] Added TrangaTask.RemoveChildTask --- Tranga/TrangaTask.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Tranga/TrangaTask.cs b/Tranga/TrangaTask.cs index f2b2ed1..b7402e3 100644 --- a/Tranga/TrangaTask.cs +++ b/Tranga/TrangaTask.cs @@ -76,11 +76,8 @@ public abstract class TrangaTask public void ReplaceFailedChildTask(DownloadChapterTask failed, DownloadChapterTask newTask) { - if (!this.childTasks.Contains(failed)) - throw new ArgumentException($"Task {failed} is not childTask of {this}"); - this.childTasks.Remove(failed); - this.childTasks.Add(newTask); - this.DecrementProgress(failed.progress); + this.RemoveChildTask(failed); + this.AddChildTask(newTask); } public void AddChildTask(TrangaTask childTask) @@ -88,6 +85,12 @@ public abstract class TrangaTask this.childTasks.Add(childTask); } + public void RemoveChildTask(TrangaTask childTask) + { + this.childTasks.Remove(childTask); + this.DecrementProgress(childTask.progress); + } + public void IncrementProgress(double amount) { this.lastChange = DateTime.Now;