Skip to content

Commit

Permalink
fix(android): return to correct game when reloading from background
Browse files Browse the repository at this point in the history
  • Loading branch information
autoreleasefool committed Sep 14, 2024
1 parent 6b0400b commit fac3b59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ sealed class Route(val route: String, val isBottomBarVisible: Boolean = true) {
savedStateHandle.get<String>("series")?.decodeListFromRoute()?.map {
SeriesID.fromString(it)
} ?: emptyList()
fun setGame(savedStateHandle: SavedStateHandle, game: GameID) {
savedStateHandle["game"] = game.toString()
}
}
data object EditTeamSeries : Route(
"edit_team_series/{teamSeries}/{game}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ class GamesEditorViewModel @Inject constructor(
initialValue = GamesEditorScreenUiState.Loading,
)

init {
viewModelScope.launch(ioDispatcher) {
currentGameId
.onEach { Route.EditGame.setGame(savedStateHandle, it) }
.launchIn(this)
}
}

override fun onResume(owner: LifecycleOwner) {
isGameDetailsSheetVisible.value = true
}
Expand Down

0 comments on commit fac3b59

Please sign in to comment.