mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +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:
parent
57df92aba7
commit
b5a7e7aede
@ -7,15 +7,17 @@ import { IS_DEV } from '@/config'
|
|||||||
export function PWAProvider({ children }: { children: React.ReactNode }) {
|
export function PWAProvider({ children }: { children: React.ReactNode }) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (IS_DEV && 'serviceWorker' in navigator) {
|
if (IS_DEV && 'serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.getRegistrations().then((registrations) => {
|
navigator.serviceWorker.getRegistrations()
|
||||||
registrations.forEach((registration) => {
|
.then((registrations) => {
|
||||||
registration.unregister()
|
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
Block a user