1
0
Fork 0

[Pomodoro] Save the last interval value

master
🦑Svarba, Rastislav 2019-11-27 09:14:48 +01:00
parent 624b53094d
commit 1f457ed9d1
No known key found for this signature in database
GPG Key ID: 18F9740D64C08249
1 changed files with 10 additions and 9 deletions

View File

@ -1,3 +1,5 @@
const storage = require("Storage");
const DEFAULT_TIME = 1500; // 25m
const TIME_BREAK = 300;
const STATES = {
@ -14,12 +16,6 @@ class State {
this.next = null;
}
goNext () {
if (this.next) {
this.next.run();
}
}
setNext (next) {
this.next = next;
}
@ -56,10 +52,14 @@ class State {
}
class InitState extends State {
constructor () {
constructor (time) {
super(STATES.INIT);
this.timeCounter = DEFAULT_TIME;
this.timeCounter = parseInt(storage.read(".pomodo") || DEFAULT_TIME, 10);
}
saveTime () {
storage.write('.pomodo', '' + this.timeCounter);
}
setButtons () {
@ -100,6 +100,7 @@ class InitState extends State {
}, BTN5, { repeat: true });
setWatch(() => {
this.saveTime();
const startedState = new StartedState(this.timeCounter);
this.setNext(startedState);
@ -119,7 +120,7 @@ class StartedState extends State {
constructor (timeCounter) {
super(STATES.STARTED);
this.timeCounter = timeCounter || DEFAULT_TIME;
this.timeCounter = timeCounter;
}
draw () {