From 7fb5317808389592f07bdb92b85d4fab80643cfd Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Tue, 2 Sep 2025 21:17:48 +0200 Subject: [PATCH] feat(focusMode): select task instead of auto starting one --- .../focus-mode-main.component.spec.ts | 66 +------------------ .../focus-mode-main.component.ts | 11 +--- 2 files changed, 6 insertions(+), 71 deletions(-) diff --git a/src/app/features/focus-mode/focus-mode-main/focus-mode-main.component.spec.ts b/src/app/features/focus-mode/focus-mode-main/focus-mode-main.component.spec.ts index 02c951c92..3f4bb983e 100644 --- a/src/app/features/focus-mode/focus-mode-main/focus-mode-main.component.spec.ts +++ b/src/app/features/focus-mode/focus-mode-main/focus-mode-main.component.spec.ts @@ -52,13 +52,9 @@ describe('FocusModeMainComponent', () => { }); currentTaskSubject = new BehaviorSubject(mockTask); - const taskServiceSpy = jasmine.createSpyObj( - 'TaskService', - ['update', 'startFirstStartable'], - { - currentTask$: currentTaskSubject.asObservable(), - }, - ); + const taskServiceSpy = jasmine.createSpyObj('TaskService', ['update'], { + currentTask$: currentTaskSubject.asObservable(), + }); const taskAttachmentServiceSpy = jasmine.createSpyObj('TaskAttachmentService', [ 'createFromDrop', @@ -124,62 +120,6 @@ describe('FocusModeMainComponent', () => { expect(component.defaultTaskNotes).toBe('Default task notes template'); }); - it('should start first startable task if no current task', () => { - // Create a new test setup with null task - const nullTaskSubject = new BehaviorSubject(null); - const taskServiceWithNull = jasmine.createSpyObj( - 'TaskService', - ['update', 'startFirstStartable'], - { - currentTask$: nullTaskSubject.asObservable(), - }, - ); - - // Use the existing mocked services - const globalConfigSpy = jasmine.createSpyObj('GlobalConfigService', [], { - misc: jasmine.createSpy().and.returnValue({ - taskNotesTpl: 'Default task notes template', - }), - }); - - const focusModeSpy = jasmine.createSpyObj('FocusModeService', [], { - timeElapsed: jasmine.createSpy().and.returnValue(60000), - isCountTimeDown: jasmine.createSpy().and.returnValue(true), - progress: jasmine.createSpy().and.returnValue(0), - timeRemaining: jasmine.createSpy().and.returnValue(1500000), - isSessionRunning: jasmine.createSpy().and.returnValue(false), - isBreakActive: jasmine.createSpy().and.returnValue(false), - currentCycle: jasmine.createSpy().and.returnValue(1), - mode: jasmine.createSpy().and.returnValue('Pomodoro'), - }); - - TestBed.resetTestingModule(); - TestBed.configureTestingModule({ - imports: [ - FocusModeMainComponent, - NoopAnimationsModule, - TranslateModule.forRoot(), - ], - providers: [ - { provide: Store, useValue: mockStore }, - { provide: GlobalConfigService, useValue: globalConfigSpy }, - { provide: TaskService, useValue: taskServiceWithNull }, - { provide: TaskAttachmentService, useValue: mockTaskAttachmentService }, - { provide: IssueService, useValue: mockIssueService }, - { - provide: SimpleCounterService, - useValue: jasmine.createSpyObj('SimpleCounterService', ['']), - }, - { provide: FocusModeService, useValue: focusModeSpy }, - ], - }); - - const nullFixture = TestBed.createComponent(FocusModeMainComponent); - nullFixture.detectChanges(); - - expect(taskServiceWithNull.startFirstStartable).toHaveBeenCalled(); - }); - it('should initialize focus mode service properties', () => { expect(component.timeElapsed()).toBe(60000); expect(component.isCountTimeDown()).toBe(true); diff --git a/src/app/features/focus-mode/focus-mode-main/focus-mode-main.component.ts b/src/app/features/focus-mode/focus-mode-main/focus-mode-main.component.ts index 25ef5bb57..7718ad25a 100644 --- a/src/app/features/focus-mode/focus-mode-main/focus-mode-main.component.ts +++ b/src/app/features/focus-mode/focus-mode-main/focus-mode-main.component.ts @@ -115,15 +115,10 @@ export class FocusModeMainComponent implements OnDestroy { }); this.taskService.currentTask$.pipe(takeUntil(this._onDestroy$)).subscribe((task) => { this.task = task; + if (!task) { + this._store.dispatch(selectFocusTask()); + } }); - - this.taskService.currentTask$ - .pipe(first(), takeUntil(this._onDestroy$)) - .subscribe((task) => { - if (!task) { - this.taskService.startFirstStartable(); - } - }); } @HostListener('dragenter', ['$event']) onDragEnter(ev: DragEvent): void {