From cad1079db46c30055698552fb8dd422eb9afddea Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Wed, 10 Feb 2021 19:42:09 +0100 Subject: Properly clean redux state when leaving a game --- .../src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt | 1 + .../main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'sw-ui/src/main/kotlin/org') diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt index b1d730a0..61d7a60c 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt @@ -100,6 +100,7 @@ private fun gameStateReducer(gameState: GameState?, action: RAction): GameState? is StartTransactionSelection -> gameState?.copy(transactionSelector = action.transactionSelector) is CancelTransactionSelection -> gameState?.copy(transactionSelector = null) is RequestPrepareMove -> gameState?.copy(transactionSelector = null) + is LeaveLobbyAction -> null else -> gameState } diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt index 4e196afb..53ade155 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt @@ -87,12 +87,12 @@ private fun SwSagaContext.launchApiActionHandlersIn(scope: CoroutineScope, sessi scope.launchOnEach { session.addBot(it.botDisplayName) } scope.launchOnEach { session.reorderPlayers(it.orderedPlayers) } scope.launchOnEach { session.reassignWonders(it.wonders) } - // mapAction { updateSettings(it.settings) } scope.launchOnEach { session.startGame() } scope.launchOnEach { session.sayReady() } scope.launchOnEach { session.prepareMove(it.move) } scope.launchOnEach { session.unprepareMove() } + scope.launchOnEach { session.leaveGame() } } private fun SwSagaContext.launchApiEventHandlersIn(scope: CoroutineScope, session: SevenWondersSession) { @@ -118,10 +118,4 @@ private fun SwSagaContext.launchApiEventHandlersIn(scope: CoroutineScope, sessio dispatch(Navigate(Route.GAME)) } } - - // FIXME map this actions like others and await server event instead - scope.launchOnEach { - session.leaveGame() - dispatch(Navigate(Route.GAME_BROWSER)) - } } -- cgit