From bea275f2ff35c2ac0731b246aea676916a0d4da8 Mon Sep 17 00:00:00 2001 From: Mamadou DICKO <63923024+mamadoudicko@users.noreply.github.com> Date: Fri, 1 Sep 2023 15:14:35 +0200 Subject: [PATCH 01/18] feat: add tanstack query and optimistic fetch on brains settings page (#1087) * refactor: remove * feat: add tanstack query * feat: add optimistic fetch to brain settings page --- frontend/app/App.tsx | 12 +++++--- .../SettingsTab/hooks/useSettingsTab.ts | 29 ++++++++++++------- frontend/lib/api/brain/config.ts | 4 +++ frontend/lib/components/TrackingWrapper.tsx | 8 ----- frontend/package.json | 1 + frontend/yarn.lock | 18 ++++++++++++ 6 files changed, 49 insertions(+), 23 deletions(-) create mode 100644 frontend/lib/api/brain/config.ts delete mode 100644 frontend/lib/components/TrackingWrapper.tsx diff --git a/frontend/app/App.tsx b/frontend/app/App.tsx index 5283a3b47708..98100c01a585 100644 --- a/frontend/app/App.tsx +++ b/frontend/app/App.tsx @@ -1,21 +1,26 @@ "use client"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { PropsWithChildren, useEffect } from "react"; import Footer from "@/lib/components/Footer"; import { NavBar } from "@/lib/components/NavBar"; -import { TrackingWrapper } from "@/lib/components/TrackingWrapper"; import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext"; import { useSupabase } from "@/lib/context/SupabaseProvider"; import { UpdateMetadata } from "@/lib/helpers/updateMetadata"; +import { usePageTracking } from "@/services/analytics/usePageTracking"; import "../lib/config/LocaleConfig/i18n"; +const queryClient = new QueryClient(); + // This wrapper is used to make effect calls at a high level in app rendering. export const App = ({ children }: PropsWithChildren): JSX.Element => { const { fetchAllBrains, fetchAndSetActiveBrain, fetchPublicPrompts } = useBrainContext(); const { session } = useSupabase(); + usePageTracking(); + useEffect(() => { void fetchAllBrains(); void fetchAndSetActiveBrain(); @@ -23,12 +28,11 @@ export const App = ({ children }: PropsWithChildren): JSX.Element => { }, [session?.user]); return ( - <> - +
{children}