diff options
author | Matt Strapp <matt@mattstrapp.net> | 2023-09-29 10:11:33 -0500 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2023-09-29 10:11:33 -0500 |
commit | 11ece69e006b446b9ca4e06eb5af5662bc811469 (patch) | |
tree | 29dbb0b4b88aa9eae29d80f5ebc08b8f710f51f8 /app/src/lib/ts/download.ts | |
parent | Update dep + fix build (diff) | |
download | trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.tar trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.tar.gz trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.tar.bz2 trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.tar.lz trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.tar.xz trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.tar.zst trinkets-11ece69e006b446b9ca4e06eb5af5662bc811469.zip |
Formatting
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to '')
-rw-r--r-- | app/src/lib/ts/download.ts | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/app/src/lib/ts/download.ts b/app/src/lib/ts/download.ts index c3e98b0..48debec 100644 --- a/app/src/lib/ts/download.ts +++ b/app/src/lib/ts/download.ts @@ -5,33 +5,33 @@ export default async function saveFile(blob: ArrayBuffer, suggestedName: string 'showSaveFilePicker' in window && (() => { try { - return window.self === window.top; + return window.self === window.top } catch { - return false; + return false } - })(); + })() if (supportsFSAccess) { try { const handle = await window.showSaveFilePicker({ - suggestedName: suggestedName - }); - const writable = await handle.createWritable(); - await writable.write(blob); - await writable.close(); - return; + suggestedName: suggestedName, + }) + const writable = await handle.createWritable() + await writable.write(blob) + await writable.close() + return } catch (err: unknown) { // TypeScript if ((err as Error)?.name !== 'AbortError') { - return Promise.reject(err); + return Promise.reject(err) } } } else { - const anchor = document.createElement('a'); - anchor.download = suggestedName ?? 'truncated'; - anchor.href = URL.createObjectURL(new Blob([blob])); - anchor.click(); - URL.revokeObjectURL(anchor.href); - document.body.removeChild(anchor); + const anchor = document.createElement('a') + anchor.download = suggestedName ?? 'truncated' + anchor.href = URL.createObjectURL(new Blob([blob])) + anchor.click() + URL.revokeObjectURL(anchor.href) + document.body.removeChild(anchor) } } |