mirror of
https://github.com/zoldar/jenot.git
synced 2026-01-03 14:32:54 +00:00
Request permission to use persistent storage by service worker
This commit is contained in:
parent
76b837e4c4
commit
6c635bf97c
1 changed files with 14 additions and 0 deletions
|
|
@ -1,5 +1,19 @@
|
|||
const registerServiceWorker = async () => {
|
||||
if ("serviceWorker" in navigator) {
|
||||
if (navigator.storage && navigator.storage.persist) {
|
||||
navigator.storage.persist().then((persistent) => {
|
||||
if (persistent) {
|
||||
console.log(
|
||||
"Storage will not be cleared except by explicit user action",
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
"Storage may be cleared by the UA under storage pressure.",
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const registration = await navigator.serviceWorker.register(
|
||||
"/js/service-worker.js",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue