Skip to content

Commit

Permalink
Merge pull request #138 from mikael-ros/137-bug-report-timer-has-some…
Browse files Browse the repository at this point in the history
…times-already-started

Made it theoretically impossible for the timer to glitch out
  • Loading branch information
mikael-ros authored Sep 14, 2024
2 parents 8a91b7c + dc3d591 commit 9759aa8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/components/ui/Timer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class Time {
this.sound = new Audio(timerSound);
this.sound.volume = getSetOrElse("volume", 1.0);
this.timeDisplay(this.toString());
this.interval = null;
}

start(){
this.interval = window.setInterval(() => {
if (!this.lapsed()){
this.tick()
Expand Down Expand Up @@ -51,12 +55,7 @@ class Time {
this.time = this.initTime;
this.kill(false);
this.timeDisplay(this.toString());
this.interval = window.setInterval(() => {
if (!this.lapsed()){
this.tick()
} else {
this.kill(true);
}}, 1000);
this.start();
}

reset(){
Expand Down

0 comments on commit 9759aa8

Please sign in to comment.