- if (Number.isInteger(gameId) || !isNaN(parseInt(gameId))) {
- // corr: only move, fen and score
- ajax("/games", "PUT", {
- gid: gameId,
- newObj: {
- // Some fields may be undefined:
- chat: obj.chat,
- move: obj.move,
- fen: obj.fen,
- score: obj.score,
- scoreMsg: obj.scoreMsg,
- drawOffer: obj.drawOffer
- }
- });
- } else {
- // live
- dbOperation(db => {
- let objectStore = db
- .transaction("games", "readwrite")
- .objectStore("games");
- objectStore.get(gameId).onsuccess = function(event) {
- const game = event.target.result;
+ // live
+ dbOperation((err,db) => {
+ let objectStore = db
+ .transaction("games", "readwrite")
+ .objectStore("games");
+ objectStore.get(gameId).onsuccess = function(event) {
+ // Ignoring error silently: shouldn't happen now. TODO?
+ if (event.target.result) {
+ let game = event.target.result;
+ // Hidden tabs are delayed, to prevent multi-updates:
+ if (obj.moveIdx < game.moves.length) return;