Skip to content

Commit a70b9fc

Browse files
Try to avoid recurion and comment
1 parent 7270c9f commit a70b9fc

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,10 @@ private void PreviewClockAndDate(object sender, RoutedEventArgs e)
519519
{
520520
if (DateFormat != null && TimeFormat != null)
521521
{
522+
if (DateFormat.SelectedIndex == -1 || TimeFormat.SelectedIndex == -1)
523+
{
524+
return;
525+
}
522526
viewModel.UpdateDateTimeDisplayList(DateFormat.SelectedIndex, TimeFormat.SelectedIndex);
523527
DateFormat.Items.Refresh();
524528
TimeFormat.Items.Refresh(); // selected = -1

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public SettingWindowViewModel(Updater updater, IPortable portable)
5252
int tmp = 0;
5353
TimeFormatIndex = (tmp = TimeFormatList.FindIndex(x => x.Equals(Settings.TimeFormat))) >= 0 ? tmp : 0;
5454
DateFormatIndex = (tmp = DateFormatList.FindIndex(x => x.Equals(Settings.DateFormat))) >= 0 ? tmp : 0;
55-
55+
// TODO: CurrentCulture may equal to settings.language when this is constructed
5656
TimeFormatDisplayList = TimeFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList();
5757
DateFormatDisplayList = DateFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList();
5858
UpdateSettingsDateTimeFormat(); // just in case something wrong
@@ -492,8 +492,6 @@ public void UpdateSettingsDateTimeFormat()
492492

493493
public void UpdateDateTimeDisplayList(int dateIndex, int timeIndex)
494494
{
495-
if (dateIndex == -1 || timeIndex == -1)
496-
return;
497495
DateFormatIndex = dateIndex;
498496
TimeFormatIndex = timeIndex;
499497

0 commit comments

Comments
 (0)