DEV Community

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

Posted on

1

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

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();
Enter fullscreen mode Exit fullscreen mode

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);
  }
Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

Tomorrow I will be working on improvising the Storage feature.

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

Image of Wix Studio

2025: Your year to build apps that sell

Dive into hands-on resources and actionable strategies designed to help you build and sell apps on the Wix App Market.

Get started

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay