@@ -52,8 +52,6 @@ public class MainViewModel : BaseModel, ISavable
5252 private ChannelWriter < ResultsForUpdate > _resultsUpdateChannelWriter ;
5353 private Task _resultsViewUpdateTask ;
5454
55-
56-
5755 #endregion
5856
5957 #region Constructor
@@ -112,7 +110,9 @@ async Task updateAction()
112110 }
113111
114112 Log . Error ( "MainViewModel" , "Unexpected ResultViewUpdate ends" ) ;
115- } ;
113+ }
114+
115+ ;
116116
117117 void continueAction ( Task t )
118118 {
@@ -693,33 +693,32 @@ private void SetOpenResultModifiers()
693693 OpenResultCommandModifiers = _settings . OpenResultModifiers ?? DefaultOpenResultModifiers ;
694694 }
695695
696- public void ToggleFlowLauncher ( )
696+ public async void ToggleFlowLauncher ( )
697697 {
698698 if ( MainWindowVisibility != Visibility . Visible )
699699 {
700700 MainWindowVisibility = Visibility . Visible ;
701701 }
702702 else
703703 {
704- if ( _settings . LastQueryMode == LastQueryMode . Empty )
704+ switch ( _settings . LastQueryMode )
705705 {
706- Application . Current . MainWindow . Opacity = 0 ; // Trick for no delay
707- ClearQueryCommand . Execute ( null ) ;
708- Task . Run ( ( ) =>
709- {
710- Thread . Sleep ( 100 ) ;
711- Application . Current . Dispatcher . BeginInvoke ( DispatcherPriority . Normal , new Action ( ( ) =>
712- {
713- MainWindowVisibility = Visibility . Collapsed ;
714- Application . Current . MainWindow . Opacity = 1 ;
715- } ) ) ;
716- } ) ;
717- }
718- else
719- {
720-
721- MainWindowVisibility = Visibility . Collapsed ;
706+ case LastQueryMode . Empty :
707+ ChangeQueryText ( string . Empty ) ;
708+ Application . Current . MainWindow . Opacity = 0 ; // Trick for no delay
709+ await Task . Delay ( 100 ) ;
710+ Application . Current . MainWindow . Opacity = 1 ;
711+ break ;
712+ case LastQueryMode . Preserved :
713+ LastQuerySelected = true ;
714+ break ;
715+ case LastQueryMode . Selected :
716+ LastQuerySelected = false ;
717+ break ;
718+ default :
719+ throw new ArgumentException ( $ "wrong LastQueryMode: <{ _settings . LastQueryMode } >") ;
722720 }
721+ MainWindowVisibility = Visibility . Collapsed ;
723722 }
724723 }
725724
@@ -731,40 +730,13 @@ public void Hide()
731730 }
732731 }
733732
734-
735733 #endregion
736734
737- public void OnHotkey ( object sender , HotkeyEventArgs e )
738- {
739- if ( ! ShouldIgnoreHotkeys ( ) )
740- {
741-
742- if ( _settings . LastQueryMode == LastQueryMode . Empty )
743- {
744- ChangeQueryText ( string . Empty ) ;
745- }
746- else if ( _settings . LastQueryMode == LastQueryMode . Preserved )
747- {
748- LastQuerySelected = true ;
749- }
750- else if ( _settings . LastQueryMode == LastQueryMode . Selected )
751- {
752- LastQuerySelected = false ;
753- }
754- else
755- {
756- throw new ArgumentException ( $ "wrong LastQueryMode: <{ _settings . LastQueryMode } >") ;
757- }
758-
759- ToggleFlowLauncher ( ) ;
760- }
761- }
762-
763735
764736 /// <summary>
765737 /// Checks if Flow Launcher should ignore any hotkeys
766738 /// </summary>
767- public bool ShouldIgnoreHotkeys ( )
739+ public bool ShouldIgnoreHotkeys ( )
768740 {
769741 return _settings . IgnoreHotkeysOnFullscreen && WindowsInteropHelper . IsWindowFullscreen ( ) ;
770742 }
0 commit comments