diff options
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() { |