Skip to content

Commit

Permalink
fix: follow setting when quick scheduling next week (#3373)
Browse files Browse the repository at this point in the history
  • Loading branch information
miqh committed Oct 6, 2024
1 parent c535162 commit 677ec49
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { PlannerService } from '../planner.service';
import { first } from 'rxjs/operators';
import { fadeAnimation } from '../../../ui/animations/fade.ani';
import { dateStrToUtcDate } from '../../../util/date-str-to-utc-date';
import { DateAdapter } from '@angular/material/core';

@Component({
selector: 'dialog-schedule-task',
Expand Down Expand Up @@ -78,6 +79,7 @@ export class DialogScheduleTaskComponent implements AfterViewInit {
private _taskService: TaskService,
private _reminderService: ReminderService,
private _plannerService: PlannerService,
private readonly _dateAdapter: DateAdapter<unknown>,
) {}

async ngAfterViewInit(): Promise<void> {
Expand Down Expand Up @@ -327,9 +329,14 @@ export class DialogScheduleTaskComponent implements AfterViewInit {
this.selectedDate = tomorrow;
break;
case 2:
const nextMonday = tDate;
nextMonday.setDate(nextMonday.getDate() + ((1 + 7 - nextMonday.getDay()) % 7));
this.selectedDate = nextMonday;
const nextFirstDayOfWeek = tDate;
const dayOffset =
(this._dateAdapter.getFirstDayOfWeek() -
this._dateAdapter.getDayOfWeek(nextFirstDayOfWeek) +
7) %
7 || 7;
nextFirstDayOfWeek.setDate(nextFirstDayOfWeek.getDate() + dayOffset);
this.selectedDate = nextFirstDayOfWeek;
break;
case 3:
const nextMonth = tDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import { PlannerActions } from '../../../planner/store/planner.actions';
import { combineDateAndTime } from '../../../../util/combine-date-and-time';
import { FocusModeService } from '../../../focus-mode/focus-mode.service';
import { isToday } from '../../../../util/is-today.util';
import { DateAdapter } from '@angular/material/core';

@Component({
selector: 'task-context-menu-inner',
Expand Down Expand Up @@ -159,6 +160,7 @@ export class TaskContextMenuInnerComponent implements AfterViewInit {
private readonly _globalConfigService: GlobalConfigService,
private readonly _store: Store,
private readonly _focusModeService: FocusModeService,
private readonly _dateAdapter: DateAdapter<unknown>,
) {}

ngAfterViewInit(): void {
Expand Down Expand Up @@ -495,9 +497,14 @@ export class TaskContextMenuInnerComponent implements AfterViewInit {
this._schedule(tomorrow);
break;
case 2:
const nextMonday = tDate;
nextMonday.setDate(nextMonday.getDate() + ((1 + 7 - nextMonday.getDay()) % 7));
this._schedule(nextMonday);
const nextFirstDayOfWeek = tDate;
const dayOffset =
(this._dateAdapter.getFirstDayOfWeek() -
this._dateAdapter.getDayOfWeek(nextFirstDayOfWeek) +
7) %
7 || 7;
nextFirstDayOfWeek.setDate(nextFirstDayOfWeek.getDate() + dayOffset);
this._schedule(nextFirstDayOfWeek);
break;
case 3:
const nextMonth = tDate;
Expand Down

0 comments on commit 677ec49

Please sign in to comment.