Skip to content

Commit

Permalink
Merge pull request #7 from hft-app/ljans
Browse files Browse the repository at this point in the history
Perform auto refreshes asynchronously
  • Loading branch information
ljans authored Mar 9, 2024
2 parents d5cb431 + 7ecd4fa commit 0e9c1e5
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 0e9c1e5

Please sign in to comment.