diff options
author | joffrey-bion <joffrey.bion@gmail.com> | 2021-02-10 19:42:09 +0100 |
---|---|---|
committer | joffrey-bion <joffrey.bion@gmail.com> | 2021-02-10 19:42:09 +0100 |
commit | cad1079db46c30055698552fb8dd422eb9afddea (patch) | |
tree | 3a9af71092b218251985f611c9426608efcfb8df /sw-ui/src/main/kotlin/org | |
parent | Update JVM target to 15 (diff) | |
download | seven-wonders-cad1079db46c30055698552fb8dd422eb9afddea.tar.gz seven-wonders-cad1079db46c30055698552fb8dd422eb9afddea.tar.bz2 seven-wonders-cad1079db46c30055698552fb8dd422eb9afddea.zip |
Properly clean redux state when leaving a game
Diffstat (limited to 'sw-ui/src/main/kotlin/org')
-rw-r--r-- | sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt | 1 | ||||
-rw-r--r-- | sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt | 8 |
2 files changed, 2 insertions, 7 deletions
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<RequestAddBot> { session.addBot(it.botDisplayName) } scope.launchOnEach<RequestReorderPlayers> { session.reorderPlayers(it.orderedPlayers) } scope.launchOnEach<RequestReassignWonders> { session.reassignWonders(it.wonders) } - // mapAction<RequestUpdateSettings> { updateSettings(it.settings) } scope.launchOnEach<RequestStartGame> { session.startGame() } scope.launchOnEach<RequestSayReady> { session.sayReady() } scope.launchOnEach<RequestPrepareMove> { session.prepareMove(it.move) } scope.launchOnEach<RequestUnprepareMove> { session.unprepareMove() } + scope.launchOnEach<RequestLeaveGame> { 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<RequestLeaveGame> { - session.leaveGame() - dispatch(Navigate(Route.GAME_BROWSER)) - } } |