feat: Refactor service worker registration and enhance offline download manager with client-side checks

This commit is contained in:
2025-08-11 12:31:08 +00:00
committed by GitHub
parent 452af2f6f0
commit 8b5dbbe854
4 changed files with 116 additions and 13 deletions

View File

@@ -15,16 +15,18 @@ import { LoginForm } from "./start-screen";
import Image from "next/image";
import PageTransition from "./PageTransition";
// Service Worker registration
if (typeof window !== 'undefined' && 'serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js')
.then((registration) => {
console.log('Service Worker registered successfully:', registration);
})
.catch((error) => {
console.error('Service Worker registration failed:', error);
});
}
// Service Worker registration - moved to useEffect to ensure it only runs client-side
React.useEffect(() => {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js')
.then((registration) => {
console.log('Service Worker registered successfully:', registration);
})
.catch((error) => {
console.error('Service Worker registration failed:', error);
});
}
}, []);
function NavidromeErrorBoundary({ children }: { children: React.ReactNode }) {
// For now, since we're switching to offline-first, we'll handle errors differently