Skip to content

Commit

Permalink
SHutdown old map states
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPushkin committed Oct 29, 2023
1 parent 6e76325 commit 2bfc6d1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/src/main/java/ru/spbu/depnav/ui/viewmodel/MapViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.distinctUntilChangedBy
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.getAndUpdate
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapLatest
Expand Down Expand Up @@ -248,11 +249,14 @@ class MapViewModel @Inject constructor(
}.toMap()
}

state.value = MapViewModelState(
mapName = mapName,
mapState = mapState,
floors = floors
)

state.getAndUpdate {
MapViewModelState(
mapName = mapName,
mapState = mapState,
floors = floors
)
}.mapState?.shutdown() // Shutdown the previous map state, if any

setFloor(checkNotNull(floors.keys.firstOrNull()) { "Map has no floors" })
}
Expand Down

0 comments on commit 2bfc6d1

Please sign in to comment.