diff --git a/index.html b/index.html index d3e0e66..1341657 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,17 @@ Voiced +
diff --git a/src/App.tsx b/src/App.tsx index 6519700..4b158b0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -11,6 +11,7 @@ import Clients from "./views/Clients"; import { ToastProvider, useToast } from "./components/ToastProvider"; import AppSettings from "./views/AppSettings"; import { requestSettingsTab } from "./lib/settingsTab"; +import { applyDocumentTheme, cachedTheme, normalizeTheme } from "./lib/theme"; export default function App() { return ( @@ -46,9 +47,15 @@ function AppInner() { void refreshSettings(); }, [refreshSettings]); + // Before settings load (and on the error screen) use the cached theme so the window never flashes white. + const theme = settings ? normalizeTheme(settings.theme) : cachedTheme(); + useEffect(() => { + applyDocumentTheme(theme); + }, [theme]); + if (loading) { return ( - +
@@ -58,7 +65,7 @@ function AppInner() { if (error) { return ( - +
+ { @@ -106,8 +111,8 @@ function AppInner() { }; return ( - - + + {/* Main views stay mounted so a half-typed invoice survives switching tabs. */} setView("new")} openDraftId={openDraftId} onDraftOpened={() => setOpenDraftId(null)} + theme={theme} + onToggleTheme={toggleTheme} />