fix: refresh server components after nav style change to fix broken layout

This commit is contained in:
ginnoir
2026-06-01 17:53:21 -05:00
parent 19308be768
commit b255aaeac1
+6 -2
View File
@@ -1,6 +1,7 @@
"use client";
import { useCallback, useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import type {
Palette,
ThemeMode,
@@ -67,6 +68,7 @@ export function useTheme(
const [dashLayout, setDashLayoutState] = useState<DashLayout>(initial.dashLayout ?? "classic");
const [calView, setCalViewState] = useState<CalView>(initial.calView ?? "month");
const [navStyle, setNavStyleState] = useState<NavStyle>(initial.navStyle ?? "rail-desktop");
const router = useRouter();
// Re-apply data-nav whenever the viewport crosses the mobile breakpoint.
useEffect(() => {
@@ -158,9 +160,11 @@ export function useTheme(
(next: NavStyle) => {
setNavStyleState(next);
applyTheme({ palette, mode, fontPair, density, navStyle: next });
persist({ navStyle: next });
if (signedIn) {
void setUserTheme({ navStyle: next }).then(() => router.refresh());
}
},
[palette, mode, fontPair, density, persist],
[palette, mode, fontPair, density, signedIn, router],
);
return {