feat: enhance service worker functionality with improved caching strategies, client communication, and service worker registration options
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 3m42s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 3m42s
This commit is contained in:
@@ -7,9 +7,9 @@ import { Sidebar } from "@/components/layout/Sidebar";
|
||||
import { InstallPWA } from "../ui/InstallPWA";
|
||||
import { Toaster } from "@/components/ui/toaster";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { registerServiceWorker } from "@/lib/registerSW";
|
||||
import { NetworkStatus } from "../ui/NetworkStatus";
|
||||
import { usePreferences } from "@/contexts/PreferencesContext";
|
||||
import { ServiceWorkerProvider } from "@/contexts/ServiceWorkerContext";
|
||||
import type { KomgaLibrary, KomgaSeries } from "@/types/komga";
|
||||
import logger from "@/lib/logger";
|
||||
|
||||
@@ -135,10 +135,6 @@ export default function ClientLayout({
|
||||
};
|
||||
}, [isSidebarOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
// Enregistrer le service worker
|
||||
registerServiceWorker();
|
||||
}, []);
|
||||
|
||||
// Ne pas afficher le header et la sidebar sur les routes publiques et le reader
|
||||
const isPublicRoute = publicRoutes.includes(pathname) || pathname.startsWith("/books/");
|
||||
@@ -151,37 +147,39 @@ export default function ClientLayout({
|
||||
|
||||
return (
|
||||
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
|
||||
{/* Background fixe pour les images et gradients */}
|
||||
{hasCustomBackground && <div className="fixed inset-0 -z-10" style={backgroundStyle} />}
|
||||
<div
|
||||
className={`relative min-h-screen ${hasCustomBackground ? "" : "bg-background"}`}
|
||||
style={
|
||||
hasCustomBackground
|
||||
? { backgroundColor: `rgba(var(--background-rgb, 255, 255, 255), ${contentOpacity})` }
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{!isPublicRoute && (
|
||||
<Header
|
||||
onToggleSidebar={handleToggleSidebar}
|
||||
onRefreshBackground={fetchRandomBook}
|
||||
showRefreshBackground={preferences.background.type === "komga-random"}
|
||||
/>
|
||||
)}
|
||||
{!isPublicRoute && (
|
||||
<Sidebar
|
||||
isOpen={isSidebarOpen}
|
||||
onClose={handleCloseSidebar}
|
||||
initialLibraries={initialLibraries}
|
||||
initialFavorites={initialFavorites}
|
||||
userIsAdmin={userIsAdmin}
|
||||
/>
|
||||
)}
|
||||
<main className={!isPublicRoute ? "pt-safe" : ""}>{children}</main>
|
||||
<InstallPWA />
|
||||
<Toaster />
|
||||
<NetworkStatus />
|
||||
</div>
|
||||
<ServiceWorkerProvider>
|
||||
{/* Background fixe pour les images et gradients */}
|
||||
{hasCustomBackground && <div className="fixed inset-0 -z-10" style={backgroundStyle} />}
|
||||
<div
|
||||
className={`relative min-h-screen ${hasCustomBackground ? "" : "bg-background"}`}
|
||||
style={
|
||||
hasCustomBackground
|
||||
? { backgroundColor: `rgba(var(--background-rgb, 255, 255, 255), ${contentOpacity})` }
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{!isPublicRoute && (
|
||||
<Header
|
||||
onToggleSidebar={handleToggleSidebar}
|
||||
onRefreshBackground={fetchRandomBook}
|
||||
showRefreshBackground={preferences.background.type === "komga-random"}
|
||||
/>
|
||||
)}
|
||||
{!isPublicRoute && (
|
||||
<Sidebar
|
||||
isOpen={isSidebarOpen}
|
||||
onClose={handleCloseSidebar}
|
||||
initialLibraries={initialLibraries}
|
||||
initialFavorites={initialFavorites}
|
||||
userIsAdmin={userIsAdmin}
|
||||
/>
|
||||
)}
|
||||
<main className={!isPublicRoute ? "pt-safe" : ""}>{children}</main>
|
||||
<InstallPWA />
|
||||
<Toaster />
|
||||
<NetworkStatus />
|
||||
</div>
|
||||
</ServiceWorkerProvider>
|
||||
</ThemeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user