Improved content refresh
This commit is contained in:
parent
460d90d957
commit
7cd8a8153e
@ -137,7 +137,7 @@ export class AnimeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async updatePushUI() {
|
async updatePushUI() {
|
||||||
if(!this.pushManager.pushSupported) {
|
if(!this.pushManager.pushSupported || !this.app.currentPath.includes("/settings")) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
const CACHE = "v-1"
|
const CACHE = "v-1"
|
||||||
const RELOADS = new Map<string, Promise<Response>>()
|
const RELOADS = new Map<string, Promise<Response>>()
|
||||||
const ETAGS = new Map<string, string>()
|
const ETAGS = new Map<string, string>()
|
||||||
|
const CACHEREFRESH = new Map<string, Promise<void>>()
|
||||||
|
|
||||||
self.addEventListener("install", (evt: InstallEvent) => {
|
self.addEventListener("install", (evt: InstallEvent) => {
|
||||||
console.log("Service worker install")
|
console.log("Service worker install")
|
||||||
@ -72,7 +73,15 @@ self.addEventListener("message", (evt: any) => {
|
|||||||
url
|
url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cacheRefresh = CACHEREFRESH.get(url)
|
||||||
|
|
||||||
|
if(!cacheRefresh) {
|
||||||
return evt.source.postMessage(JSON.stringify(message))
|
return evt.source.postMessage(JSON.stringify(message))
|
||||||
|
}
|
||||||
|
|
||||||
|
return cacheRefresh.then(() => {
|
||||||
|
evt.source.postMessage(JSON.stringify(message))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -99,10 +108,12 @@ self.addEventListener("fetch", async (evt: FetchEvent) => {
|
|||||||
let clone = response.clone()
|
let clone = response.clone()
|
||||||
|
|
||||||
// Save the new version of the resource in the cache
|
// Save the new version of the resource in the cache
|
||||||
caches.open(CACHE).then(cache => {
|
let cacheRefresh = caches.open(CACHE).then(cache => {
|
||||||
return cache.put(request, clone)
|
return cache.put(request, clone)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
CACHEREFRESH.set(request.url, cacheRefresh)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user