mirror of https://github.com/buster-so/buster.git
adjust query provider menu
This commit is contained in:
parent
7b2190cea9
commit
cdf1551e9d
|
@ -34,7 +34,7 @@ const chatsGetList = (filters?: Parameters<typeof getListChats>[0]) =>
|
||||||
|
|
||||||
const chatsBlackBoxMessages = (messageId: string) =>
|
const chatsBlackBoxMessages = (messageId: string) =>
|
||||||
queryOptions<string | null>({
|
queryOptions<string | null>({
|
||||||
queryKey: ['chats', 'messages', messageId, 'black-box'] as const,
|
queryKey: ['chats', 'messages', messageId, 'local-only-black-box'] as const,
|
||||||
staleTime: Infinity,
|
staleTime: Infinity,
|
||||||
enabled: false, //this is local
|
enabled: false, //this is local
|
||||||
queryFn: () => Promise.resolve(null)
|
queryFn: () => Promise.resolve(null)
|
||||||
|
|
|
@ -7,7 +7,7 @@ const collectionsGetList = (
|
||||||
) =>
|
) =>
|
||||||
queryOptions<BusterCollectionListItem[]>({
|
queryOptions<BusterCollectionListItem[]>({
|
||||||
queryKey: ['collections', 'list', filters] as const,
|
queryKey: ['collections', 'list', filters] as const,
|
||||||
staleTime: 4 * 1000,
|
staleTime: 60 * 1000,
|
||||||
initialData: [],
|
initialData: [],
|
||||||
initialDataUpdatedAt: 0
|
initialDataUpdatedAt: 0
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,8 +10,8 @@ const dashboardGetList = (
|
||||||
) =>
|
) =>
|
||||||
queryOptions<BusterDashboardListItem[]>({
|
queryOptions<BusterDashboardListItem[]>({
|
||||||
queryKey: ['dashboard', 'list', filters] as const,
|
queryKey: ['dashboard', 'list', filters] as const,
|
||||||
staleTime: 10 * 1000,
|
|
||||||
initialData: [],
|
initialData: [],
|
||||||
|
staleTime: 60 * 1000,
|
||||||
initialDataUpdatedAt: 0
|
initialDataUpdatedAt: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ export const metricsGetMetric = (metricId: string, version_number?: number) => {
|
||||||
export const metricsGetList = (filters?: Parameters<typeof listMetrics>[0]) =>
|
export const metricsGetList = (filters?: Parameters<typeof listMetrics>[0]) =>
|
||||||
queryOptions<BusterMetricListItem[]>({
|
queryOptions<BusterMetricListItem[]>({
|
||||||
queryKey: ['metrics', 'list', filters] as const,
|
queryKey: ['metrics', 'list', filters] as const,
|
||||||
staleTime: 10 * 1000
|
staleTime: 60 * 1000
|
||||||
});
|
});
|
||||||
|
|
||||||
export const metricsGetData = (id: string, version_number?: number) =>
|
export const metricsGetData = (id: string, version_number?: number) =>
|
||||||
|
|
|
@ -33,8 +33,8 @@ const ScrollBar = React.forwardRef<
|
||||||
orientation={orientation}
|
orientation={orientation}
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex touch-none transition-colors select-none',
|
'flex touch-none transition-colors select-none',
|
||||||
orientation === 'vertical' && 'h-full w-2.5 border-l border-l-transparent p-[1px]',
|
orientation === 'vertical' && 'h-full w-2 border-l border-l-transparent p-[1px]',
|
||||||
orientation === 'horizontal' && 'h-2.5 flex-col border-t border-t-transparent p-[1px]',
|
orientation === 'horizontal' && 'h-2 flex-col border-t border-t-transparent p-[1px]',
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}>
|
{...props}>
|
||||||
|
|
|
@ -1,18 +1,29 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { QueryClientProvider } from '@tanstack/react-query';
|
import { QueryClientProvider } from '@tanstack/react-query';
|
||||||
import React, { useLayoutEffect } from 'react';
|
import React, { useLayoutEffect, useState } from 'react';
|
||||||
import mainApi from '@/api/buster_rest/instances';
|
import mainApi from '@/api/buster_rest/instances';
|
||||||
import { defaultRequestHandler } from '@/api/createInstance';
|
import { defaultRequestHandler } from '@/api/createInstance';
|
||||||
import nextApi from '@/api/next/instances';
|
import nextApi from '@/api/next/instances';
|
||||||
import { useSupabaseContext } from '../Supabase/SupabaseContextProvider';
|
import { useSupabaseContext } from '../Supabase/SupabaseContextProvider';
|
||||||
import { getQueryClient } from './getQueryClient';
|
import { getQueryClient } from './getQueryClient';
|
||||||
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools';
|
import {} from '@tanstack/react-query-devtools';
|
||||||
|
import dynamic from 'next/dynamic';
|
||||||
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
|
|
||||||
|
const ReactQueryDevtoolsPanel = dynamic(
|
||||||
|
() => import('@tanstack/react-query-devtools').then((mod) => mod.ReactQueryDevtoolsPanel),
|
||||||
|
{
|
||||||
|
loading: () => <div>Loading dev tools...</div>,
|
||||||
|
ssr: false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export const BusterReactQueryProvider = ({ children }: { children: React.ReactElement<any> }) => {
|
export const BusterReactQueryProvider = ({ children }: { children: React.ReactElement<any> }) => {
|
||||||
const accessToken = useSupabaseContext((state) => state.accessToken);
|
const accessToken = useSupabaseContext((state) => state.accessToken);
|
||||||
const checkTokenValidity = useSupabaseContext((state) => state.checkTokenValidity);
|
const checkTokenValidity = useSupabaseContext((state) => state.checkTokenValidity);
|
||||||
const queryClient = getQueryClient(accessToken);
|
const queryClient = getQueryClient(accessToken);
|
||||||
|
const [isDevToolsOpen, setIsDevToolsOpen] = useState(false);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
//reset all request interceptors
|
//reset all request interceptors
|
||||||
|
@ -22,10 +33,15 @@ export const BusterReactQueryProvider = ({ children }: { children: React.ReactEl
|
||||||
nextApi.interceptors.request.use((v) => defaultRequestHandler(v, { checkTokenValidity }));
|
nextApi.interceptors.request.use((v) => defaultRequestHandler(v, { checkTokenValidity }));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useHotkeys('meta+shift+i', () => {
|
||||||
|
console.log('meta+shift+i');
|
||||||
|
setIsDevToolsOpen((prev) => !prev);
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
{children}
|
{children}
|
||||||
<ReactQueryDevtoolsPanel />
|
{isDevToolsOpen && <ReactQueryDevtoolsPanel />}
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,7 +46,11 @@ export const ChatContainerHeaderDropdown: React.FC<{
|
||||||
];
|
];
|
||||||
}, [chatId, currentMessageId, deleteChat, duplicateChat]);
|
}, [chatId, currentMessageId, deleteChat, duplicateChat]);
|
||||||
|
|
||||||
return <Dropdown items={menuItem}>{chatId ? children : null}</Dropdown>;
|
return (
|
||||||
|
<Dropdown align="end" items={menuItem}>
|
||||||
|
{chatId ? children : null}
|
||||||
|
</Dropdown>
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
ChatContainerHeaderDropdown.displayName = 'ChatContainerHeaderDropdown';
|
ChatContainerHeaderDropdown.displayName = 'ChatContainerHeaderDropdown';
|
||||||
|
|
Loading…
Reference in New Issue