From 9cdf080dfb589c748928657c8ce0a53b3959d3a8 Mon Sep 17 00:00:00 2001 From: Isidro Henoch Date: Wed, 12 Jan 2022 18:37:07 -0600 Subject: Fixes the empty unit details --- .../kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'shared/src/commonMain/kotlin/mx') 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() { -- cgit v1.2.3