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:
@ -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
|
||||
}
|
||||
|
@ -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."
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user