summaryrefslogtreecommitdiff
path: root/sw-ui
diff options
context:
space:
mode:
authorjoffrey-bion <joffrey.bion@gmail.com>2021-02-10 19:42:09 +0100
committerjoffrey-bion <joffrey.bion@gmail.com>2021-02-10 19:42:09 +0100
commitcad1079db46c30055698552fb8dd422eb9afddea (patch)
tree3a9af71092b218251985f611c9426608efcfb8df /sw-ui
parentUpdate JVM target to 15 (diff)
downloadseven-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')
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt1
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt8
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))
- }
}
bgstack15