From 722e082526c7d07d8c456ea51b658da2e86992ca Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Mon, 3 Jan 2022 16:20:53 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Rename=20method=20from=20update?= =?UTF-8?q?=20to=20rebuild?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Domain/Menu/MainMenu.swift | 17 +++++++++-------- phpmon/Domain/Preferences/PrefsVC.swift | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/phpmon/Domain/Menu/MainMenu.swift b/phpmon/Domain/Menu/MainMenu.swift index 7cda0f7..ae12f5f 100644 --- a/phpmon/Domain/Menu/MainMenu.swift +++ b/phpmon/Domain/Menu/MainMenu.swift @@ -24,8 +24,9 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate { /** Update the menu's contents, based on what's going on. + This will rebuild the entire menu, so this can take a few moments. */ - func update() { + func rebuild() { // Update the menu item on the main thread DispatchQueue.main.async { [self] in // Create a new menu @@ -97,13 +98,13 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate { PhpEnv.shared.isBusy = true setBusyImage() DispatchQueue.global(qos: .userInitiated).async { [unowned self] in - update() + rebuild() execute() PhpEnv.shared.isBusy = false DispatchQueue.main.async { [self] in updatePhpVersionInStatusBar() - update() + rebuild() completion() } } @@ -122,7 +123,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate { @objc func updatePhpVersionInStatusBar() { refreshIcon() - update() + rebuild() } func refreshIcon() { @@ -287,7 +288,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate { updatePhpVersionInStatusBar() // Update the menu - update() + rebuild() let completion = { PhpEnv.shared.delegate?.switcherDidCompleteSwitch() @@ -298,7 +299,7 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate { // Perform UI updates on main thread DispatchQueue.main.async { [self] in updatePhpVersionInStatusBar() - update() + rebuild() let sendLocalNotification = { LocalNotification.send( @@ -361,13 +362,13 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate { private func updateGlobalDependencies(notify: Bool, completion: @escaping (Bool) -> Void) { PhpEnv.shared.isBusy = true setBusyImage() - self.update() + self.rebuild() let noLongerBusy = { PhpEnv.shared.isBusy = false DispatchQueue.main.async { [self] in self.updatePhpVersionInStatusBar() - self.update() + self.rebuild() } } diff --git a/phpmon/Domain/Preferences/PrefsVC.swift b/phpmon/Domain/Preferences/PrefsVC.swift index a1aaaab..b2555ef 100644 --- a/phpmon/Domain/Preferences/PrefsVC.swift +++ b/phpmon/Domain/Preferences/PrefsVC.swift @@ -64,7 +64,7 @@ class PrefsVC: NSViewController { preference: .fullPhpVersionDynamicIcon, action: { MainMenu.shared.refreshIcon() - MainMenu.shared.update() + MainMenu.shared.rebuild() } ), CheckboxPreferenceView.make(