|
@@ -1,7 +1,12 @@
|
|
import { PRE_GAME, PRE_ROUND, IN_ROUND, POST_ROUND, POST_GAME } from "./GameState";
|
|
import { PRE_GAME, PRE_ROUND, IN_ROUND, POST_ROUND, POST_GAME } from "./GameState";
|
|
import { createStore } from "../store";
|
|
import { createStore } from "../store";
|
|
import { joinGame, sendGuess } from "./apiMethods";
|
|
import { joinGame, sendGuess } from "./apiMethods";
|
|
-import { saveGameInfoToLocalStorage, clearGameInfoFromLocalStorage } from "./localStorageMethods";
|
|
|
|
|
|
+import {
|
|
|
|
+ saveGameInfoToLocalStorage,
|
|
|
|
+ clearGameInfoFromLocalStorage,
|
|
|
|
+ clearPointFromLocalStorage,
|
|
|
|
+ clearTimerFromLocalStorage,
|
|
|
|
+} from "./localStorageMethods";
|
|
|
|
|
|
export const [
|
|
export const [
|
|
{
|
|
{
|
|
@@ -38,6 +43,8 @@ export const [
|
|
const name = get.playerName();
|
|
const name = get.playerName();
|
|
const { playerId } = await joinGame(gameId, name);
|
|
const { playerId } = await joinGame(gameId, name);
|
|
set({ playerId });
|
|
set({ playerId });
|
|
|
|
+ clearTimerFromLocalStorage();
|
|
|
|
+ clearPointFromLocalStorage();
|
|
saveGameInfoToLocalStorage(gameId, name, playerId);
|
|
saveGameInfoToLocalStorage(gameId, name, playerId);
|
|
},
|
|
},
|
|
rejoinGame: ([set], gameId, playerName, playerId) => set({
|
|
rejoinGame: ([set], gameId, playerName, playerId) => set({
|
|
@@ -64,8 +71,12 @@ export const [
|
|
gameState: POST_ROUND,
|
|
gameState: POST_ROUND,
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- goToSummary: ([set, get], gameId) => {
|
|
|
|
- clearGameInfoFromLocalStorage();
|
|
|
|
|
|
+ goToSummary: ([set, get], gameId, clearSavedGame = true) => {
|
|
|
|
+ if (clearSavedGame) {
|
|
|
|
+ clearTimerFromLocalStorage();
|
|
|
|
+ clearPointFromLocalStorage();
|
|
|
|
+ clearGameInfoFromLocalStorage();
|
|
|
|
+ }
|
|
set({
|
|
set({
|
|
gameId: gameId || get.gameId(),
|
|
gameId: gameId || get.gameId(),
|
|
gameState: POST_GAME,
|
|
gameState: POST_GAME,
|