mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-03-30 16:30:09 +02:00
🐛 Address some MainActor annotations
This commit is contained in:
@@ -151,7 +151,6 @@ extension MainMenu {
|
|||||||
When the environment is not OK, present an alert to inform the user.
|
When the environment is not OK, present an alert to inform the user.
|
||||||
*/
|
*/
|
||||||
private func onEnvironmentFail() async {
|
private func onEnvironmentFail() async {
|
||||||
Task { @MainActor [self] in
|
|
||||||
NVAlert()
|
NVAlert()
|
||||||
.withInformation(
|
.withInformation(
|
||||||
title: "alert.cannot_start.title".localized,
|
title: "alert.cannot_start.title".localized,
|
||||||
@@ -165,11 +164,8 @@ extension MainMenu {
|
|||||||
})
|
})
|
||||||
.show()
|
.show()
|
||||||
|
|
||||||
Task { // An issue occurred, fire startup checks again after dismissal
|
|
||||||
await startup()
|
await startup()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Detect which applications are installed that can be used to open a domain's source directory.
|
Detect which applications are installed that can be used to open a domain's source directory.
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ struct HeaderView: View {
|
|||||||
|
|
||||||
// MARK: - NSMenuItem
|
// MARK: - NSMenuItem
|
||||||
|
|
||||||
|
@MainActor
|
||||||
static func asMenuItem(
|
static func asMenuItem(
|
||||||
text: String,
|
text: String,
|
||||||
minimumWidth: CGFloat? = nil
|
minimumWidth: CGFloat? = nil
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import NVAlert
|
|||||||
|
|
||||||
struct ServicesView: View {
|
struct ServicesView: View {
|
||||||
|
|
||||||
|
@MainActor
|
||||||
static func asMenuItem(perRow: Int = 4) -> NSMenuItem {
|
static func asMenuItem(perRow: Int = 4) -> NSMenuItem {
|
||||||
let view = {
|
let view = {
|
||||||
let rootView = Self(manager: ServicesManager.shared, perRow: perRow)
|
let rootView = Self(manager: ServicesManager.shared, perRow: perRow)
|
||||||
@@ -103,6 +104,13 @@ struct ServiceView: View {
|
|||||||
var service: Service
|
var service: Service
|
||||||
@State var isBusy: Bool = false
|
@State var isBusy: Bool = false
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
private func toggleService() async {
|
||||||
|
isBusy = true
|
||||||
|
await ServicesManager.shared.toggleService(named: service.name)
|
||||||
|
isBusy = false
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .center, spacing: 0) {
|
VStack(alignment: .center, spacing: 0) {
|
||||||
Text(service.name.uppercased())
|
Text(service.name.uppercased())
|
||||||
@@ -133,11 +141,7 @@ struct ServiceView: View {
|
|||||||
}
|
}
|
||||||
if service.status == .error {
|
if service.status == .error {
|
||||||
Button {
|
Button {
|
||||||
Task {
|
Task { await toggleService() }
|
||||||
isBusy = true
|
|
||||||
await ServicesManager.shared.toggleService(named: service.name)
|
|
||||||
isBusy = false
|
|
||||||
}
|
|
||||||
} label: {
|
} label: {
|
||||||
Text("E")
|
Text("E")
|
||||||
.frame(width: 12.0, height: 12.0)
|
.frame(width: 12.0, height: 12.0)
|
||||||
@@ -148,11 +152,7 @@ struct ServiceView: View {
|
|||||||
}
|
}
|
||||||
if service.status == .active || service.status == .inactive {
|
if service.status == .active || service.status == .inactive {
|
||||||
Button {
|
Button {
|
||||||
Task {
|
Task { await toggleService() }
|
||||||
isBusy = true
|
|
||||||
await ServicesManager.shared.toggleService(named: service.name)
|
|
||||||
isBusy = false
|
|
||||||
}
|
|
||||||
} label: {
|
} label: {
|
||||||
Image(
|
Image(
|
||||||
systemName: service.status == .active ? "checkmark" : "xmark"
|
systemName: service.status == .active ? "checkmark" : "xmark"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import SwiftUI
|
|||||||
|
|
||||||
struct StatsView: View {
|
struct StatsView: View {
|
||||||
|
|
||||||
|
@MainActor
|
||||||
static func asMenuItem(memory: String, post: String, upload: String) -> NSMenuItem {
|
static func asMenuItem(memory: String, post: String, upload: String) -> NSMenuItem {
|
||||||
let item = NSMenuItem()
|
let item = NSMenuItem()
|
||||||
let view = NSHostingView(
|
let view = NSHostingView(
|
||||||
|
|||||||
Reference in New Issue
Block a user