mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 13:31:03 +08:00
Unregister old service workers when Discourse.ServiceWorkerURL
changes.
This commit is contained in:
parent
b5d29f7d88
commit
af5cd7e548
|
@ -11,6 +11,19 @@ export default {
|
|||
|
||||
if (isSupported) {
|
||||
if (Discourse.ServiceWorkerURL && !isSafari) {
|
||||
navigator.serviceWorker.getRegistrations().then(registrations => {
|
||||
for (let registration of registrations) {
|
||||
if (
|
||||
registration.active &&
|
||||
!registration.active.scriptURL.includes(
|
||||
Discourse.ServiceWorkerURL
|
||||
)
|
||||
) {
|
||||
registration.unregister();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
navigator.serviceWorker
|
||||
.register(`${Discourse.BaseUri}/${Discourse.ServiceWorkerURL}`)
|
||||
.catch(error => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user