reload: Replace setInterval with setTimeout.

We retry reloading repeatedly at an interval of 30 seconds,
to handle the case where window.location.reload has no
immediate affect.

Previously, setInterval was used for this, but this commit
replaces it with nested setTimeout calls.

This change will help us in avoiding a large number of
requests to `/` in case when browser tries to "catch up"
pending calls after unsuspend.
This commit is contained in:
Sahil Batra
2022-11-15 16:58:24 +05:30
committed by Tim Abbott
parent f80a999828
commit 5ce7015cc8

View File

@@ -246,10 +246,19 @@ function do_reload_app(send_after_reload, save_pointer, save_narrow, save_compos
blueslip.log("Retrying on-focus page reload");
window.location.reload(true);
});
setInterval(() => {
function retry_reload() {
// Schedule the next attempt to reload. This implementation
// aims to simulate setInterval, which was used previously.
//
// See comment for get_full_presence_list_update in
// activity.js for more details.
setTimeout(retry_reload, 30000);
blueslip.log("Retrying page reload due to 30s timer");
window.location.reload(true);
}, 30000);
}
setTimeout(retry_reload, 30000);
try {
server_events.cleanup_event_queue();