From 2bfcc822a34f586457fabdb89880ab498130160a Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Tue, 28 Apr 2020 14:57:06 -0500 Subject: [PATCH] fix for not actually forcing reload when update fails --- js/pacosako_ui.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/pacosako_ui.js b/js/pacosako_ui.js index 219bd4b..6bfb208 100644 --- a/js/pacosako_ui.js +++ b/js/pacosako_ui.js @@ -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);