Skip to content

Commit

Permalink
Made it theoretically impossible for the timer to glitch out
Browse files Browse the repository at this point in the history
  • Loading branch information
mikael-ros committed Sep 14, 2024
1 parent 8a91b7c commit dc3d591
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 dc3d591

Please sign in to comment.