mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-18 08:02:03 +03:00
3ed0ea15bb
Issue: https://github.com/StanGirard/quivr/issues/1866 - Use context to control sidebar open status - Control sidebar through chat bar - Persist sidebar status after page change Demo: https://github.com/StanGirard/quivr/assets/63923024/b9750198-e68d-47a7-b266-627a01586512
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
"use client";
|
|
|
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
import { PropsWithChildren, useEffect } from "react";
|
|
|
|
import { BrainProvider } from "@/lib/context";
|
|
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
|
|
import { SideBarProvider } from "@/lib/context/SidebarProvider/sidebar-provider";
|
|
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
|
import { UpdateMetadata } from "@/lib/helpers/updateMetadata";
|
|
import { usePageTracking } from "@/services/analytics/june/usePageTracking";
|
|
import "../lib/config/LocaleConfig/i18n";
|
|
|
|
// This wrapper is used to make effect calls at a high level in app rendering.
|
|
const App = ({ children }: PropsWithChildren): JSX.Element => {
|
|
const { fetchAllBrains, fetchDefaultBrain, fetchPublicPrompts } =
|
|
useBrainContext();
|
|
const { session } = useSupabase();
|
|
|
|
usePageTracking();
|
|
|
|
useEffect(() => {
|
|
if (session?.user) {
|
|
void fetchAllBrains();
|
|
void fetchDefaultBrain();
|
|
void fetchPublicPrompts();
|
|
}
|
|
}, [session]);
|
|
|
|
return (
|
|
<>
|
|
{children}
|
|
<UpdateMetadata />
|
|
</>
|
|
);
|
|
};
|
|
|
|
const queryClient = new QueryClient();
|
|
|
|
const AppWithQueryClient = ({ children }: PropsWithChildren): JSX.Element => {
|
|
return (
|
|
<QueryClientProvider client={queryClient}>
|
|
<BrainProvider>
|
|
<SideBarProvider>
|
|
<App>{children}</App>
|
|
</SideBarProvider>
|
|
</BrainProvider>
|
|
</QueryClientProvider>
|
|
);
|
|
};
|
|
|
|
export { AppWithQueryClient as App };
|