Skip to content

Commit

Permalink
Merge pull request #1 from 73cirdan/issue33
Browse files Browse the repository at this point in the history
issue ianperrin#33 - rewrote setTimeout call
  • Loading branch information
73cirdan authored May 25, 2022
2 parents 0adb6e1 + d57c54c commit fb805a8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ 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 +63,13 @@ 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 fb805a8

Please sign in to comment.