1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 03:50:08 +02:00

👌 Fix timing issue

This commit is contained in:
2022-11-22 00:14:46 +01:00
parent c3e55df9fb
commit 3f8739dc30
3 changed files with 13 additions and 11 deletions

View File

@ -18,6 +18,8 @@ class ServicesManager: ObservableObject {
@Published var services: [String: ServiceWrapper] = [:]
init() {
Log.info("Initializing ServicesManager")
formulae = [
Homebrew.Formulae.php,
Homebrew.Formulae.nginx,
@ -79,8 +81,8 @@ class ServicesManager: ObservableObject {
Service wrapper, that contains the Homebrew JSON output (if determined) and the formula.
This helps the app determine whether a service should run as an administrator or not.
*/
public class ServiceWrapper {
public let formula: HomebrewFormula
public struct ServiceWrapper {
public var formula: HomebrewFormula
public var service: HomebrewService?
init(formula: HomebrewFormula) {
@ -93,7 +95,7 @@ class ServicesManager: ObservableObject {
*/
func withDummyServices(_ services: [String: Bool]) -> Self {
for (service, enabled) in services {
let item = ServiceWrapper(formula: HomebrewFormula(service))
var item = ServiceWrapper(formula: HomebrewFormula(service))
item.service = HomebrewService.dummy(named: service, enabled: enabled)
self.services[service] = item
}

View File

@ -34,6 +34,9 @@ extension MainMenu {
// Determine what the `php` formula is aliased to
await PhpEnv.shared.determinePhpAlias()
// Initialize preferences
_ = Preferences.shared
// Determine install method
Log.info(HomebrewDiagnostics.customCaskInstalled
? "[BREW] The app has probably been installed via Homebrew Cask."

View File

@ -16,15 +16,10 @@ struct ServicesView: View {
static func asMenuItem(perRow: Int = 3) -> NSMenuItem {
let item = NSMenuItem()
var services = [
Homebrew.Formulae.php.name,
Homebrew.Formulae.nginx.name,
Homebrew.Formulae.dnsmasq.name
]
if Preferences.custom.hasServices() {
services += Preferences.custom.services!
}
let services = ServicesManager.shared.services.keys.map({ item in
return item
})
let view = NSHostingView(
rootView: Self(
@ -90,9 +85,11 @@ struct CheckmarkView: View {
public func toggleService() async {
if active()! {
await Actions.stopService(name: serviceName)
await delay(seconds: 1.2)
busy = false
} else {
await Actions.startService(name: serviceName)
await delay(seconds: 1.2)
busy = false
}
}