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.
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.ready.then((registration) => {
|
||||
registration.addEventListener('updatefound', () => {
|
||||
const newWorker = registration.installing
|
||||
if (!newWorker) return
|
||||
newWorker.addEventListener('statechange', () => {
|
||||
// Yeni SW kuruldu, aktivasyon aşamasına geçiyor
|
||||
if (newWorker.state === 'installed' && navigator.serviceWorker.controller) {
|
||||
// ready'den önce updatefound zaten tetiklendiyse (race condition)
|
||||
if (registration.installing && navigator.serviceWorker.controller) {
|
||||
showUpdateOverlay()
|
||||
}
|
||||
|
||||
registration.addEventListener('updatefound', () => {
|
||||
// Güncelleme başlar başlamaz overlay'i göster
|
||||
if (navigator.serviceWorker.controller) {
|
||||
showUpdateOverlay()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue