From 0fab60b7106a324bf6a6072f76115900e7ea1e17 Mon Sep 17 00:00:00 2001 From: ectasy663 Date: Sun, 20 Sep 2026 12:15:33 +0530 Subject: [PATCH] perf: eliminate demo account switch lag - no more page reload, parallel fetches, settings cache --- src/app/dashboard/layout.tsx | 28 ++++++- src/hooks/useActiveUser.ts | 142 ++++++++++++++++++++++++----------- 2 files changed, 124 insertions(+), 46 deletions(-) diff --git a/src/app/dashboard/layout.tsx b/src/app/dashboard/layout.tsx index 811021f..7bfedd0 100644 --- a/src/app/dashboard/layout.tsx +++ b/src/app/dashboard/layout.tsx @@ -20,7 +20,7 @@ export default function DashboardLayout({ children }: { children: ReactNode }) { const [dropdownOpen, setDropdownOpen] = useState(false) const dropdownRef = useRef(null) - const { userId, user, globalSettings, switchUser, logout, hasAccessTo, loading, trialInfo } = useActiveUser(); + const { userId, user, globalSettings, switchUser, logout, hasAccessTo, loading, switching, trialInfo } = useActiveUser(); const [maintenance, setMaintenance] = useState(false); const [checkingMaintenance, setCheckingMaintenance] = useState(true); @@ -75,6 +75,22 @@ export default function DashboardLayout({ children }: { children: ReactNode }) { return (
+ {/* Demo Account Switch — slim top progress bar, no full-page reload */} + {switching && ( +
+
+ +
+ )} {/* Sidebar */}