mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-29 00:20:04 +01:00
web: use simple transform stream for export progress
This commit is contained in:
@@ -86,13 +86,24 @@ export async function exportNotes(
|
||||
title: "Exporting notes",
|
||||
subtitle: "Please wait while your notes are exported.",
|
||||
action: async (report) => {
|
||||
const total = await notes.count();
|
||||
let progress = 0;
|
||||
|
||||
const noteStream = fromAsyncIterator(notes[Symbol.asyncIterator]());
|
||||
await noteStream
|
||||
.pipeThrough(
|
||||
new ExportStream(format, undefined, (c, text) =>
|
||||
report({ current: c, text })
|
||||
)
|
||||
new TransformStream<Note, Note>({
|
||||
transform(note, controller) {
|
||||
controller.enqueue(note);
|
||||
report({
|
||||
total,
|
||||
current: progress++,
|
||||
text: `Exporting "${note?.title}"`
|
||||
});
|
||||
}
|
||||
})
|
||||
)
|
||||
.pipeThrough(new ExportStream(format, undefined))
|
||||
.pipeThrough(createZipStream())
|
||||
.pipeTo(await createWriteStream("notes.zip"));
|
||||
return true;
|
||||
|
||||
@@ -37,9 +37,9 @@ export class ExportStream extends TransformStream<Note, ZipFile> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!note || format === "pdf") return;
|
||||
if (format === "pdf") return;
|
||||
|
||||
const result = await exportNote(note, format);
|
||||
const result = await exportNote(note, { format });
|
||||
if (!result) return;
|
||||
|
||||
const { filename, content } = result;
|
||||
|
||||
Reference in New Issue
Block a user