Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix: avoid the entire app layout re render on route change

Louis5f6a68d844a7
diff --git a/web-app/src/routes/__root.tsx b/web-app/src/routes/__root.tsx
index ca287872b..cfa05df16 100644
--- a/web-app/src/routes/__root.tsx
+++ b/web-app/src/routes/__root.tsx
@@ -192,17 +192,16 @@ const LogsLayout = () => {
}
function RootLayout() {
- const pathname = useRouterState({
- select: (state) => state.location.pathname,
- })
- const isLocalAPIServerLogsRoute = useMemo(
- () =>
+ const getInitialLayoutType = () => {
+ const pathname = window.location.pathname
+ return (
pathname === route.localApiServerlogs ||
pathname === route.systemMonitor ||
- pathname === route.appLogs,
- [pathname]
- )
+ pathname === route.appLogs
+ )
+ }
+ const IS_LOGS_ROUTE = getInitialLayoutType()
return (
<Fragment>
<ServiceHubProvider>
@@ -214,7 +213,7 @@ function RootLayout() {
<AuthProvider>
<DataProvider />
<GlobalEventHandler />
- {isLocalAPIServerLogsRoute ? <LogsLayout /> : <AppLayout />}
+ {IS_LOGS_ROUTE ? <LogsLayout /> : <AppLayout />}
</AuthProvider>
</ExtensionProvider>
{/* {isLocalAPIServerLogsRoute ? <LogsLayout /> : <AppLayout />} */}