fix(store): banner on a refused archive write, rescue download kept alive

This commit is contained in:
bchanot committed 2026-10-14 23:18:33 +02:00
1 parent a37c50b9ee
commit c97b0e7c67
4 files changed
+29 -8

No files matched your search

@@ -18,12 +18,19 @@ export interface HeldSessionPanelProps {
type Pending = { action: 'discard'; text: SessionText } | { action: 'open' }
const REVOKE_DELAY_MS = 30_000
const FILE_STEM: Record<SessionText, string> = {
draft: 'faunosteo-brouillon',
archive: 'faunosteo-archive',
}
/** Saves the stored text verbatim (it is JSON.stringify output: ASCII escapes, lossless). */
/**
* Saves the stored text verbatim. It is JSON.stringify output, whose lone surrogates are
* `\uXXXX` escapes, so the UTF-8 Blob is lossless. This copy may be the last one before
* a deletion: the anchor is attached while clicked and the URL revoked later, since some
* engines (WebKit) cancel a download whose URL is revoked at once.
*/
function downloadCopy(text: SessionText): void {
const raw = readSessionText(text)
if (raw === null) return
@@ -31,8 +38,10 @@ function downloadCopy(text: SessionText): void {
const a = document.createElement('a')
a.href = url
a.download = `${FILE_STEM[text]}-${todayIso()}.json`
document.body.appendChild(a)
a.click()
URL.revokeObjectURL(url)
a.remove()
setTimeout(() => URL.revokeObjectURL(url), REVOKE_DELAY_MS)
}
function rowLabelKey(item: HeldText): string {