show notice for long-running update requests

This commit is contained in:
Jesse D. McDonald 2020-04-28 01:00:42 -05:00
parent 81eb34f4d8
commit 3184831ebb
1 changed files with 19 additions and 5 deletions

View File

@ -462,11 +462,25 @@ $(function (){
Object.assign(meta, extra);
}
meta.modified = $('#cb_board').data('modified');
IO.sendUpdate(gameId, meta).catch((err) => {
new jBox('Notice', {
content: 'Failed to send update to server.',
});
const noticeBox = new jBox('Notice', {
content: 'Saving...',
autoClose: false,
delayOpen: 200,
delayClose: 2000,
onCloseComplete() { this.destroy(); },
});
const modified = meta.modified = $('#cb_board').data('modified');
IO.sendUpdate(gameId, meta).then((response) => {
noticeBox.close({ ignoreDelay: true });
if (response && response.data && Number.isInteger(response.data.modified)) {
if (response.data.modified > modified) {
$('#cb_board').data('modified', response.data.modified);
}
}
}).catch((err) => {
noticeBox.setContent('Failed to send update to server.');
noticeBox.close();
debug('update error', err);
/* force a reset back to the latest server data */