loading...
Cover image for Day 4 - 100 days of Coding - Vs Code Extension - Store Date in a permanent file

Day 4 - 100 days of Coding - Vs Code Extension - Store Date in a permanent file

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 4 of 100 days of coding

Today's Objectives

1)Add Pause Functionality for Rest Timer

2)Store Completed Pomodo into permanent file

I managed to complete the both the objective for today

Add Pause Functionality for Rest Timer

To Achieve this I had to Either add a new Command or adjust existing command. I decided to go with the existing command. So whenever startPomodoTimer is executed, it will check for current Action State, if it is Pomodoro Timer it will trigger start Work Timer or it will trigger rest Timer.

    if (this.currentAction == POMODO_TIMER) this.startWorkTimer();
    else this.startRestTimer();

Store Completed Pomodo into permanent file

To achieve this I had to use Vscode Context. There is a path allocated for all the plugins. To make sure our specific directory exist we need to make sure using fs module of node.

  try {
    fs.mkdirSync(context.globalStoragePath, { recursive: true });
  } catch (exception) {
    console.log(exception);
  }

So whenever a Pomodoro is completed, We need to call storeDatetoFile Method, Currently it's a simple text file that stores the start time of a Pomodoro and it's status (which is completed always)

  storeDataToFile() {
    fs.appendFile(this.fileName, this.currentTime + ",completed", (err) => console.log(err));
  }

Tomorrow I will be working on improvising the Storage feature.

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 10 '19 by:

Discussion

markdown guide