|
|
@ -19,18 +19,28 @@ customElements.define( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
class Setup { |
|
|
class Setup { |
|
|
async run() { |
|
|
async runWithSw() { |
|
|
const sw = navigator.serviceWorker |
|
|
navigator.serviceWorker.addEventListener( |
|
|
|
|
|
'controllerchange', |
|
|
sw.addEventListener('controllerchange', () => { |
|
|
() => { |
|
|
if (this.registration.active) { |
|
|
if (this.registration.active) { |
|
|
window.location.reload(true) |
|
|
window.location.reload(true) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
) |
|
|
await this.register() |
|
|
await this.register() |
|
|
this.load() |
|
|
this.load() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async runWithoutSw() { |
|
|
|
|
|
const layout = document.createElement( |
|
|
|
|
|
'm-layout' |
|
|
|
|
|
) |
|
|
|
|
|
layout.csp = undefined |
|
|
|
|
|
layout.header.menu.handleLinks = true |
|
|
|
|
|
document.body.appendChild(layout) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
async register() { |
|
|
async register() { |
|
|
try { |
|
|
try { |
|
|
this.registration = |
|
|
this.registration = |
|
|
@ -54,4 +64,4 @@ class Setup { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
new Setup().run() |
|
|
new Setup().runWithSw() |