fix for missing data when showing tiles for old games
This commit is contained in:
parent
8de753aac5
commit
59af2e0a29
|
|
@ -780,6 +780,8 @@ $(function (){
|
||||||
$('#cb_dark_name').val(String(d.darkName || ''));
|
$('#cb_dark_name').val(String(d.darkName || ''));
|
||||||
|
|
||||||
$('#cb_board').data('modified', data.modified);
|
$('#cb_board').data('modified', data.modified);
|
||||||
|
|
||||||
|
updateSelectGameMeta(data, newId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -1305,11 +1307,6 @@ $(function (){
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSelectGameMeta(data, gameId) {
|
function updateSelectGameMeta(data, gameId) {
|
||||||
data = Object.assign({}, data, {
|
|
||||||
gameId: gameId || data.gameId,
|
|
||||||
timestamp: data.timestamp || +new Date(),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (typeof gameId !== 'string' || !gameId.match(/^[0-9a-f]{16}$/)) {
|
if (typeof gameId !== 'string' || !gameId.match(/^[0-9a-f]{16}$/)) {
|
||||||
debug('invalid game ID', gameId);
|
debug('invalid game ID', gameId);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1319,8 +1316,8 @@ $(function (){
|
||||||
const oldTile = $('#game_tile_' + gameId).first();
|
const oldTile = $('#game_tile_' + gameId).first();
|
||||||
|
|
||||||
if (!data.lightName && !data.darkName && !data.moves && gameId !== currentGameId) {
|
if (!data.lightName && !data.darkName && !data.moves && gameId !== currentGameId) {
|
||||||
oldTile.removeAttr('id');
|
|
||||||
if (oldTile.length >= 1) {
|
if (oldTile.length >= 1) {
|
||||||
|
oldTile.removeAttr('id');
|
||||||
oldTile.hide({
|
oldTile.hide({
|
||||||
effect: "clip",
|
effect: "clip",
|
||||||
direction: "horizontal",
|
direction: "horizontal",
|
||||||
|
|
@ -1332,6 +1329,13 @@ $(function (){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldTile.length && data.modified && oldTile.data('gameMeta').modified >= data.modified) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = Object.assign({ gameId, timestamp: +new Date(), modified: 0 }, data);
|
||||||
|
delete data.board;
|
||||||
|
|
||||||
const tile = oldTile.length ? oldTile :
|
const tile = oldTile.length ? oldTile :
|
||||||
$(`<div class="game-tile existing-game-tile"></div>`).hide();
|
$(`<div class="game-tile existing-game-tile"></div>`).hide();
|
||||||
tile.attr('id', 'game_tile_' + gameId).data('gameMeta', data).empty();
|
tile.attr('id', 'game_tile_' + gameId).data('gameMeta', data).empty();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue