diff options
author | Isidro Henoch <imhenoch@protonmail.com> | 2022-01-12 18:37:07 -0600 |
---|---|---|
committer | Isidro Henoch <imhenoch@protonmail.com> | 2022-01-12 18:37:07 -0600 |
commit | 9cdf080dfb589c748928657c8ce0a53b3959d3a8 (patch) | |
tree | 477afcf01a9557384a72af783d8fee7a0353470b /shared/src/commonMain | |
parent | 9a125dd2ca5144ae49761b73564871bb0b38c0b7 (diff) | |
download | etbsa-trackermap-mobile-9cdf080dfb589c748928657c8ce0a53b3959d3a8.tar.gz etbsa-trackermap-mobile-9cdf080dfb589c748928657c8ce0a53b3959d3a8.tar.bz2 etbsa-trackermap-mobile-9cdf080dfb589c748928657c8ce0a53b3959d3a8.zip |
Fixes the empty unit details
Diffstat (limited to 'shared/src/commonMain')
-rw-r--r-- | shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt index 576ca0e..584f656 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt @@ -51,8 +51,11 @@ class UnitsController( queryFlow.value = query } - fun getUnit(deviceId: Int): UnitInformation? { - return unitsFlow.value.firstOrNull { it.device.id == deviceId } + suspend fun getUnit(deviceId: Int): UnitInformation { + val device = devicesApi.devicesGet(id = deviceId).first() + val position = positionsApi.positionsGet(id = device.positionId).first() + + return UnitInformation(device, position) } private suspend fun setupFlows() { |