refactor: use Promise.all for service worker unregistration
Co-authored-by: hyoban <38493346+hyoban@users.noreply.github.com>
This commit is contained in:
parent
57df92aba7
commit
b5a7e7aede
|
|
@ -7,15 +7,17 @@ import { IS_DEV } from '@/config'
|
|||
export function PWAProvider({ children }: { children: React.ReactNode }) {
|
||||
useEffect(() => {
|
||||
if (IS_DEV && 'serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.getRegistrations().then((registrations) => {
|
||||
registrations.forEach((registration) => {
|
||||
registration.unregister()
|
||||
navigator.serviceWorker.getRegistrations()
|
||||
.then((registrations) => {
|
||||
return Promise.all(
|
||||
registrations.map(registration => registration.unregister()),
|
||||
)
|
||||
})
|
||||
.catch((error) => {
|
||||
// Silently fail if service worker unregistration fails
|
||||
// This is a development-only optimization and shouldn't block the app
|
||||
console.warn('Failed to unregister service workers:', error)
|
||||
})
|
||||
}).catch((error) => {
|
||||
// Silently fail if service worker unregistration fails
|
||||
// This is a development-only optimization and shouldn't block the app
|
||||
console.warn('Failed to unregister service workers:', error)
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue