Books: request persistent storage when first caching a book
Ohne navigator.storage.persist() ist der IndexedDB-Speicher "best-effort" und kann vom Browser bei Speicherknappheit still gelöscht werden. Der Aufruf erfolgt beim ersten Schreiben eines Buches in den Cache — Chrome gewährt das für installierte PWAs automatisch, Firefox kann einen Dialog zeigen. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3d25519367
commit
5ba1a7bdad
1 changed files with 4 additions and 0 deletions
|
|
@ -2731,6 +2731,10 @@ async function _setCachedBook(bookId, data_ct, data_iv) {
|
||||||
tx.oncomplete = resolve;
|
tx.oncomplete = resolve;
|
||||||
tx.onerror = resolve;
|
tx.onerror = resolve;
|
||||||
});
|
});
|
||||||
|
// Request persistent storage so the browser doesn't evict cached books
|
||||||
|
// under storage pressure. Chrome grants this silently for installed PWAs;
|
||||||
|
// Firefox may show a permission prompt.
|
||||||
|
if (navigator.storage?.persist) navigator.storage.persist();
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue