import "./index.css" // import { Suspense, lazy, useEffect, StrictMode } from "react" import { Suspense, lazy, memo, useEffect } from "react" import ReactDOM from "react-dom/client" import { ThemeProvider } from "./components/theme-provider.tsx" import { DirectionProvider } from "@radix-ui/react-direction" import { $authenticated, $publicKey, $copyContent, $direction } from "./lib/stores.ts" import { pb, updateUserSettings } from "./lib/api.ts" import * as systemsManager from "./lib/systemsManager.ts" import { useStore } from "@nanostores/react" import { Toaster } from "./components/ui/toaster.tsx" import { $router } from "./components/router.tsx" import Navbar from "./components/navbar.tsx" import { I18nProvider } from "@lingui/react" import { i18n } from "@lingui/core" import { getLocale, dynamicActivate } from "./lib/i18n" import { alertManager } from "./lib/alerts" import Settings from "./components/routes/settings/layout.tsx" const LoginPage = lazy(() => import("@/components/login/login.tsx")) const Home = lazy(() => import("@/components/routes/home.tsx")) const SystemDetail = lazy(() => import("@/components/routes/system.tsx")) const CopyToClipboardDialog = lazy(() => import("@/components/copy-to-clipboard.tsx")) const App = memo(() => { const page = useStore($router) useEffect(() => { // change auth store on auth change pb.authStore.onChange(() => { $authenticated.set(pb.authStore.isValid) }) // get version / public key pb.send("/api/beszel/getkey", {}).then((data) => { $publicKey.set(data.key) }) // get user settings updateUserSettings() // need to get system list before alerts systemsManager.init() systemsManager // get current systems list .refresh() // subscribe to new system updates .then(systemsManager.subscribe) // get current alerts .then(alertManager.refresh) // subscribe to new alert updates .then(alertManager.subscribe) return () => { // updateFavicon("favicon.svg") alertManager.unsubscribe() systemsManager.unsubscribe() } }, []) if (!page) { return