reload: Add on-focus handler after a delay.

(cherry picked from commit 9479eae87f)
This commit is contained in:
Tim Abbott 2024-02-02 13:08:44 -08:00
parent 187c9e4b14
commit ae05d780c7
1 changed files with 11 additions and 4 deletions

View File

@ -175,10 +175,17 @@ function do_reload_app(send_after_reload, save_pointer, save_narrow, save_compos
// broken state and cause lots of confusing tracebacks. So, we // broken state and cause lots of confusing tracebacks. So, we
// set ourselves to try reloading a bit later, both periodically // set ourselves to try reloading a bit later, both periodically
// and when the user focuses the window. // and when the user focuses the window.
$(window).one("focus", () => { setTimeout(() => {
blueslip.log("Retrying on-focus page reload"); // We add this handler after a bit of delay, because in some
window.location.reload(true); // browsers, processing window.location.reload causes the
}); // window to gain focus, and duplicate reload attempts result
// in the browser sending duplicate requests to `/`.
$(window).one("focus", () => {
blueslip.log("Retrying on-focus page reload");
window.location.reload(true);
});
}, 5000);
function retry_reload() { function retry_reload() {
blueslip.log("Retrying page reload due to 30s timer"); blueslip.log("Retrying page reload due to 30s timer");