Skip to content

Commit fc55cbf

Browse files
committed
web: show total notes count in export dialog
Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
1 parent a5f2d39 commit fc55cbf

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

apps/web/src/common/export.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ export async function exportNotes(
9292
const { createZipStream } = await import("../utils/streams/zip-stream");
9393

9494
const errors: Error[] = [];
95-
const exportStream = new ExportStream(report, (e) => errors.push(e));
95+
const exportStream = new ExportStream(
96+
report,
97+
(e) => errors.push(e),
98+
await notes.count()
99+
);
96100
await fromAsyncIterator(
97101
_exportNotes(notes, { format, unlockVault: Vault.unlockVault })
98102
)

apps/web/src/utils/streams/export-stream.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@ export class ExportStream extends TransformStream<
2828
> {
2929
progress = 0;
3030
constructor(
31-
report: (progress: { text: string; current?: number }) => void,
32-
handleError: (error: Error) => void
31+
report: (progress: {
32+
text: string;
33+
current?: number;
34+
total?: number;
35+
}) => void,
36+
handleError: (error: Error) => void,
37+
totalItems?: number
3338
) {
3439
super({
3540
transform: async (item, controller) => {
@@ -69,7 +74,8 @@ export class ExportStream extends TransformStream<
6974
controller.enqueue(item);
7075
report({
7176
current: this.progress++,
72-
text: `Exporting note: ${item.path}`
77+
text: `Exporting note: ${item.path}`,
78+
total: totalItems
7379
});
7480
}
7581
}

0 commit comments

Comments
 (0)