X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fstore.js;h=e9bbf653534bc65b5f633b66c2a4513f97e24d17;hp=32347119caedfef7dec35c302402422c2b82925f;hb=03608482744c433ad284f4b61e85b2e8cff4f5f3;hpb=9d58ef95e3affd799571838164f7c5bbfda11f64 diff --git a/client/src/store.js b/client/src/store.js index 32347119..e9bbf653 100644 --- a/client/src/store.js +++ b/client/src/store.js @@ -15,13 +15,11 @@ export const store = initialize() { ajax("/variants", "GET", res => { this.state.variants = res.variantArray; }); this.state.user = { - // id and name could be undefined - id: localStorage["myuid"], - name: localStorage["myname"], + id: localStorage["myuid"] || 0, + name: localStorage["myname"] || "", //"anonymous" + sid: localStorage["mysid"] || getRandString(), }; - // TODO: if there is a socket ID in localStorage, it means a live game was interrupted (and should resume) - const mysid = localStorage["mysid"] || getRandString(); - this.state.conn = new WebSocket(params.socketUrl + "/?sid=" + mysid); + this.state.conn = new WebSocket(params.socketUrl + "/?sid=" + this.state.user.sid); // Settings initialized with values from localStorage this.state.settings = { bcolor: localStorage["bcolor"] || "lichess",