diff --git a/js/pacosako_io.js b/js/pacosako_io.js index 0049eb3..826dbf4 100644 --- a/js/pacosako_io.js +++ b/js/pacosako_io.js @@ -258,21 +258,18 @@ function gamePollState(gameId) { function processGame(gameId, data) { const game = gamePollState(gameId); - if (data && (game.data.modified === 0 || data.modified > game.data.modified)) { + if (data && data.modified > game.data.modified) { data.gameId = data.gameId || gameId; game.data = data; for (const cbId in game.listeners) { try { - game.listeners[cbId](JSON.parse(JSON.stringify(data)), gameId); + const copy = JSON.parse(JSON.stringify(data)); + game.listeners[cbId](copy, gameId); } catch(err) { console.error('uncaught exception in callback', err); } } - - if (data.modified !== 0) { - processMeta({ games: [data], modified: 0 }); - } } } @@ -343,14 +340,10 @@ function processMeta(data) { const gameId = game.gameId; if (gameId in meta.games === false || game.modified > meta.games[gameId].modified) { meta.games[gameId] = game; - if (gameId in games === false || games[gameId].data.modified === 0) { - const copy = Object.assign({}, game); - copy.modified = 0; - processGame(gameId, copy); - } for (const cbId in meta.listeners) { try { - meta.listeners[cbId](JSON.parse(JSON.stringify(game)), gameId); + const copy = Object.assign({}, game); + meta.listeners[cbId](copy, gameId); } catch(err) { console.error('uncaught exception in callback', err); }