diff options
author | Iván Ávalos <avalos@disroot.org> | 2023-09-16 16:13:33 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2023-09-16 16:13:33 -0600 |
commit | be1aa14b94e435488864aa77d895ad8d93865d7c (patch) | |
tree | 713cf49fb6e8516788a437a91730d7d56540a384 /iosApp/iosApp/Units | |
parent | 6c69520fc2a968cb27d1f751f34a123205936567 (diff) | |
download | etbsa-trackermap-mobile-be1aa14b94e435488864aa77d895ad8d93865d7c.tar.gz etbsa-trackermap-mobile-be1aa14b94e435488864aa77d895ad8d93865d7c.tar.bz2 etbsa-trackermap-mobile-be1aa14b94e435488864aa77d895ad8d93865d7c.zip |
- [shared] Downgrade Kotlin to 1.8.22 due to Native issues
- [shared] Upgrade Ktor to 2.3.4 and migrate code
- [ios] Update view models to use @MainActor and Kotlin migrations
Diffstat (limited to 'iosApp/iosApp/Units')
-rw-r--r-- | iosApp/iosApp/Units/UnitsViewModel.swift | 17 |
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) { |