aboutsummaryrefslogtreecommitdiff
path: root/iosApp/iosApp/Units/UnitsViewModel.swift
diff options
context:
space:
mode:
Diffstat (limited to 'iosApp/iosApp/Units/UnitsViewModel.swift')
-rw-r--r--iosApp/iosApp/Units/UnitsViewModel.swift17
1 files changed, 12 insertions, 5 deletions
diff --git a/iosApp/iosApp/Units/UnitsViewModel.swift b/iosApp/iosApp/Units/UnitsViewModel.swift
index 6a3ce19..7fcc80e 100644
--- a/iosApp/iosApp/Units/UnitsViewModel.swift
+++ b/iosApp/iosApp/Units/UnitsViewModel.swift
@@ -19,6 +19,7 @@ import Foundation
import WhirlyGlobe
import shared
+@MainActor
class UnitsViewModel: ObservableObject {
@Inject var unitsController: UnitsController
@Inject var geofenceController: GeofencesController
@@ -45,7 +46,9 @@ class UnitsViewModel: ObservableObject {
@Published var unitsDisplayMode: UnitsDisplayMode = .map
@Published var units: [UnitInformation] = [] {
didSet {
- markers = units.compactMap(Marker.companion.fromUnit)
+ Task { @MainActor in
+ markers = units.compactMap(Marker.companion.fromUnit)
+ }
}
}
@Published var markers: [Marker] = []
@@ -81,20 +84,24 @@ class UnitsViewModel: ObservableObject {
private func setupObservers() {
let unitsCollector = Collector<[UnitInformation]>(callback: setUnits)
- unitsController.displayedUnitsFlow.collect(collector: unitsCollector) { unit, error in }
+ unitsController.displayedUnitsFlow.collect(collector: unitsCollector) { _ in }
let geofencesCollector = Collector<[Int: Geofence]>(callback: setGeofences)
- geofenceController.geofencesFlow.collect(collector: geofencesCollector) { unit, error in }
+ geofenceController.geofencesFlow.collect(collector: geofencesCollector) { _ in }
}
private func setUnits(units: [UnitInformation]) {
print("Positions")
- self.units = units
+ Task { @MainActor in
+ self.units = units
+ }
updateSelectedUnit()
}
private func setGeofences(geofences: [Int: Geofence]) {
- self.geofences = geofences
+ Task { @MainActor in
+ self.geofences = geofences
+ }
}
func selectUnit(unit: UnitInformation?, switchToMap: Bool = true) {