@@ -442,12 +442,16 @@ public List<Result> LoadContextMenus(Result selectedResult)
442442 Title = Context . API . GetTranslation ( "flowlauncher_plugin_program_disable_program" ) ,
443443 Action = c =>
444444 {
445- _ = DisableProgramAsync ( program ) ;
445+ _ = Task . Run ( async ( ) =>
446+ {
447+ await DisableProgramAsync ( program ) ;
448+ ResetCache ( ) ;
449+ Context . API . ReQuery ( ) ;
450+ } ) ;
446451 Context . API . ShowMsg (
447452 Context . API . GetTranslation ( "flowlauncher_plugin_program_disable_dlgtitle_success" ) ,
448453 Context . API . GetTranslation (
449454 "flowlauncher_plugin_program_disable_dlgtitle_success_message" ) ) ;
450- Context . API . ReQuery ( ) ;
451455 return false ;
452456 } ,
453457 IcoPath = "Images/disable.png" ,
@@ -464,46 +468,40 @@ private static async Task DisableProgramAsync(IProgram programToDelete)
464468 return ;
465469
466470 await _uwpsLock . WaitAsync ( ) ;
467- var reindexUwps = true ;
468471 try
469472 {
470- reindexUwps = _uwps . Any ( x => x . UniqueIdentifier == programToDelete . UniqueIdentifier ) ;
471- var program = _uwps . First ( x => x . UniqueIdentifier == programToDelete . UniqueIdentifier ) ;
472- program . Enabled = false ;
473- _settings . DisabledProgramSources . Add ( new ProgramSource ( program ) ) ;
473+ var program = _uwps . FirstOrDefault ( x => x . UniqueIdentifier == programToDelete . UniqueIdentifier ) ;
474+ if ( program != null )
475+ {
476+ program . Enabled = false ;
477+ _settings . DisabledProgramSources . Add ( new ProgramSource ( program ) ) ;
478+ // Reindex UWP programs
479+ _ = Task . Run ( IndexUwpProgramsAsync ) ;
480+ return ;
481+ }
474482 }
475483 finally
476484 {
477485 _uwpsLock . Release ( ) ;
478486 }
479487
480- // Reindex UWP programs
481- if ( reindexUwps )
482- {
483- _ = Task . Run ( IndexUwpProgramsAsync ) ;
484- return ;
485- }
486-
487488 await _win32sLock . WaitAsync ( ) ;
488- var reindexWin32s = true ;
489489 try
490490 {
491- reindexWin32s = _win32s . Any ( x => x . UniqueIdentifier == programToDelete . UniqueIdentifier ) ;
492- var program = _win32s . First ( x => x . UniqueIdentifier == programToDelete . UniqueIdentifier ) ;
493- program . Enabled = false ;
494- _settings . DisabledProgramSources . Add ( new ProgramSource ( program ) ) ;
491+ var program = _win32s . FirstOrDefault ( x => x . UniqueIdentifier == programToDelete . UniqueIdentifier ) ;
492+ if ( program != null )
493+ {
494+ program . Enabled = false ;
495+ _settings . DisabledProgramSources . Add ( new ProgramSource ( program ) ) ;
496+ // Reindex Win32 programs
497+ _ = Task . Run ( IndexWin32ProgramsAsync ) ;
498+ return ;
499+ }
495500 }
496501 finally
497502 {
498503 _win32sLock . Release ( ) ;
499504 }
500-
501- // Reindex Win32 programs
502- if ( reindexWin32s )
503- {
504- _ = Task . Run ( IndexWin32ProgramsAsync ) ;
505- return ;
506- }
507505 }
508506
509507 public static void StartProcess ( Func < ProcessStartInfo , Process > runProcess , ProcessStartInfo info )
0 commit comments