Skip to content

Commit

Permalink
Merge pull request #40 from 73cirdan/issue33
Browse files Browse the repository at this point in the history
issue #33 - rewrote setTimeout call
  • Loading branch information
ianperrin committed May 27, 2022
2 parents 0adb6e1 + 1938ba9 commit 3e4a814
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ module.exports = NodeHelper.create({
console.log(this.name + " is fetching " + this.config.type + " standings for the " + this.config.season + " season");
const endpoint = this.config.type === "DRIVER" ? "getDriverStandings" : "getConstructorStandings";
const season = (this.config.season === "current", new Date().getFullYear(), this.config.season);
const self = this;
f1Api[endpoint](season).then((standings) => {
console.log(this.name + " is returning " + this.config.type + " standings for the " + season + " season");
this.sendSocketNotification(this.config.type + "_STANDINGS", standings);
this.standingsTimerId = setTimeout(this.fetchStandings, this.config.reloadInterval);
this.standingsTimerId = setTimeout(function () {
self.fetchStandings();
}, this.config.reloadInterval);
});
},

Expand All @@ -62,12 +65,15 @@ module.exports = NodeHelper.create({
fetchSchedule: function () {
console.log(this.name + " is fetching the race schedule for the " + this.config.season + " season");
const season = (this.config.season === "current", new Date().getFullYear(), this.config.season);
const self = this;
f1Api.getSeasonRacesSchedule(season).then((raceSchedule) => {
if (raceSchedule) {
raceScheduleDB = raceSchedule;
this.sendSocketNotification("RACE_SCHEDULE", raceSchedule);
}
this.scheduleTimerId = setTimeout(this.fetchSchedule, this.config.reloadInterval);
this.scheduleTimerId = setTimeout(function () {
self.fetchSchedule();
}, this.config.reloadInterval);
});
},

Expand Down

0 comments on commit 3e4a814

Please sign in to comment.