mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
Fix navigating away from the page in Firefox
When navigating away get_events will fail after we delete the event queue before leaving the page. In that case we try to reload the page to correct the problem. This happens before the page navigation is complete, and then we reload zulip keeping the user captive. This was only observed on on Firefox. (imported from commit e001172e87a9f2ab7cf07a477e46b9d87752ac04)
This commit is contained in:
committed by
Jessica McKellar
parent
fe826cdf2b
commit
5ad256fee7
@@ -159,6 +159,8 @@ function cleanup_before_reload() {
|
||||
}
|
||||
|
||||
function do_reload_app(send_after_reload, save_state, message) {
|
||||
if (reload_in_progress) { return; }
|
||||
|
||||
// TODO: we should completely disable the UI here
|
||||
if (save_state) {
|
||||
preserve_state(send_after_reload);
|
||||
@@ -241,5 +243,15 @@ exports.initiate = function (options) {
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('beforeunload', function () {
|
||||
// When navigating away from the page do not try to reload.
|
||||
// The polling get_events call will fail after we delete the event queue.
|
||||
// When that happens we reload the page to correct the problem. If this
|
||||
// happens before the navigation is complete the user is kept captive at
|
||||
// zulip.
|
||||
reload_in_progress = true;
|
||||
});
|
||||
|
||||
|
||||
return exports;
|
||||
}());
|
||||
|
||||
Reference in New Issue
Block a user