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

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

ganesh profile image Ganesh Raja ・1 min read

100 Days of Code (6 Part Series)

1) Vs-Code Extension - Project Setup and Basic functionalities 2) Vs Code Extension 3 ... 4 3) Day 3 - 100 days of Coding - Vs Code Extension 4) Day 4 - 100 days of Coding - Vs Code Extension - Store Date in a permanent file 5) Day 5 - 100 days of Coding - Python - Add text into Image 6) 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();
  }

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));
  }

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

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

100 Days of Code (6 Part Series)

1) Vs-Code Extension - Project Setup and Basic functionalities 2) Vs Code Extension 3 ... 4 3) Day 3 - 100 days of Coding - Vs Code Extension 4) Day 4 - 100 days of Coding - Vs Code Extension - Store Date in a permanent file 5) Day 5 - 100 days of Coding - Python - Add text into Image 6) Day 6 - 100 days of Coding - Vs Code Extension - add restart feature

Posted on Apr 16 by:

Discussion

markdown guide