Skip to content

Commit

Permalink
Fix comic update interval bug
Browse files Browse the repository at this point in the history
The update timer was being set every time a new comic was fetched when it only needed to be set once. Turns out it repeats. Who knew?
  • Loading branch information
Blastitt committed Feb 23, 2017
1 parent 75f423c commit 246a2fe
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions DailyXKCD.js
Expand Up @@ -26,6 +26,12 @@ Module.register("DailyXKCD", {
this.autoIntervals = [];

this.getComic();

self = this;

setInterval(function() {
self.getComic();
}, self.config.updateInterval);

if (this.config.scrollInterval < 3000) {
// animation takes 3 seconds
Expand Down Expand Up @@ -71,7 +77,7 @@ Module.register("DailyXKCD", {
this.dailyComic = payload.img;
this.dailyComicTitle = payload.safe_title;
this.dailyComicAlt = payload.alt;
this.scheduleUpdate();
this.updateDom(1000);
}
},

Expand Down Expand Up @@ -210,16 +216,5 @@ Module.register("DailyXKCD", {
interval: newInterval,
time: time
});
},

scheduleUpdate: function() {
var self = this;

self.updateDom(2000);

setInterval(function() {
self.getComic();
}, this.config.updateInterval);
}

});

0 comments on commit 246a2fe

Please sign in to comment.