Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private async void OnClosing(object sender, CancelEventArgs e)
_viewModel.Save();
e.Cancel = true;
await PluginManager.DisposePluginsAsync();
Application.Current.Shutdown();
Environment.Exit(0);
}

private void OnInitialized(object sender, EventArgs e)
Expand Down
45 changes: 21 additions & 24 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private void InitializeKeyCommands()
ReloadPluginDataCommand = new RelayCommand(_ =>
{
Hide();

PluginManager
.ReloadData()
.ContinueWith(_ =>
Expand Down Expand Up @@ -315,7 +315,7 @@ public string QueryText
/// <param name="queryText"></param>
public void ChangeQueryText(string queryText, bool reQuery = false)
{
if (QueryText!=queryText)
if (QueryText != queryText)
{
// re-query is done in QueryText's setter method
QueryText = queryText;
Expand Down Expand Up @@ -696,41 +696,38 @@ private void SetOpenResultModifiers()
OpenResultCommandModifiers = _settings.OpenResultModifiers ?? DefaultOpenResultModifiers;
}

public async void ToggleFlowLauncher()
public void ToggleFlowLauncher()
{
if (MainWindowVisibility != Visibility.Visible)
{
MainWindowVisibility = Visibility.Visible;
}
else
{
switch (_settings.LastQueryMode)
{
case LastQueryMode.Empty:
ChangeQueryText(string.Empty);
Application.Current.MainWindow.Opacity = 0; // Trick for no delay
await Task.Delay(100);
Application.Current.MainWindow.Opacity = 1;
break;
case LastQueryMode.Preserved:
LastQuerySelected = true;
break;
case LastQueryMode.Selected:
LastQuerySelected = false;
break;
default:
throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>");
}
MainWindowVisibility = Visibility.Collapsed;
Hide();
}
}

public void Hide()
public async void Hide()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why add async here? @onesounds / @taooceros

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for handling the task delay for fixing empty query issue.

{
if (MainWindowVisibility != Visibility.Collapsed)
switch (_settings.LastQueryMode)
{
ToggleFlowLauncher();
case LastQueryMode.Empty:
ChangeQueryText(string.Empty);
Application.Current.MainWindow.Opacity = 0; // Trick for no delay
await Task.Delay(100);
Application.Current.MainWindow.Opacity = 1;
break;
case LastQueryMode.Preserved:
LastQuerySelected = true;
break;
case LastQueryMode.Selected:
LastQuerySelected = false;
break;
default:
throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>");
}
MainWindowVisibility = Visibility.Collapsed;
}

#endregion
Expand Down