Skip to content

Commit

Permalink
Perform auto refreshes asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
ljans committed Mar 9, 2024
1 parent 46e8fed commit 7ecd4fa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions scripts/handler/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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);
}
Expand Down

0 comments on commit 7ecd4fa

Please sign in to comment.