Request persistent storage (#701)
* Request persistent storage * Only prompt for persistent storage if push notifications enabled --------- Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
parent
9f7f09378d
commit
056be01f15
|
@ -99,7 +99,15 @@ export const ServiceWorkerProvider = ({ children }) => {
|
||||||
if (pushSubscription) {
|
if (pushSubscription) {
|
||||||
return unsubscribeFromPushNotifications(pushSubscription)
|
return unsubscribeFromPushNotifications(pushSubscription)
|
||||||
}
|
}
|
||||||
return subscribeToPushNotifications()
|
return subscribeToPushNotifications().then(async () => {
|
||||||
|
// request persistent storage: https://web.dev/learn/pwa/offline-data#data_persistence
|
||||||
|
const persisted = await navigator?.storage?.persisted?.()
|
||||||
|
if (!persisted && navigator?.storage?.persist) {
|
||||||
|
return navigator.storage.persist().then(persistent => {
|
||||||
|
logger.info('persistent storage:', persistent)
|
||||||
|
}).catch(logger.error)
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
Loading…
Reference in New Issue