Skip to content

Commit cd3ae03

Browse files
author
Dmitry Yadrikhinsky
committed
Reminder
1 parent f9ee904 commit cd3ae03

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/services/projects/ProjectStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default class ProjectStore {
5353
}
5454

5555
this.projects = TreeModelStoreHelper.deleteItems(this.projects, condition);
56-
// this.projectService.save(this.projects);
56+
this.projectService.save(this.projects);
5757
}
5858

5959
restore() {

src/services/tasks/TaskStore.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default class TaskStore {
99
tasks: TasksByProject = {};
1010
activeTask: TaskModel | undefined;
1111
private tasksService = new TaskService();
12+
private interval: NodeJS.Timeout | undefined;
1213

1314
constructor() {
1415
makeAutoObservable(this);
@@ -104,18 +105,21 @@ export default class TaskStore {
104105
}
105106
this.activeTask = task;
106107
task.start();
108+
this.setupReminder(task);
107109
this.tasksService.save(this.tasks);
108110
}
109111

110112
stopTimer(task: TaskModel) {
111113
this.activeTask = undefined;
112114
task.stop();
115+
this.setupReminder();
113116
this.tasksService.save(this.tasks);
114117
}
115118

116119
restore() {
117120
this.tasks = this.tasksService.getAll();
118121
this.findActiveTask();
122+
this.setupReminder(this.activeTask);
119123
}
120124

121125
getCheckedKeys(projectId: string): string[] {
@@ -169,4 +173,27 @@ export default class TaskStore {
169173
}
170174
});
171175
}
176+
177+
private setupReminder(task?: TaskModel) {
178+
if (this.interval) {
179+
clearInterval(this.interval);
180+
}
181+
if (task) {
182+
console.log('Setup: Task in progress');
183+
this.interval = setInterval(() => {
184+
console.log('Task in progress');
185+
new Notification('You are tracking time', {
186+
body: `Task '${task.title}' in progress`,
187+
});
188+
}, 40 * 60 * 1000);
189+
} else {
190+
console.log('Setup: No tasks in progress');
191+
this.interval = setInterval(() => {
192+
console.log('No tasks in progress');
193+
new Notification('You are not tracking time', {
194+
body: 'There are not task that you track',
195+
});
196+
}, 15 * 60 * 1000);
197+
}
198+
}
172199
}

0 commit comments

Comments
 (0)