From 7ecd4fa8c2e4b2b14a76be39cb6e6f7650ad26fa Mon Sep 17 00:00:00 2001 From: Lukas Jans Date: Sat, 9 Mar 2024 19:57:35 +0100 Subject: [PATCH] Perform auto refreshes asynchronously --- scripts/handler/core.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/handler/core.js b/scripts/handler/core.js index dadf031..c9fe472 100644 --- a/scripts/handler/core.js +++ b/scripts/handler/core.js @@ -27,13 +27,6 @@ class CoreHandler { // Process request async process(request) { - // Auto refresh - const checked = await this.controller.idb.state.get('checked'); - if(!checked || new Date() - checked > 15*60*1000) { - await this.controller.idb.state.put(new Date(), 'checked'); - if(navigator.onLine) await controller.refresh(); - } - // Load page and module const page = request.params[1]; const module = this.modules[page]; @@ -60,6 +53,13 @@ class CoreHandler { // Remember visitable page if(page != 'error') await this.controller.idb.state.put(page, 'page'); + // Auto refresh + const checked = await this.controller.idb.state.get('checked'); + if(!checked || new Date() - checked > 15*60*1000) { + await this.controller.idb.state.put(new Date(), 'checked'); + if(navigator.onLine) controller.refresh(); + } + // Render template return await this.controller.renderTemplate(page, data); }