mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-11-08 05:30:05 +01:00
👌 Fix timing issue
This commit is contained in:
@@ -18,6 +18,8 @@ class ServicesManager: ObservableObject {
|
|||||||
@Published var services: [String: ServiceWrapper] = [:]
|
@Published var services: [String: ServiceWrapper] = [:]
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
Log.info("Initializing ServicesManager")
|
||||||
|
|
||||||
formulae = [
|
formulae = [
|
||||||
Homebrew.Formulae.php,
|
Homebrew.Formulae.php,
|
||||||
Homebrew.Formulae.nginx,
|
Homebrew.Formulae.nginx,
|
||||||
@@ -79,8 +81,8 @@ class ServicesManager: ObservableObject {
|
|||||||
Service wrapper, that contains the Homebrew JSON output (if determined) and the formula.
|
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.
|
This helps the app determine whether a service should run as an administrator or not.
|
||||||
*/
|
*/
|
||||||
public class ServiceWrapper {
|
public struct ServiceWrapper {
|
||||||
public let formula: HomebrewFormula
|
public var formula: HomebrewFormula
|
||||||
public var service: HomebrewService?
|
public var service: HomebrewService?
|
||||||
|
|
||||||
init(formula: HomebrewFormula) {
|
init(formula: HomebrewFormula) {
|
||||||
@@ -93,7 +95,7 @@ class ServicesManager: ObservableObject {
|
|||||||
*/
|
*/
|
||||||
func withDummyServices(_ services: [String: Bool]) -> Self {
|
func withDummyServices(_ services: [String: Bool]) -> Self {
|
||||||
for (service, enabled) in services {
|
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)
|
item.service = HomebrewService.dummy(named: service, enabled: enabled)
|
||||||
self.services[service] = item
|
self.services[service] = item
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ extension MainMenu {
|
|||||||
// Determine what the `php` formula is aliased to
|
// Determine what the `php` formula is aliased to
|
||||||
await PhpEnv.shared.determinePhpAlias()
|
await PhpEnv.shared.determinePhpAlias()
|
||||||
|
|
||||||
|
// Initialize preferences
|
||||||
|
_ = Preferences.shared
|
||||||
|
|
||||||
// Determine install method
|
// Determine install method
|
||||||
Log.info(HomebrewDiagnostics.customCaskInstalled
|
Log.info(HomebrewDiagnostics.customCaskInstalled
|
||||||
? "[BREW] The app has probably been installed via Homebrew Cask."
|
? "[BREW] The app has probably been installed via Homebrew Cask."
|
||||||
|
|||||||
@@ -16,15 +16,10 @@ struct ServicesView: View {
|
|||||||
|
|
||||||
static func asMenuItem(perRow: Int = 3) -> NSMenuItem {
|
static func asMenuItem(perRow: Int = 3) -> NSMenuItem {
|
||||||
let item = NSMenuItem()
|
let item = NSMenuItem()
|
||||||
var services = [
|
|
||||||
Homebrew.Formulae.php.name,
|
|
||||||
Homebrew.Formulae.nginx.name,
|
|
||||||
Homebrew.Formulae.dnsmasq.name
|
|
||||||
]
|
|
||||||
|
|
||||||
if Preferences.custom.hasServices() {
|
let services = ServicesManager.shared.services.keys.map({ item in
|
||||||
services += Preferences.custom.services!
|
return item
|
||||||
}
|
})
|
||||||
|
|
||||||
let view = NSHostingView(
|
let view = NSHostingView(
|
||||||
rootView: Self(
|
rootView: Self(
|
||||||
@@ -90,9 +85,11 @@ struct CheckmarkView: View {
|
|||||||
public func toggleService() async {
|
public func toggleService() async {
|
||||||
if active()! {
|
if active()! {
|
||||||
await Actions.stopService(name: serviceName)
|
await Actions.stopService(name: serviceName)
|
||||||
|
await delay(seconds: 1.2)
|
||||||
busy = false
|
busy = false
|
||||||
} else {
|
} else {
|
||||||
await Actions.startService(name: serviceName)
|
await Actions.startService(name: serviceName)
|
||||||
|
await delay(seconds: 1.2)
|
||||||
busy = false
|
busy = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user