From 73eea945722605540120d34058122107e14d1f2f Mon Sep 17 00:00:00 2001 From: Oscar Beaumont Date: Tue, 25 Oct 2022 11:41:46 +1000 Subject: [PATCH] React Query devtools --- apps/desktop/src/index.tsx | 1 - packages/client/src/stores/debugState.ts | 7 ++++- packages/interface/src/App.tsx | 28 +++++++++++-------- .../src/components/layout/Sidebar.tsx | 18 ++++++++++++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/apps/desktop/src/index.tsx b/apps/desktop/src/index.tsx index 0638c9ac2..04eb2f184 100644 --- a/apps/desktop/src/index.tsx +++ b/apps/desktop/src/index.tsx @@ -10,7 +10,6 @@ import { createRoot } from 'react-dom/client'; import '@sd/ui/style'; -const isDev = import.meta.env.DEV; const client = hooks.createClient({ links: [ splitLink({ diff --git a/packages/client/src/stores/debugState.ts b/packages/client/src/stores/debugState.ts index 2fe06b296..f2dc5f8d2 100644 --- a/packages/client/src/stores/debugState.ts +++ b/packages/client/src/stores/debugState.ts @@ -6,7 +6,12 @@ import { valtioPersist } from '.'; export const debugState = valtioPersist('sd-debugState', { // @ts-ignore enabled: import.meta.env.DEV, - rspcLogger: false + rspcLogger: false, + // @ts-ignore + reactQueryDevtools: (import.meta.env.DEV ? 'invisible' : 'enabled') as + | 'enabled' + | 'disabled' + | 'invisible' }); export function useDebugState() { diff --git a/packages/interface/src/App.tsx b/packages/interface/src/App.tsx index 9756e7336..c0669d41a 100644 --- a/packages/interface/src/App.tsx +++ b/packages/interface/src/App.tsx @@ -1,5 +1,5 @@ import '@fontsource/inter/variable.css'; -import { LibraryContextProvider, queryClient } from '@sd/client'; +import { LibraryContextProvider, queryClient, useDebugState } from '@sd/client'; import { QueryClientProvider, defaultContext } from '@tanstack/react-query'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import dayjs from 'dayjs'; @@ -21,16 +21,7 @@ export default function SpacedriveInterface() { return ( - {/* The `context={defaultContext}` part is required for this to work on Windows. Why, idk, don't question it */} - {import.meta.env.DEV && ( - - )} + @@ -39,6 +30,21 @@ export default function SpacedriveInterface() { ); } +function Devtools() { + const debugState = useDebugState(); + + // The `context={defaultContext}` part is required for this to work on Windows. Why, idk, don't question it + return debugState.reactQueryDevtools !== 'disabled' ? ( + + ) : null; +} + // This can't go in `` cause it needs the router context but it can't go in `` because that requires this context function AppRouterWrapper() { const navigate = useNavigate(); diff --git a/packages/interface/src/components/layout/Sidebar.tsx b/packages/interface/src/components/layout/Sidebar.tsx index aa23904c8..6223da349 100644 --- a/packages/interface/src/components/layout/Sidebar.tsx +++ b/packages/interface/src/components/layout/Sidebar.tsx @@ -18,6 +18,8 @@ import { Dropdown, Loader, OverlayPanel, + Select, + SelectOption, Switch, cva, tw @@ -195,6 +197,22 @@ function DebugPanel() { )} + + + + {/* {platform.showDevtools && (