From a70b9fcb2dc1ebb9f71940cc23e363551865835f Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 01:43:20 +0800 Subject: [PATCH] Try to avoid recurion and comment --- Flow.Launcher/SettingWindow.xaml.cs | 4 ++++ Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 7e029910f..bdc858527 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -519,6 +519,10 @@ namespace Flow.Launcher { if (DateFormat != null && TimeFormat != null) { + if (DateFormat.SelectedIndex == -1 || TimeFormat.SelectedIndex == -1) + { + return; + } viewModel.UpdateDateTimeDisplayList(DateFormat.SelectedIndex, TimeFormat.SelectedIndex); DateFormat.Items.Refresh(); TimeFormat.Items.Refresh(); // selected = -1 diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 302310e43..5066d0ca6 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -52,7 +52,7 @@ namespace Flow.Launcher.ViewModel int tmp = 0; TimeFormatIndex = (tmp = TimeFormatList.FindIndex(x => x.Equals(Settings.TimeFormat))) >= 0 ? tmp : 0; DateFormatIndex = (tmp = DateFormatList.FindIndex(x => x.Equals(Settings.DateFormat))) >= 0 ? tmp : 0; - + // TODO: CurrentCulture may equal to settings.language when this is constructed TimeFormatDisplayList = TimeFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList(); DateFormatDisplayList = DateFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList(); UpdateSettingsDateTimeFormat(); // just in case something wrong @@ -492,8 +492,6 @@ namespace Flow.Launcher.ViewModel public void UpdateDateTimeDisplayList(int dateIndex, int timeIndex) { - if (dateIndex == -1 || timeIndex == -1) - return; DateFormatIndex = dateIndex; TimeFormatIndex = timeIndex;