diff --git a/app-src/scripts/constants.js b/app-src/scripts/constants.js index 06d0434fca..e34541194d 100644 --- a/app-src/scripts/constants.js +++ b/app-src/scripts/constants.js @@ -114,12 +114,15 @@ syncPath: '~/sync.json', }, pomodoro: { + isEnabled: true, duration: moment.duration(45, 'minutes'), breakDuration: moment.duration(5, 'minutes'), longerBreakDuration: moment.duration(15, 'minutes'), cyclesBeforeLongerBreak: 4, + isStopTrackingOnBreak: true, + isStopTrackingOnLongBreak: true, + isOnlyTrackPomodoroTime: false, isShowDistractionsOnBreak: true, - isEnabled: true, }, isTakeABreakEnabled: false, takeABreakMinWorkingTime: undefined, diff --git a/app-src/scripts/pomodoro-button/pomodoro-button-s.js b/app-src/scripts/pomodoro-button/pomodoro-button-s.js index a609767155..3a0b0a6d8b 100644 --- a/app-src/scripts/pomodoro-button/pomodoro-button-s.js +++ b/app-src/scripts/pomodoro-button/pomodoro-button-s.js @@ -15,7 +15,7 @@ class PomodoroButton { /* @ngInject */ - constructor($rootScope, $interval, Dialogs, Tasks) { + constructor($rootScope, $interval, Dialogs, Tasks, LS_DEFAULTS) { this.$rootScope = $rootScope; this.$interval = $interval; this.Dialogs = Dialogs; @@ -24,6 +24,10 @@ this.data = this.$rootScope.r.currentSession.pomodoro || {}; this.$rootScope.r.currentSession.pomodoro = this.data; + if (!this.$rootScope.r.config.pomodoro) { + this.$rootScope.r.config.pomodoro = LS_DEFAULTS.config.pomodoro; + } + this.config = this.$rootScope.r.config.pomodoro; this.initSession(); @@ -80,8 +84,11 @@ sessionDone() { this.data.isOnBreak = !this.data.isOnBreak; if (this.data.isOnBreak) { - this.lastCurrentTask = this.Tasks.getCurrent(); - this.Tasks.updateCurrent(undefined); + if ((this.config.isStopTrackingOnBreak && this.isOnShortBreak()) || + (this.config.isStopTrackingOnLongBreak && this.isOnLongBreak())) { + this.lastCurrentTask = this.Tasks.getCurrent(); + this.Tasks.updateCurrent(undefined); + } } else { this.data.currentCycle++; this.selectTask() @@ -91,17 +98,14 @@ } setSessionTimerTime() { - if (this.data.isOnBreak) { - // init break session timer - if (this.data.currentCycle % this.config.cyclesBeforeLongerBreak === 0) { - this.data.currentSessionTime = moment - .duration(this.config.longerBreakDuration) - .asMilliseconds(); - } else { - this.data.currentSessionTime = moment - .duration(this.config.breakDuration) - .asMilliseconds(); - } + if (this.isOnLongBreak()) { + this.data.currentSessionTime = moment + .duration(this.config.longerBreakDuration) + .asMilliseconds(); + } else if (this.isOnShortBreak()) { + this.data.currentSessionTime = moment + .duration(this.config.breakDuration) + .asMilliseconds(); } else { // init work session timer this.data.currentSessionTime = moment.duration(this.config.duration).asMilliseconds(); @@ -125,19 +129,31 @@ } } + isOnLongBreak() { + return (this.data.isOnBreak && (this.data.currentCycle % this.config.cyclesBeforeLongerBreak === 0)); + } + + isOnShortBreak() { + return (this.data.isOnBreak && (this.data.currentCycle % this.config.cyclesBeforeLongerBreak !== 0)); + } + selectTask(cb) { + const execCbIfGiven = () => { + if (cb) { + cb.apply(this); + } + }; + if (!this.Tasks.getCurrent()) { if (this.lastCurrentTask) { this.Tasks.updateCurrent(this.lastCurrentTask); - cb && cb.apply(this); + execCbIfGiven(); } else { this.Dialogs('TASK_SELECTION') - .then(() => { - cb && cb.apply(this); - }); + .then(execCbIfGiven); } } else { - cb && cb.apply(this); + execCbIfGiven(); } } } diff --git a/app-src/scripts/settings/misc-settings/misc-settings-d.html b/app-src/scripts/settings/misc-settings/misc-settings-d.html index 6bf31f6ba2..ce71c7df5b 100644 --- a/app-src/scripts/settings/misc-settings/misc-settings-d.html +++ b/app-src/scripts/settings/misc-settings/misc-settings-d.html @@ -19,7 +19,8 @@
The pomodoro timer can be configured via 4 settings. The duration of every work session, the duration of normal breaks, the number of work sessions to run before a longer break is started and the duration of this longer break.
You can also set if you want to display your distractions during your pomodoro breaks.
- +Setting "Pause time tracking on pomodoro break" will also track your breaks as work time spent on a task. Setting "Pause time tracking on longer pomodoro break" will do the same for the longer breaks.
+Enabling "Only track pomodoro time" will disable time tracking if you're not in an active pomodoro work session.
@@ -109,6 +110,27 @@ ng-model="vm.settings.pomodoro.cyclesBeforeLongerBreak"> +