Skip to content

Commit 96bb62a

Browse files
committed
Refresh interface when Home Page is changed
1 parent f2f4ebf commit 96bb62a

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,20 @@ public string PlaceholderText
159159
}
160160
}
161161

162-
public bool ShowHomePage { get; set; } = true;
162+
private bool _showHomePage { get; set; } = true;
163+
public bool ShowHomePage
164+
{
165+
get => _showHomePage;
166+
set
167+
{
168+
if (_showHomePage != value)
169+
{
170+
_showHomePage = value;
171+
OnPropertyChanged();
172+
}
173+
}
174+
}
175+
163176
public bool ShowHistoryResultsForHomePage { get; set; } = false;
164177
public int MaxHistoryResultsToShowForHomePage { get; set; } = 5;
165178

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,17 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
277277
case nameof(Settings.SettingWindowFont):
278278
InitializeContextMenu();
279279
break;
280+
case nameof(Settings.ShowHomePage):
281+
// We should refresh results when these two settings are changed but we cannot do that
282+
// Because the order of the results will change, making the interface look weird
283+
// So we would better refresh results when query text is changed next time
284+
/*case nameof(Settings.ShowHistoryResultsForHomePage):
285+
case nameof(Settings.MaxHistoryResultsToShowForHomePage):*/
286+
if (string.IsNullOrEmpty(_viewModel.QueryText))
287+
{
288+
_viewModel.QueryResults();
289+
}
290+
break;
280291
}
281292
};
282293

@@ -294,7 +305,10 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
294305
.AddValueChanged(History, (s, e) => UpdateClockPanelVisibility());
295306

296307
// Initialize query state
297-
_viewModel.InitializeQuery();
308+
if (_settings.ShowHomePage && string.IsNullOrEmpty(_viewModel.QueryText))
309+
{
310+
_viewModel.QueryResults();
311+
}
298312
}
299313

300314
private async void OnClosing(object sender, CancelEventArgs e)

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,12 +1080,9 @@ private bool QueryResultsPreviewed()
10801080

10811081
#region Query
10821082

1083-
public void InitializeQuery()
1083+
public void QueryResults()
10841084
{
1085-
if (Settings.ShowHomePage)
1086-
{
1087-
_ = QueryResultsAsync(false);
1088-
}
1085+
_ = QueryResultsAsync(false);
10891086
}
10901087

10911088
public void Query(bool searchDelay, bool isReQuery = false)

Flow.Launcher/ViewModel/PluginViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public bool PluginHomeState
8282
{
8383
PluginPair.Metadata.HomeDisabled = !value;
8484
PluginSettingsObject.HomeDiabled = !value;
85+
// We should refresh results when these two settings are changed but we cannot do that
86+
// Because the order of the results will change, making the interface look weird
87+
// So we would better refresh results when query text is changed next time
8588
}
8689
}
8790

0 commit comments

Comments
 (0)