Stabilize root app shell renders
Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
1 parent
d1e85c4e8f
commit
4b87dbf7d7
1 file changed
+22
-18
@@ -99,19 +99,20 @@ export const Route = createRootRouteWithContext<{
|
||||
}),
|
||||
});
|
||||
|
||||
const APP_SHELL = (
|
||||
<CommandPalette>
|
||||
<AppSidebarLayout>
|
||||
<Outlet />
|
||||
</AppSidebarLayout>
|
||||
</CommandPalette>
|
||||
);
|
||||
|
||||
function RootRouteView() {
|
||||
const pathname = useLocation({ select: (location) => location.pathname });
|
||||
const { authGateState } = Route.useRouteContext();
|
||||
const primaryEnvironmentAuthenticated = authGateState.status === "authenticated";
|
||||
|
||||
useEffect(() => {
|
||||
const frame = window.requestAnimationFrame(() => {
|
||||
syncBrowserChromeTheme();
|
||||
});
|
||||
return () => {
|
||||
window.cancelAnimationFrame(frame);
|
||||
};
|
||||
}, [pathname]);
|
||||
useBrowserChromeThemeSync(pathname);
|
||||
|
||||
if (pathname === "/pair") {
|
||||
return <Outlet />;
|
||||
@@ -121,14 +122,6 @@ function RootRouteView() {
|
||||
return <Outlet />;
|
||||
}
|
||||
|
||||
const appShell = (
|
||||
<CommandPalette>
|
||||
<AppSidebarLayout>
|
||||
<Outlet />
|
||||
</AppSidebarLayout>
|
||||
</CommandPalette>
|
||||
);
|
||||
|
||||
return (
|
||||
<ToastProvider>
|
||||
<AnchoredToastProvider>
|
||||
@@ -142,15 +135,26 @@ function RootRouteView() {
|
||||
{primaryEnvironmentAuthenticated ? <WebSocketConnectionCoordinator /> : null}
|
||||
{primaryEnvironmentAuthenticated ? <SlowRpcAckToastCoordinator /> : null}
|
||||
{primaryEnvironmentAuthenticated ? (
|
||||
<WebSocketConnectionSurface>{appShell}</WebSocketConnectionSurface>
|
||||
<WebSocketConnectionSurface>{APP_SHELL}</WebSocketConnectionSurface>
|
||||
) : (
|
||||
appShell
|
||||
APP_SHELL
|
||||
)}
|
||||
</AnchoredToastProvider>
|
||||
</ToastProvider>
|
||||
);
|
||||
}
|
||||
|
||||
function useBrowserChromeThemeSync(pathname: string) {
|
||||
useEffect(() => {
|
||||
const frame = window.requestAnimationFrame(() => {
|
||||
syncBrowserChromeTheme();
|
||||
});
|
||||
return () => {
|
||||
window.cancelAnimationFrame(frame);
|
||||
};
|
||||
}, [pathname]);
|
||||
}
|
||||
|
||||
function HostedStaticEnvironmentBootstrap() {
|
||||
const savedEnvironmentCount = useSavedEnvironmentRegistryStore(
|
||||
(state) => Object.keys(state.byId).length,
|
||||
|
||||
Reference in new issue
Block a user