refactor(tasks): use action instead of weird subscribe combo for starting first startable

This commit is contained in:
Johannes Millan 2019-01-28 21:31:38 +01:00
parent 181829076d
commit 816fd0c376
2 changed files with 6 additions and 9 deletions

View file

@ -21,6 +21,7 @@ import {
RemoveTimeSpent,
RestoreTask,
SetCurrentTask,
StartFirstStartable,
TaskActionTypes,
ToggleStart,
ToggleTaskShowSubTasks,
@ -58,7 +59,6 @@ import { getWorklogStr } from '../../util/get-work-log-str';
import { Actions, ofType } from '@ngrx/effects';
import { IssueService } from '../issue/issue.service';
import { ProjectService } from '../project/project.service';
import { tasks_v1 } from 'googleapis';
@Injectable({
@ -224,6 +224,10 @@ export class TaskService {
}
}
startFirstStartable() {
this._store.dispatch(new StartFirstStartable());
}
async loadStateForProject(projectId) {
const lsTaskState = await this._persistenceService.loadTasksForProject(projectId);
this.loadState(lsTaskState || initialTaskState);

View file

@ -109,13 +109,6 @@ export class WorkViewPageComponent implements OnInit, OnDestroy {
startWork() {
// TODO refactor to action
this.isPlanYourDay = false;
this._subs.add(this.taskService.startableTaskIds$
.pipe(take(1))
.subscribe(taskIds => {
const nextTaskId = taskIds && taskIds[0];
if (nextTaskId) {
this.taskService.setCurrentId(nextTaskId);
}
}));
this.taskService.startFirstStartable();
}
}