X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Futils%2Fstorage.js;h=ab459662d15379040da9f974f3500cc31f76d231;hp=bb7fdce7dd3aca1d0c372f8f284303aa24494431;hb=ce87ac6a12007a62a55a45e404f818df3eb90f64;hpb=4fe5664d48e37cf7e0de7562e8e76e8698b0ea74 diff --git a/client/src/utils/storage.js b/client/src/utils/storage.js index bb7fdce7..ab459662 100644 --- a/client/src/utils/storage.js +++ b/client/src/utils/storage.js @@ -2,9 +2,11 @@ // https://developer.mozilla.org/fr/docs/Web/API/API_IndexedDB // https://dexie.org/ +import { storageState } from "@/store"; + export const GameStorage = { - init: function(myid, oppid, gameId, variant, mycolor, fenStart) + init: function(myid, oppid, gameId, variant, mycolor, fenStart, mode) { localStorage.setItem("myid", myid); localStorage.setItem("gameId", gameId); @@ -12,6 +14,21 @@ export const GameStorage = localStorage.setItem("mycolor", mycolor); localStorage.setItem("fenStart", fenStart); localStorage.setItem("moves", []); + + + + game.score = localStorage.getItem("score"); + game.mycolor = localStorage.getItem("mycolor"); + game.fenStart = localStorage.getItem("fenStart"); + game.fen = localStorage.getItem("fen"); + game.moves = JSON.parse(localStorage.getItem("moves")); + game.players = JSON.parse(localStorage.getItem("players")); + game.started = JSON.parse(localStorage.getItem("started")); + game.clocks = JSON.parse(localStorage.getItem("clocks")); + game.timeControl = localStorage.getItem("timeControl"); + game.increment = localStorage.getItem("increment"); + game.vname = localStorage.getItem("vname"); + game.mode = "live"; }, // TODO: also option to takeback a move ?