From 263ac2645569ae2ae67831820858082c76cc731d Mon Sep 17 00:00:00 2001
From: Nlick47 <2247717951@qq.com>
Date: Wed, 25 Sep 2024 21:12:28 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=80=89=E6=8B=A9?=
=?UTF-8?q?=E4=B8=8B=E8=BD=BD=E8=B7=AF=E5=BE=84=E6=97=B6=E5=BC=95=E5=8F=91?=
=?UTF-8?q?=E7=9A=84=E5=8F=A6=E4=B8=80=E4=B8=AA=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DownKyi.Core/Utils/ListHelper.cs | 13 ++++++++++++-
.../Dialogs/ViewDownloadSetterViewModel.cs | 2 +-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/DownKyi.Core/Utils/ListHelper.cs b/DownKyi.Core/Utils/ListHelper.cs
index 0ad4100..875150c 100644
--- a/DownKyi.Core/Utils/ListHelper.cs
+++ b/DownKyi.Core/Utils/ListHelper.cs
@@ -39,7 +39,7 @@ public static class ListHelper
///
///
///
- public static void InsertUnique(Collection list, T item, int index)
+ public static void InsertUnique(Collection list, T item, int index, ref T currentSelection)
{
if (!list.Contains(item))
{
@@ -47,8 +47,19 @@ public static class ListHelper
}
else
{
+ var previousSelection = currentSelection;
list.Remove(item);
list.Insert(index, item);
+ if (previousSelection != null && previousSelection.Equals(item))
+ {
+ currentSelection = previousSelection;
+ }
}
}
+
+ public static void InsertUnique(Collection list, T item, int index)
+ {
+ T defaultSelection = default;
+ InsertUnique(list, item, index, ref defaultSelection);
+ }
}
\ No newline at end of file
diff --git a/DownKyi/ViewModels/Dialogs/ViewDownloadSetterViewModel.cs b/DownKyi/ViewModels/Dialogs/ViewDownloadSetterViewModel.cs
index 4390a49..327daf2 100644
--- a/DownKyi/ViewModels/Dialogs/ViewDownloadSetterViewModel.cs
+++ b/DownKyi/ViewModels/Dialogs/ViewDownloadSetterViewModel.cs
@@ -379,7 +379,7 @@ public class ViewDownloadSetterViewModel : BaseDialogViewModel
// 将Directory移动到第一项
// 如果直接在ComboBox中选择的就需要
// 否则选中项不会在下次出现在第一项
- ListHelper.InsertUnique(DirectoryList, Directory, 0);
+ ListHelper.InsertUnique(DirectoryList, Directory, 0,ref _directory);
// 将更新后的DirectoryList写入历史中
SettingsManager.GetInstance().SetSaveVideoRootPath(Directory);