Skip to content

Commit 12ee364

Browse files
committed
display export indicator
1 parent 36fe39a commit 12ee364

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

src/web/src/app/_db-view/db-view-mail-tab.component.html

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,33 @@
1515
</ul>
1616
</ng-template>
1717
<div class="py-2 d-flex">
18-
<a class="d-flex flex-grow-1" href="javascript:void(0)" (click)="export()">Export</a>
18+
<a class="d-flex flex-grow-1" href="javascript:void(0)"
19+
*ngIf="!exporting; else progressTemplate"
20+
(click)="export()"
21+
>Export</a>
22+
<ng-template #progressTemplate>
23+
<div class="text-primary d-flex flex-grow-1" style="cursor: not-allowed">
24+
Export
25+
<small><i class="fa fa-spinner fa-pulse fa-fw ml-1"></i></small>
26+
</div>
27+
</ng-template>
1928
<i class="fa fa-info-circle text-danger d-flex pt-1 ml-1"
2029
[popover]="dangerPopupTemplate" placement="top" container="body" triggers="mouseenter:mouseleave"
2130
></i>
2231
<i class="fa fa-info-circle text-warning d-flex pt-1 ml-1"
2332
[popover]="warningPopupTemplate" placement="top" container="body" triggers="mouseenter:mouseleave"
2433
></i>
2534
<ng-template #dangerPopupTemplate>
26-
App exports emails in their original <br>form, <span class="text-danger">unencrypted</span> and <span class="text-danger">unsanitized</span>!
35+
<div class="text-center">
36+
App exports emails<br>in their original form,<br>
37+
<span class="text-danger">unencrypted</span> and <span class="text-danger">unsanitized</span>!
38+
</div>
2739
</ng-template>
2840
<ng-template #warningPopupTemplate>
29-
Attachments are ignored during export.
41+
<div class="text-center">
42+
Attachments are ignored<br>
43+
during export.
44+
</div>
3045
</ng-template>
3146
</div>
3247
</div>

src/web/src/app/_db-view/db-view-mail-tab.component.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {ChangeDetectionStrategy, Component, Input, OnDestroy} from "@angular/core";
1+
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnDestroy} from "@angular/core";
22
import {EMPTY, Subject} from "rxjs";
33
import {Store, select} from "@ngrx/store";
4-
import {concatMap, mergeMap, takeUntil} from "rxjs/operators";
4+
import {concatMap, filter, finalize, mergeMap, takeUntil, throttleTime} from "rxjs/operators";
55

66
import {CORE_ACTIONS, DB_VIEW_ACTIONS} from "src/web/src/app/store/actions";
77
import {DbAccountPk, MAIL_FOLDER_TYPE, Mail, View} from "src/shared/model/database";
@@ -19,6 +19,8 @@ import {ToggleFolderMetadataPropEmitter} from "./db-view-mails.component";
1919
changeDetection: ChangeDetectionStrategy.OnPush,
2020
})
2121
export class DbViewMailTabComponent extends NgChangesObservableComponent implements OnDestroy {
22+
exporting?: boolean;
23+
2224
@Input()
2325
dbAccountPk!: DbAccountPk;
2426

@@ -65,6 +67,7 @@ export class DbViewMailTabComponent extends NgChangesObservableComponent impleme
6567
constructor(
6668
private store: Store<State>,
6769
private api: ElectronService,
70+
private changeDetectorRef: ChangeDetectorRef,
6871
) {
6972
super();
7073
}
@@ -87,9 +90,23 @@ export class DbViewMailTabComponent extends NgChangesObservableComponent impleme
8790

8891
export() {
8992
this.api.ipcMainClient({timeoutMs: ONE_SECOND_MS * 60 * 5})("dbExport")(this.dbAccountPk)
90-
.pipe(takeUntil(this.unSubscribe$))
93+
.pipe(
94+
takeUntil(this.unSubscribe$),
95+
filter((value) => "progress" in value),
96+
throttleTime(ONE_SECOND_MS / 2),
97+
finalize(() => {
98+
delete this.exporting;
99+
this.changeDetectorRef.detectChanges();
100+
}),
101+
)
91102
.subscribe(
92-
() => {},
103+
() => {
104+
if (this.exporting) {
105+
return;
106+
}
107+
this.exporting = true;
108+
this.changeDetectorRef.detectChanges();
109+
},
93110
(error) => this.store.dispatch(CORE_ACTIONS.Fail(error)),
94111
);
95112
}

0 commit comments

Comments
 (0)