aboutsummaryrefslogtreecommitdiff
path: root/shared/src/commonMain
diff options
context:
space:
mode:
authorIsidro Henoch <imhenoch@protonmail.com>2022-01-12 18:37:07 -0600
committerIsidro Henoch <imhenoch@protonmail.com>2022-01-12 18:37:07 -0600
commite386cd98427cf323285358057fa099b3f9641591 (patch)
tree477afcf01a9557384a72af783d8fee7a0353470b /shared/src/commonMain
parent8b9f4d7d7c1cebd380a617d25f7f580353f24535 (diff)
downloadetbsa-trackermap-mobile-e386cd98427cf323285358057fa099b3f9641591.tar.gz
etbsa-trackermap-mobile-e386cd98427cf323285358057fa099b3f9641591.tar.bz2
etbsa-trackermap-mobile-e386cd98427cf323285358057fa099b3f9641591.zip
Fixes the empty unit details
Diffstat (limited to 'shared/src/commonMain')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt7
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() {