From 13fa102ea86d76bf9f3e835b54acf34d8ccc486e Mon Sep 17 00:00:00 2001 From: uye <2396806385@qq.com> Date: Fri, 20 Jan 2023 23:44:58 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=87=8F=E5=B0=91=E5=86=97?= =?UTF-8?q?=E4=BD=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Main/TaskQueueViewModel.cs | 47 ++++-------------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/src/MaaWpfGui/Main/TaskQueueViewModel.cs b/src/MaaWpfGui/Main/TaskQueueViewModel.cs index 500c1cf425..a9598de1c0 100644 --- a/src/MaaWpfGui/Main/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/Main/TaskQueueViewModel.cs @@ -269,14 +269,7 @@ namespace MaaWpfGui // reset closed stage1 to "Last/Current" if (!CustomStageCode) { - if (stage1 == null || !_stageManager.IsStageOpen(stage1, _curDayOfWeek)) - { - Stage1 = string.Empty; - } - else - { - Stage1 = stage1; - } + Stage1 = (stage1 != null && _stageManager.IsStageOpen(stage1, _curDayOfWeek)) ? stage1 : string.Empty; } } else @@ -291,47 +284,23 @@ namespace MaaWpfGui StageList = new ObservableCollection(_stageManager.GetStageList()); // reset closed stages to "Last/Current" - if (!CustomStageCode && !StageList.Any(x => x.Value == stage1)) + if (!CustomStageCode) { - Stage1 = string.Empty; + Stage1 = StageList.Any(x => x.Value == stage1) ? stage1 : string.Empty; + Stage2 = StageList.Any(x => x.Value == stage2) ? stage2 : string.Empty; + Stage3 = StageList.Any(x => x.Value == stage3) ? stage3 : string.Empty; } - else - { - Stage1 = stage1; - } - - if (!CustomStageCode && !StageList.Any(x => x.Value == stage2)) - { - Stage2 = string.Empty; - } - else - { - Stage2 = stage2; - } - - if (!CustomStageCode && !StageList.Any(x => x.Value == stage3)) - { - Stage3 = string.Empty; - } - else - { - Stage3 = stage3; - } - } - else - { - // do nothing } } - var remainingSanityStage = RemainingSanityStage; + var rss = RemainingSanityStage; RemainingSanityStageList = new ObservableCollection(_stageManager.GetStageList()) { [0] = new CombData { Display = Localization.GetString("NoUse"), Value = string.Empty }, }; - if (!CustomStageCode && !RemainingSanityStageList.Any(x => x.Value == remainingSanityStage)) + if (!CustomStageCode) { - RemainingSanityStage = string.Empty; + RemainingSanityStage = RemainingSanityStageList.Any(x => x.Value == rss) ? rss : string.Empty; } }