Эх сурвалжийг харах

Fixing order of state changes in some actions

Kirk Trombley 5 жил өмнө
parent
commit
fa77e619b8

+ 9 - 9
client/src/domain/gameStore.js

@@ -83,7 +83,6 @@ export const [
       roundNum,
       roundNum,
       selectedPoint || { timeout: true }
       selectedPoint || { timeout: true }
     );
     );
-    const { currentRound, coord, timer } = await getCurrentRound(gameId, playerId);
     set({
     set({
       lastRound: {
       lastRound: {
         roundNum,
         roundNum,
@@ -91,19 +90,20 @@ export const [
         score,
         score,
         totalScore,
         totalScore,
       },
       },
+      gameState: POST_ROUND,
+    });
+    const { currentRound, coord, timer } = await getCurrentRound(gameId, playerId);
+    set({
       currentRound,
       currentRound,
       targetPoint: coord,
       targetPoint: coord,
       roundSeconds: timer,
       roundSeconds: timer,
-      gameState: POST_ROUND,
     });
     });
-    clearTimerFromLocalStorage();
-    clearPointFromLocalStorage();
   },
   },
-  goToSummary: ([set, get], gameId, clearSavedGame = true) => {
-    set({
-      gameId: gameId || get.gameId(),
-      gameState: POST_GAME,
-    });
+  goToSummary: ([set], gameId, clearSavedGame = true) => {
+    if (gameId) {
+      set({ gameId });
+    }
+    set({ gameState: POST_GAME });
     if (clearSavedGame) {
     if (clearSavedGame) {
       clearTimerFromLocalStorage();
       clearTimerFromLocalStorage();
       clearPointFromLocalStorage();
       clearPointFromLocalStorage();