call render() again after render bouncer timer has elapsed

This is necessary so that the GUI really shows the latest data from server
after the timer has elapsed.

Also add some other minor fixes.
This commit is contained in:
Oliver Gerlich 2018-07-18 22:29:54 +02:00 committed by Geno
parent ba1045aacd
commit 67dd56d71d
1 changed files with 16 additions and 11 deletions

View File

@ -16,7 +16,6 @@ let init = false,
function renderView () { function renderView () {
if (!document.body) { if (!document.body) {
window.setTimeout(renderView, GUI_RENDER_DEBOUNCER_TIME);
return; return;
} }
@ -36,19 +35,25 @@ function renderView () {
router.resolve(); router.resolve();
} }
export function render () {
let timeout = false;
function reset () { let renderDebounceTimer = null,
timeout = null; numRenderCallsSkipped = 0;
}
if (timeout) { export function render () {
console('skip rendering to often'); if (renderDebounceTimer == null) {
window.clearTimeout(timeout);
}else{
renderView(); renderView();
renderDebounceTimer = window.setTimeout(() => {
renderDebounceTimer = null;
if (numRenderCallsSkipped > 0) {
console.log("skipped " + numRenderCallsSkipped + " render calls; calling render() now");
numRenderCallsSkipped = 0;
render();
}
}, GUI_RENDER_DEBOUNCER_TIME);
} else {
console.log("skip rendering");
numRenderCallsSkipped++;
} }
timeout = window.setTimeout(reset, GUI_RENDER_DEBOUNCER_TIME);
} }
export function setView (toView) { export function setView (toView) {