File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
src/Files.App/Actions/Global Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -23,16 +23,35 @@ public HotKey SecondHotKey
2323 public RichGlyph Glyph
2424 => new ( themedIconStyle : "App.ThemedIcons.Omnibar.Search" ) ;
2525
26+ public bool IsExecutable
27+ => context . ShellPage is not null ;
28+
2629 public SearchAction ( )
2730 {
2831 context = Ioc . Default . GetRequiredService < IContentPageContext > ( ) ;
32+
33+ context . PropertyChanged += Context_PropertyChanged ;
2934 }
3035
3136 public Task ExecuteAsync ( object ? parameter = null )
3237 {
33- context . ShellPage ! . ToolbarViewModel . SwitchToSearchMode ( ) ;
38+ // Check if ShellPage is available before executing the action
39+ if ( context . ShellPage is null )
40+ return Task . CompletedTask ;
41+
42+ context . ShellPage . ToolbarViewModel . SwitchToSearchMode ( ) ;
3443
3544 return Task . CompletedTask ;
3645 }
46+
47+ private void Context_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
48+ {
49+ switch ( e . PropertyName )
50+ {
51+ case nameof ( IContentPageContext . ShellPage ) :
52+ OnPropertyChanged ( nameof ( IsExecutable ) ) ;
53+ break ;
54+ }
55+ }
3756 }
3857}
You can’t perform that action at this time.
0 commit comments