From d0ee08fa1137e81896b4c7d33d5b8466f5e447ee Mon Sep 17 00:00:00 2001
From: ScrubN <72096833+ScrubN@users.noreply.github.com>
Date: Wed, 28 Aug 2024 19:14:17 -0400
Subject: [PATCH 1/3] Add buttons and logic for rearranging tasks
---
TwitchDownloaderWPF/PageQueue.xaml | 10 +++++++-
TwitchDownloaderWPF/PageQueue.xaml.cs | 34 +++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/TwitchDownloaderWPF/PageQueue.xaml b/TwitchDownloaderWPF/PageQueue.xaml
index 31733e35..c8054e1c 100644
--- a/TwitchDownloaderWPF/PageQueue.xaml
+++ b/TwitchDownloaderWPF/PageQueue.xaml
@@ -87,7 +87,15 @@
-
+
+
+
+
+
diff --git a/TwitchDownloaderWPF/PageQueue.xaml.cs b/TwitchDownloaderWPF/PageQueue.xaml.cs
index 47ce873f..dc8a664a 100644
--- a/TwitchDownloaderWPF/PageQueue.xaml.cs
+++ b/TwitchDownloaderWPF/PageQueue.xaml.cs
@@ -333,5 +333,39 @@ private static void RetryTask(TwitchTask task)
task.Reinitialize();
}
}
+
+ private void BtnMoveTaskUp_Click(object sender, RoutedEventArgs e)
+ {
+ if (sender is not Button { DataContext: TwitchTask task })
+ {
+ return;
+ }
+
+ lock (taskLock)
+ {
+ var index = taskList.IndexOf(task);
+ if (index < 1)
+ return;
+
+ taskList.Move(index, index - 1);
+ }
+ }
+
+ private void BtnMoveTaskDown_Click(object sender, RoutedEventArgs e)
+ {
+ if (sender is not Button { DataContext: TwitchTask task })
+ {
+ return;
+ }
+
+ lock (taskLock)
+ {
+ var index = taskList.IndexOf(task);
+ if (index == -1 || index == taskList.Count - 1)
+ return;
+
+ taskList.Move(index, index + 1);
+ }
+ }
}
}
From dead8115def5b56bbb1653ec8bf5f62514a73c63 Mon Sep 17 00:00:00 2001
From: ScrubN <72096833+ScrubN@users.noreply.github.com>
Date: Wed, 28 Aug 2024 19:15:54 -0400
Subject: [PATCH 2/3] Use FontAwesome for close button
---
TwitchDownloaderWPF/PageQueue.xaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/TwitchDownloaderWPF/PageQueue.xaml b/TwitchDownloaderWPF/PageQueue.xaml
index c8054e1c..1f8431cb 100644
--- a/TwitchDownloaderWPF/PageQueue.xaml
+++ b/TwitchDownloaderWPF/PageQueue.xaml
@@ -94,7 +94,9 @@
-
+
From c9cec6023eb471dfacafc6d0a47507efc9ab0df7 Mon Sep 17 00:00:00 2001
From: ScrubN <72096833+ScrubN@users.noreply.github.com>
Date: Wed, 28 Aug 2024 19:16:09 -0400
Subject: [PATCH 3/3] Fix potential race condition
---
TwitchDownloaderWPF/PageQueue.xaml.cs | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/TwitchDownloaderWPF/PageQueue.xaml.cs b/TwitchDownloaderWPF/PageQueue.xaml.cs
index dc8a664a..a12fee62 100644
--- a/TwitchDownloaderWPF/PageQueue.xaml.cs
+++ b/TwitchDownloaderWPF/PageQueue.xaml.cs
@@ -290,9 +290,12 @@ private static void RemoveTask(TwitchTask task)
return;
}
- if (!taskList.Remove(task))
+ lock (taskLock)
{
- MessageBox.Show(Application.Current.MainWindow!, Translations.Strings.TaskCouldNotBeRemoved, Translations.Strings.UnknownErrorOccurred, MessageBoxButton.OK, MessageBoxImage.Error);
+ if (!taskList.Remove(task))
+ {
+ MessageBox.Show(Application.Current.MainWindow!, Translations.Strings.TaskCouldNotBeRemoved, Translations.Strings.UnknownErrorOccurred, MessageBoxButton.OK, MessageBoxImage.Error);
+ }
}
}