A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: do not show save file dialog if download is canceled
Abdullah Attab3b1b7470ee2
diff --git a/apps/web/src/stores/attachment-store.js b/apps/web/src/stores/attachment-store.jsindex fe41ba090..ef123f899 100644--- a/apps/web/src/stores/attachment-store.js+++ b/apps/web/src/stores/attachment-store.js@@ -67,7 +67,9 @@ class AttachmentStore extends BaseStore {);await attachmentStream.pipeThrough(new ZipStream())- .pipeTo(createWriteStream("attachments.zip"));+ .pipeTo(+ createWriteStream("attachments.zip", { signal: abortController.signal })+ );this.set((state) => (state.status = undefined));};diff --git a/apps/web/src/utils/stream-saver/index.ts b/apps/web/src/utils/stream-saver/index.tsindex 259bfe532..67cf3219c 100644--- a/apps/web/src/utils/stream-saver/index.ts+++ b/apps/web/src/utils/stream-saver/index.ts@@ -38,6 +38,7 @@ function makeIframe(src: string, doc = true) {if (doc) iframe.srcdoc = src;else iframe.src = src;document.body.appendChild(iframe);+ return iframe;}try {@@ -72,12 +73,14 @@ export function createWriteStream(opts: {size?: number;pathname?: string;+ signal?: AbortSignal;} = {}): WritableStream<Uint8Array> {// let bytesWritten = 0; // by StreamSaver.js (not the service worker)let downloadUrl: string | null = null;let channel: MessageChannel | null = null;- let ts = null;+ let ts: TransformStream | null = null;+ let frame: HTMLIFrameElement | null = null;if (!useBlobFallback) {channel = new MessageChannel();@@ -106,14 +109,18 @@ export function createWriteStream(if (supportsTransferable) {ts = new TransformStream();const readableStream = ts.readable;-+ if (opts.signal) {+ opts.signal.addEventListener("abort", () => frame?.remove(), {+ once: true+ });+ }channel.port1.postMessage({ readableStream }, [readableStream]);}channel.port1.onmessage = async (evt) => {// Service worker sent us a link that we should open.if (evt.data.download) {// We never remove this iframes because it can interrupt saving- makeIframe(evt.data.download, false);+ frame = makeIframe(evt.data.download, false);} else if (evt.data.abort) {chunks = [];if (channel) {