mirror of
https://github.com/zoldar/jenot.git
synced 2026-01-05 07:02:55 +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 () => {
|
const registerServiceWorker = async () => {
|
||||||
if ("serviceWorker" in navigator) {
|
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 {
|
try {
|
||||||
const registration = await navigator.serviceWorker.register(
|
const registration = await navigator.serviceWorker.register(
|
||||||
"/js/service-worker.js",
|
"/js/service-worker.js",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue