DEV Community

Cover image for Day 6 - 100 days of Coding - Vs Code Extension - add restart feature
Ganesh Raja
Ganesh Raja

Posted on

Day 6 - 100 days of Coding - Vs Code Extension - add restart feature

So it's day 6 of 100 days of coding

Today's Objectives

1)Add Restart Functionality

2)Update the Format of the Data

Add Restart Functionality

To do this, I added a new command that will call the storeDate Method to make sure it stores the Data into File if it's a restarting Pomodoro.
Then it resets the value to default. Later it moves to the Start Timer Method to trigger new Pomodoro

  restartTimer() {
    if (this.tick >= 0) this.storeStatusToFile(); //Update File with Previous Pomodo Data
    this.resetPomodoTimer();
    this.startTimer();
  }
Enter fullscreen mode Exit fullscreen mode

Update the Format of the Data

Here we store the ISO String of Date & time the Pomodoro was started. If it's fully completed. We trigger completed. Else store as canceled


  storeStatusToFile() {
    let status = this.tick <= 0 && this.currentAction == POMODO_TIMER ? COMPLETED : CANCELED;
    let data = [this.startedTime.toISOString(), status].join(",");
    fs.appendFile(this.fileName, data + "\n", (err) => console.log(err));
  }
Enter fullscreen mode Exit fullscreen mode

Tomorrow I will be working on custom values for the PomodoTimer.

You can check the full code in my repo simple-pomodoro-timer

Top comments (0)