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

👌 Revert loading

This commit is contained in:
2023-01-06 18:34:39 +01:00
parent 7b07520440
commit a090cbc20b

View File

@@ -14,6 +14,7 @@ import Foundation
public enum ServiceStatus: String { public enum ServiceStatus: String {
case active case active
case inactive case inactive
case loading
case missing case missing
} }
@@ -25,11 +26,17 @@ public class ServiceWrapper: ObservableObject, Identifiable, Hashable {
var formula: HomebrewFormula var formula: HomebrewFormula
var service: HomebrewService? var service: HomebrewService?
var isBusy: Bool = false
public var name: String { public var name: String {
return formula.name return formula.name
} }
public var status: ServiceStatus { public var status: ServiceStatus {
if isBusy {
return .loading
}
guard let service = self.service else { guard let service = self.service else {
return .missing return .missing
} }
@@ -39,20 +46,16 @@ public class ServiceWrapper: ObservableObject, Identifiable, Hashable {
init(formula: HomebrewFormula) { init(formula: HomebrewFormula) {
self.formula = formula self.formula = formula
self.isBusy = true
} }
public static func == (lhs: ServiceWrapper, rhs: ServiceWrapper) -> Bool { public static func == (lhs: ServiceWrapper, rhs: ServiceWrapper) -> Bool {
return lhs.hashValue == rhs.hashValue return lhs.service == rhs.service
&& lhs.formula == rhs.formula
} }
public func hash(into hasher: inout Hasher) { public func hash(into hasher: inout Hasher) {
hasher.combine(formula) hasher.combine(formula)
hasher.combine(service) hasher.combine(service)
} }
public func broadcastChanged() {
Task { @MainActor in
self.objectWillChange.send()
}
}
} }