feat(pwa):

This commit is contained in:
Julien Oculi 2024-07-17 13:51:06 +02:00
parent 00c40f2569
commit c21d21015f

View file

@ -69,6 +69,7 @@ if (IS_SW) {
})
self.addEventListener('push', (event) => {
console.log('push')
const { title, options } = (event.data?.json() ?? {}) as {
title?: string
options?: Partial<NotificationOptions>
@ -140,9 +141,14 @@ async function fetchHandler(event: FetchEvent) {
async function updateCache() {
const serverVersion = await getServerCacheVersion()
const clientVersion = await swStorage.getItem<string>('$sw.cache.version')
if (clientVersion === null) return
if (serverVersion === undefined) return
if (clientVersion === serverVersion) return
openCache()
// Open new pre-cache
await openCache()
// Delete old pre-cache
caches.delete(clientVersion)
}
async function getServerCacheVersion() {