mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user