fix: bug when huge amount of time was wrongly tracked when application is idle for a long time (e.g. when being on lock screen over several hours)

This commit is contained in:
Johannes Millan 2018-02-27 19:51:42 +01:00
parent 99b1db9caf
commit 55ee2665a3

View file

@ -11,6 +11,7 @@
const IPC_EVENT_CURRENT_TASK_UPDATED = 'CHANGED_CURRENT_TASK';
const IPC_EVENT_IDLE_TIME = 'IDLE_TIME';
const MAX_TRACKING_PERIOD_VAL = 60000;
class TimeTracking {
/* @ngInject */
@ -45,7 +46,8 @@
let realPeriodDuration = moment.duration(now.diff(currentTrackingStart))
.asMilliseconds();
if (!this.isIdle) {
// only track if not idle and interval is smaller than threshold
if (!this.isIdle && realPeriodDuration <= MAX_TRACKING_PERIOD_VAL) {
this.Tasks.addTimeSpent(this.$rootScope.r.currentTask, realPeriodDuration);
}