1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 03:50:08 +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 {
case active
case inactive
case loading
case missing
}
@ -25,11 +26,17 @@ public class ServiceWrapper: ObservableObject, Identifiable, Hashable {
var formula: HomebrewFormula
var service: HomebrewService?
var isBusy: Bool = false
public var name: String {
return formula.name
}
public var status: ServiceStatus {
if isBusy {
return .loading
}
guard let service = self.service else {
return .missing
}
@ -39,20 +46,16 @@ public class ServiceWrapper: ObservableObject, Identifiable, Hashable {
init(formula: HomebrewFormula) {
self.formula = formula
self.isBusy = true
}
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) {
hasher.combine(formula)
hasher.combine(service)
}
public func broadcastChanged() {
Task { @MainActor in
self.objectWillChange.send()
}
}
}