showUpdateOverlay güncellemesi
This commit is contained in:
parent
524a88274b
commit
414006204e
1 changed files with 9 additions and 8 deletions
|
|
@ -73,15 +73,16 @@ export const registerServiceWorker = () => {
|
||||||
// skipWaiting: true (workbox config) → controllerchange → autoUpdate reload.
|
// skipWaiting: true (workbox config) → controllerchange → autoUpdate reload.
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.ready.then((registration) => {
|
navigator.serviceWorker.ready.then((registration) => {
|
||||||
|
// ready'den önce updatefound zaten tetiklendiyse (race condition)
|
||||||
|
if (registration.installing && navigator.serviceWorker.controller) {
|
||||||
|
showUpdateOverlay()
|
||||||
|
}
|
||||||
|
|
||||||
registration.addEventListener('updatefound', () => {
|
registration.addEventListener('updatefound', () => {
|
||||||
const newWorker = registration.installing
|
// Güncelleme başlar başlamaz overlay'i göster
|
||||||
if (!newWorker) return
|
if (navigator.serviceWorker.controller) {
|
||||||
newWorker.addEventListener('statechange', () => {
|
showUpdateOverlay()
|
||||||
// Yeni SW kuruldu, aktivasyon aşamasına geçiyor
|
}
|
||||||
if (newWorker.state === 'installed' && navigator.serviceWorker.controller) {
|
|
||||||
showUpdateOverlay()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue