From 5ba1a7bdad841058be3b83aaa0a65906a9684a2f Mon Sep 17 00:00:00 2001 From: marwin Date: Fri, 29 May 2026 23:54:54 +0200 Subject: [PATCH] Books: request persistent storage when first caching a book MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- static/js/app.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/static/js/app.js b/static/js/app.js index f0a0c31..5068fff 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -2731,6 +2731,10 @@ async function _setCachedBook(bookId, data_ct, data_iv) { tx.oncomplete = 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 {} }