Skip to content

Commit

Permalink
Improve time left counter
Browse files Browse the repository at this point in the history
  • Loading branch information
nikelasi committed Jan 15, 2023
1 parent ad8cc36 commit 1ecd0e0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/popup/js/time-left.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ function millisToMinutesAndSeconds(millis) {
return minutes + ":" + (seconds < 10 ? '0' : '') + seconds;
}

setInterval(async () => {
const runTimeLeftUpdate = async () => {
const alarm = await browser.alarms.get("Breaks");
if (alarm) {
console.log("hello");
timeLeft = alarm.scheduledTime - Date.now();
}
if (timeLeft - 1000 >= 0) {
timeLeftValue.textContent = millisToMinutesAndSeconds(timeLeft);
} else {
timeLeftValue.textContent = "disabled"
}
}, 1000);
setTimeout(runTimeLeftUpdate, 1000);
};

runTimeLeftUpdate();

0 comments on commit 1ecd0e0

Please sign in to comment.