mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-17 16:37:43 +00:00
refactor: more signals
This commit is contained in:
parent
5efcc83bae
commit
3dbe2939f5
4 changed files with 13 additions and 20 deletions
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<select-task
|
||||
(taskChange)="onTaskChange($event)"
|
||||
[initialTask]="initialTask$ | async"
|
||||
[initialTask]="initialTask()"
|
||||
[isIncludeDoneTasks]="false"
|
||||
>
|
||||
</select-task>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import {
|
|||
} from '@angular/core';
|
||||
import { Task } from '../../tasks/task.model';
|
||||
import { TaskService } from '../../tasks/task.service';
|
||||
import { first } from 'rxjs/operators';
|
||||
import { Store } from '@ngrx/store';
|
||||
import {
|
||||
setFocusSessionActivePage,
|
||||
|
|
@ -17,7 +16,6 @@ import { FocusModeMode, FocusModePage } from '../focus-mode.const';
|
|||
import { T } from 'src/app/t.const';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatButton } from '@angular/material/button';
|
||||
import { AsyncPipe } from '@angular/common';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { SelectTaskComponent } from '../../tasks/select-task/select-task.component';
|
||||
import { selectFocusModeMode } from '../store/focus-mode.selectors';
|
||||
|
|
@ -29,7 +27,7 @@ import { selectFocusModeConfig } from '../../config/store/global-config.reducer'
|
|||
templateUrl: './focus-mode-task-selection.component.html',
|
||||
styleUrls: ['./focus-mode-task-selection.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [FormsModule, MatButton, AsyncPipe, TranslatePipe, SelectTaskComponent],
|
||||
imports: [FormsModule, MatButton, TranslatePipe, SelectTaskComponent],
|
||||
})
|
||||
export class FocusModeTaskSelectionComponent implements AfterViewInit, OnDestroy {
|
||||
readonly taskService = inject(TaskService);
|
||||
|
|
@ -39,7 +37,7 @@ export class FocusModeTaskSelectionComponent implements AfterViewInit, OnDestroy
|
|||
cfg = toSignal(this._store.select(selectFocusModeConfig));
|
||||
|
||||
selectedTask: string | Task | undefined;
|
||||
initialTask$ = this.taskService.firstStartableTask$.pipe(first());
|
||||
initialTask = this.taskService.firstStartableTask;
|
||||
focusTimeout = 0;
|
||||
T: typeof T = T;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { nanoid } from 'nanoid';
|
||||
import { first, map, take, withLatestFrom } from 'rxjs/operators';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { computed, inject, Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import {
|
||||
ArchiveTask,
|
||||
|
|
@ -38,7 +38,6 @@ import {
|
|||
selectAllTasks,
|
||||
selectCurrentTask,
|
||||
selectCurrentTaskId,
|
||||
selectCurrentTaskOrParentWithData,
|
||||
selectCurrentTaskParentOrCurrent,
|
||||
selectIsTaskDataLoaded,
|
||||
selectMainTasksWithoutTag,
|
||||
|
|
@ -135,10 +134,9 @@ export class TaskService {
|
|||
// NOTE: we can't use share here, as we need the last emitted value
|
||||
);
|
||||
|
||||
firstStartableTask$: Observable<Task | undefined> =
|
||||
this._workContextService.startableTasksForActiveContext$.pipe(
|
||||
map((tasks) => tasks[0]),
|
||||
);
|
||||
firstStartableTask = computed(
|
||||
() => this._workContextService.startableTasksForActiveContext()[0],
|
||||
);
|
||||
|
||||
taskDetailPanelTargetPanel$: Observable<TaskDetailTargetPanel | null | undefined> =
|
||||
this._store.pipe(
|
||||
|
|
@ -146,11 +144,6 @@ export class TaskService {
|
|||
// NOTE: we can't use share here, as we need the last emitted value
|
||||
);
|
||||
|
||||
currentTaskOrCurrentParent$: Observable<TaskWithSubTasks | null> = this._store.pipe(
|
||||
select(selectCurrentTaskOrParentWithData),
|
||||
// NOTE: we can't use share here, as we need the last emitted value
|
||||
);
|
||||
|
||||
isTaskDataLoaded$: Observable<boolean> = this._store.pipe(
|
||||
select(selectIsTaskDataLoaded),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { inject, Injectable } from '@angular/core';
|
||||
import { select, Store } from '@ngrx/store';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { combineLatest, interval, Observable, of, timer } from 'rxjs';
|
||||
import {
|
||||
WorkContext,
|
||||
|
|
@ -301,14 +302,15 @@ export class WorkContextService {
|
|||
this.backlogTasks$,
|
||||
]).pipe(map(([today, backlog]) => [...today, ...backlog]));
|
||||
|
||||
startableTasksForActiveContext$: Observable<Task[]> = this._afterDataLoadedOnce$.pipe(
|
||||
switchMap(() => this._store$),
|
||||
startableTasksForActiveContext$: Observable<Task[]> = this._store$.pipe(
|
||||
select(selectStartableTasksForActiveContext),
|
||||
shareReplay(1),
|
||||
);
|
||||
startableTasksForActiveContext = toSignal(this.startableTasksForActiveContext$, {
|
||||
initialValue: [],
|
||||
});
|
||||
|
||||
trackableTasksForActiveContext$: Observable<Task[]> = this._afterDataLoadedOnce$.pipe(
|
||||
switchMap(() => this._store$),
|
||||
trackableTasksForActiveContext$: Observable<Task[]> = this._store$.pipe(
|
||||
select(selectTrackableTasksForActiveContext),
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue