mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-11-18 03:26:17 +00:00
Update AppImage
This commit is contained in:
@@ -3,6 +3,7 @@ import type { Metadata } from "next"
|
|||||||
import { GeistSans } from "geist/font/sans"
|
import { GeistSans } from "geist/font/sans"
|
||||||
import { GeistMono } from "geist/font/mono"
|
import { GeistMono } from "geist/font/mono"
|
||||||
import { ThemeProvider } from "../components/theme-provider"
|
import { ThemeProvider } from "../components/theme-provider"
|
||||||
|
import { PollingConfigProvider } from "../lib/polling-config"
|
||||||
import { Suspense } from "react"
|
import { Suspense } from "react"
|
||||||
import "./globals.css"
|
import "./globals.css"
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ export default function RootLayout({
|
|||||||
<body className={`${GeistSans.variable} ${GeistMono.variable} antialiased bg-background text-foreground`}>
|
<body className={`${GeistSans.variable} ${GeistMono.variable} antialiased bg-background text-foreground`}>
|
||||||
<Suspense fallback={<div>Loading...</div>}>
|
<Suspense fallback={<div>Loading...</div>}>
|
||||||
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem disableTransitionOnChange>
|
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem disableTransitionOnChange>
|
||||||
{children}
|
<PollingConfigProvider>{children}</PollingConfigProvider>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ export function PollingConfigProvider({ children }: { children: ReactNode }) {
|
|||||||
|
|
||||||
// Load from localStorage on mount
|
// Load from localStorage on mount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (typeof window === "undefined") return
|
||||||
|
|
||||||
const stored = localStorage.getItem(STORAGE_KEY)
|
const stored = localStorage.getItem(STORAGE_KEY)
|
||||||
if (stored) {
|
if (stored) {
|
||||||
try {
|
try {
|
||||||
@@ -45,7 +47,9 @@ export function PollingConfigProvider({ children }: { children: ReactNode }) {
|
|||||||
const updateInterval = (key: keyof PollingIntervals, value: number) => {
|
const updateInterval = (key: keyof PollingIntervals, value: number) => {
|
||||||
setIntervals((prev) => {
|
setIntervals((prev) => {
|
||||||
const newIntervals = { ...prev, [key]: value }
|
const newIntervals = { ...prev, [key]: value }
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(newIntervals))
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(newIntervals))
|
||||||
|
}
|
||||||
return newIntervals
|
return newIntervals
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -56,6 +60,13 @@ export function PollingConfigProvider({ children }: { children: ReactNode }) {
|
|||||||
export function usePollingConfig() {
|
export function usePollingConfig() {
|
||||||
const context = useContext(PollingConfigContext)
|
const context = useContext(PollingConfigContext)
|
||||||
if (!context) {
|
if (!context) {
|
||||||
|
// During SSR or when provider is not available, return defaults
|
||||||
|
if (typeof window === "undefined") {
|
||||||
|
return {
|
||||||
|
intervals: DEFAULT_INTERVALS,
|
||||||
|
updateInterval: () => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
throw new Error("usePollingConfig must be used within PollingConfigProvider")
|
throw new Error("usePollingConfig must be used within PollingConfigProvider")
|
||||||
}
|
}
|
||||||
return context
|
return context
|
||||||
|
|||||||
Reference in New Issue
Block a user