Skip to content

Commit

Permalink
Protect web time interval
Browse files Browse the repository at this point in the history
  • Loading branch information
javalikescript committed Dec 30, 2024
1 parent 9847da8 commit 01099eb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions extensions/web-time/web-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ define(['./web-time.xml'], function(timeTemplate) {
var self = this;
var date = new Date();
self.refresh(date);
this.clearTimer();
var ms = 1000 - (date.getTime() % 1000);
setTimeout(function() {
self.refresh(new Date());
self.registerTimer(1000);
// TODO Interval refresh should be provided by the app.
this.timer = setTimeout(function() {
if (app.isActivePage(self)) {
self.refresh(new Date());
self.registerTimer(1000);
}
}, ms);
},
onHide: function() {
Expand Down

0 comments on commit 01099eb

Please sign in to comment.