From bfc27008ccf75974a83aaa547681922001d566d7 Mon Sep 17 00:00:00 2001 From: "louis.pontoise" Date: Fri, 10 Jan 2020 14:09:19 +0900 Subject: [PATCH] fix: quitting multiple apps would refresh the ui multiple times --- alt-tab-macos/logic/Applications.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/alt-tab-macos/logic/Applications.swift b/alt-tab-macos/logic/Applications.swift index 9b39db89..a8b51ac4 100644 --- a/alt-tab-macos/logic/Applications.swift +++ b/alt-tab-macos/logic/Applications.swift @@ -40,10 +40,6 @@ class Applications { // some apps never finish launching; the observer leaks for them without this app.removeObserver() Applications.map.removeValue(forKey: runningApp.processIdentifier) - guard Windows.listRecentlyUsedFirst.count > 0 else { (App.shared as! App).hideUi(); return } - // TODO: implement of more sophisticated way to decide which thumbnail gets focused on app quit - Windows.focusedWindowIndex = 1 - (App.shared as! App).refreshOpenUi() } // sometimes removed `runningApps` are already terminated by the time they reach this method so we can't match their pid in `Applications.map` above // we need to remove them based on their lack of `bundleIdentifier` @@ -51,6 +47,10 @@ class Applications { Windows.listRecentlyUsedFirst.removeAll(where: { $0.application.runningApplication.bundleIdentifier == nil }) Applications.map = Applications.map.filter { $0.value.runningApplication.bundleIdentifier != nil } } + guard Windows.listRecentlyUsedFirst.count > 0 else { (App.shared as! App).hideUi(); return } + // TODO: implement of more sophisticated way to decide which thumbnail gets focused on app quit + Windows.focusedWindowIndex = 1 + (App.shared as! App).refreshOpenUi() } private static func filterApplications(_ apps: [NSRunningApplication]) -> [NSRunningApplication] {