Try to avoid recurion and comment

This commit is contained in:
Vic 2022-11-19 01:43:20 +08:00
parent 7270c9f35d
commit a70b9fcb2d
2 changed files with 5 additions and 3 deletions

View file

@ -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

View file

@ -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;