diff --git a/apps/pomodo/pomodoro.js b/apps/pomodo/pomodoro.js index 5570d9b47..c376d9a06 100644 --- a/apps/pomodo/pomodoro.js +++ b/apps/pomodo/pomodoro.js @@ -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 () {