Skip to content

Commit

Permalink
fix: save and go home marking tasks as done before confirmation in di…
Browse files Browse the repository at this point in the history
…alog
  • Loading branch information
johannesjo committed Jan 4, 2024
1 parent d661fad commit 90cff79
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/app/pages/daily-summary/daily-summary.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { GlobalConfigService } from '../../features/config/global-config.service
import {
delay,
filter,
first,
map,
shareReplay,
startWith,
Expand Down Expand Up @@ -212,13 +213,8 @@ export class DailySummaryComponent implements OnInit, OnDestroy {

async finishDay(): Promise<void> {
await this._beforeFinishDayService.executeActions();

const doneTasks = await this.workContextService.doneTasks$.pipe(take(1)).toPromise();

this._taskService.moveToArchive(doneTasks);

if (IS_ELECTRON && this.isForToday) {
this._matDialog
const isConfirm = await this._matDialog
.open(DialogConfirmComponent, {
restoreFocus: true,
data: {
Expand All @@ -228,18 +224,25 @@ export class DailySummaryComponent implements OnInit, OnDestroy {
},
})
.afterClosed()
.subscribe((isConfirm: boolean) => {
if (isConfirm) {
this._finishDayForGood(() => {
window.ea.shutdownNow();
});
} else if (isConfirm === false) {
this._finishDayForGood(() => {
this._router.navigate(['/active/tasks']);
});
}
.pipe(first())
.toPromise();

// dialog was just clicked away
if (isConfirm === undefined) {
return;
} else if (isConfirm === true) {
await this._moveDoneToArchive();
this._finishDayForGood(() => {
window.ea.shutdownNow();
});
} else if (isConfirm === false) {
await this._moveDoneToArchive();
this._finishDayForGood(() => {
this._router.navigate(['/active/tasks']);
});
}
} else {
await this._moveDoneToArchive();
this._finishDayForGood(() => {
this._router.navigate(['/active/tasks']);
});
Expand All @@ -264,6 +267,11 @@ export class DailySummaryComponent implements OnInit, OnDestroy {
this.selectedTabIndex = i;
}

private async _moveDoneToArchive(): Promise<void> {
const doneTasks = await this.workContextService.doneTasks$.pipe(take(1)).toPromise();
this._taskService.moveToArchive(doneTasks);
}

private async _finishDayForGood(cb?: any): Promise<void> {
const syncCfg = this.configService.cfg?.sync;
if (syncCfg?.isEnabled) {
Expand Down

0 comments on commit 90cff79

Please sign in to comment.