fix for not actually forcing reload when update fails

This commit is contained in:
Jesse D. McDonald 2020-04-28 14:57:06 -05:00
parent 3184831ebb
commit 2bfcc822a3
1 changed files with 6 additions and 5 deletions

View File

@ -484,24 +484,25 @@ $(function (){
debug('update error', err);
/* force a reset back to the latest server data */
switchGameId(gameId);
switchGameId(gameId, true);
});
}
function switchGameId(newId){
function switchGameId(newId, force) {
let boardElem = $('#cb_board');
let gameId = boardElem.data('gameId');
debug('switching from ' + gameId + ' to ' + newId);
if (newId === gameId) {
if (newId === gameId && !force) {
return;
}
cancelGameCallback();
/* cancel to reload data, but keep polling if game ID will be the same */
cancelGameCallback(newId === gameId);
boardElem.data('gameId', newId);
boardElem.data('modified', 0);
location.hash = '#/' + newId;
history.replaceState(null, document.title, '#/' + newId);
const notifyAfter = +new Date() + 2000;
$(window).data('notifyAfter', +new Date() + 2000);