diff --git a/src/components/App.tsx b/src/components/App.tsx index bf9d935..7f623c5 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -11,9 +11,6 @@ import { ReactLocation, Router, } from "@tanstack/react-location"; -import { ChatRoute } from "../routes/ChatRoute"; -import { PublicChatRoute } from "../routes/PublicChatRoute"; -import { IndexRoute } from "../routes/IndexRoute"; import { BaseLayout } from "../layouts/Base"; import { PublicLayout } from "../layouts/Public"; @@ -38,9 +35,9 @@ export function App() { }, - { id: "chat", path: "/chats/:chatId", element: }, - { id: "public_chat", path: "/shared/chats/:chatId", element: }, + { id: "root", path: "/", element: () => import('../routes/IndexRoute').then((mod) => )}, + { id: "chat", path: "/chats/:chatId", element: () => import('../routes/ChatRoute').then((mod) => ) }, + { id: "public_chat", path: "/shared/chats/:chatId", element: () => import('../routes/PublicChatRoute').then((mod) => ) }, ]} > import('../components/Prompts')); export function BaseLayout({ children }: { children: React.ReactNode }) { const theme = useMantineTheme(); @@ -105,12 +109,15 @@ export function BaseLayout({ children }: { children: React.ReactNode }) { } }, [chatId]); + const [fetchingChats, setFetchingChats] = useState(false); const [chats, setChats] = useState([]); useEffect(() => { const dataFetch = async () => { + setFetchingChats(true); const { items } = await detaDB.chats.fetch(incognitoMode ? { private: true } : { 'private?ne': true }); setChats(items as unknown as Chat[]); + setFetchingChats(false); }; dataFetch(); @@ -270,9 +277,23 @@ export function BaseLayout({ children }: { children: React.ReactNode }) { /> - {tab === "Chats" && } + {tab === "Chats" && (fetchingChats ? ( + + + + + + ) : ())} {tab === "Prompts" && ( - setTab("Chats")} /> + + + + + + }> + setTab("Chats")} /> + )}