Skip to content

Commit

Permalink
ws: Don't reload page if reload is already in progress
Browse files Browse the repository at this point in the history
If the page reload is taking a long time but already
in progress don't fire window.location.reload again.
  • Loading branch information
petervo committed Sep 15, 2017
1 parent 6befb5a commit d8d483e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/ws/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,23 @@ var phantom_checkpoint = phantom_checkpoint || function () { };
}

function login_reload (wanted) {
// Force a reload if not triggered below
// because only the hash part of the url
// changed
var timer = window.setTimeout(function() {
timer = null;
window.location.reload(true);
}, 100);

if (wanted && wanted != window.location.href)
window.location = wanted;

// Force a reload if the above didn't trigger it
window.setTimeout(function() {
window.location.reload(true);
}, 100);
// cancel forced reload if we are reloading
window.onbeforeunload = function() {
if (timer)
window.clearTimeout(timer);
timer = null;
};
}

function machine_application_login_reload (wanted) {
Expand Down

0 comments on commit d8d483e

Please sign in to comment.