mirror of
https://github.com/langgenius/dify.git
synced 2026-02-27 04:57:08 +08:00
refactor: use Promise.all for service worker unregistration
Co-authored-by: hyoban <38493346+hyoban@users.noreply.github.com>
This commit is contained in:
@ -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)
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user