diff --git a/web/src/api/buster_socket_query/index.ts b/web/src/api/buster_socket_query/index.ts index 34a0cf655..edcb14c65 100644 --- a/web/src/api/buster_socket_query/index.ts +++ b/web/src/api/buster_socket_query/index.ts @@ -1,3 +1,4 @@ export * from './useSocketQueryMutation'; export * from './useSocketQueryOn'; export * from './useSocketQueryEmitAndOnce'; +export * from './useSocketQueryEmitOn'; diff --git a/web/src/api/buster_socket_query/useSocketQueryEmitAndOnce.tsx b/web/src/api/buster_socket_query/useSocketQueryEmitAndOnce.tsx index ffb3bc56e..1b3c24434 100644 --- a/web/src/api/buster_socket_query/useSocketQueryEmitAndOnce.tsx +++ b/web/src/api/buster_socket_query/useSocketQueryEmitAndOnce.tsx @@ -14,7 +14,6 @@ import type { } from '@/api/buster_socket'; import { useBusterWebSocket } from '@/context/BusterWebSocket'; import { useMemoizedFn } from 'ahooks'; -import { queryOptionsConfig } from './queryKeyConfig'; import type { BusterChat } from '@/api/asset_interfaces'; import { InferBusterSocketResponseData } from './types'; @@ -63,19 +62,19 @@ export function useSocketQueryEmitAndOnce< }); } -const ExampleComponent = () => { - const options = queryOptionsConfig['/chats/get:getChat']('123'); +// const ExampleComponent = () => { +// const options = queryOptionsConfig['/chats/get:getChat']('123'); - const deleteChatInitialData = { - id: '123' - } as unknown as BusterChat; +// const deleteChatInitialData = { +// id: '123' +// } as unknown as BusterChat; - const { data } = useSocketQueryEmitAndOnce( - { route: '/chats/get', payload: { id: '123' } }, - '/chats/get:getChat', - options, - (d, x) => { - return deleteChatInitialData; - } - ); -}; +// const { data } = useSocketQueryEmitAndOnce( +// { route: '/chats/get', payload: { id: '123' } }, +// '/chats/get:getChat', +// options, +// (d, x) => { +// return deleteChatInitialData; +// } +// ); +// }; diff --git a/web/src/api/buster_socket_query/useSocketEmitOn.tsx b/web/src/api/buster_socket_query/useSocketQueryEmitOn.tsx similarity index 96% rename from web/src/api/buster_socket_query/useSocketEmitOn.tsx rename to web/src/api/buster_socket_query/useSocketQueryEmitOn.tsx index c7c70a162..8d935e401 100644 --- a/web/src/api/buster_socket_query/useSocketEmitOn.tsx +++ b/web/src/api/buster_socket_query/useSocketQueryEmitOn.tsx @@ -6,7 +6,7 @@ import { useEffect } from 'react'; import { useMemoizedFn } from 'ahooks'; import { useSocketQueryOn } from './useSocketQueryOn'; -export const useSocketEmitOn = < +export const useSocketQueryEmitOn = < TRoute extends BusterSocketResponseRoute, TError = unknown, TData = InferBusterSocketResponseData, diff --git a/web/src/api/buster_socket_query/useSocketQueryMutation.tsx b/web/src/api/buster_socket_query/useSocketQueryMutation.tsx index 1aeb45397..7b70b13ba 100644 --- a/web/src/api/buster_socket_query/useSocketQueryMutation.tsx +++ b/web/src/api/buster_socket_query/useSocketQueryMutation.tsx @@ -15,7 +15,7 @@ import type { } from '@/api/buster_socket'; import { useBusterWebSocket } from '@/context/BusterWebSocket'; import { useMemoizedFn } from 'ahooks'; -import { queryOptionsConfig } from './queryKeyConfig'; +import { queryKeys } from '../asset_interfaces'; import type { BusterSocketRequestConfig, BusterSocketRequestRoute, @@ -86,28 +86,28 @@ export function useSocketQueryMutation< }); } -const ExampleComponent = () => { - const queryClient = useQueryClient(); - const options = queryOptionsConfig['/chats/list:getChatsList'](); - const data = queryClient.getQueryData(options.queryKey); - data?.[0].created_by_avatar; +// const ExampleComponent = () => { +// const queryClient = useQueryClient(); +// const options = queryKeys['/chats/list:getChatsList'](); +// const data = queryClient.getQueryData(options.queryKey); +// data?.[0].created_by_avatar; - const { mutate } = useSocketQueryMutation< - '/chats/delete', - '/chats/delete:deleteChat', - unknown, - { id: string }[], - { id: string }[], - BusterChatListItem[] - >( - { route: '/chats/delete' }, - { route: '/chats/delete:deleteChat' }, - options, - (currentData, newData) => { - currentData?.[0].created_by_avatar; // This should now be properly typed - return currentData ?? []; - } - ); +// const { mutate } = useSocketQueryMutation< +// '/chats/delete', +// '/chats/delete:deleteChat', +// unknown, +// { id: string }[], +// { id: string }[], +// BusterChatListItem[] +// >( +// { route: '/chats/delete' }, +// { route: '/chats/delete:deleteChat' }, +// options, +// (currentData, newData) => { +// currentData?.[0].created_by_avatar; // This should now be properly typed +// return currentData ?? []; +// } +// ); - mutate([{ id: '123' }]); -}; +// mutate([{ id: '123' }]); +// }; diff --git a/web/src/api/buster_socket_query/useSocketQueryOn.tsx b/web/src/api/buster_socket_query/useSocketQueryOn.tsx index 7bccbf8f2..a27f17e90 100644 --- a/web/src/api/buster_socket_query/useSocketQueryOn.tsx +++ b/web/src/api/buster_socket_query/useSocketQueryOn.tsx @@ -12,8 +12,11 @@ import { useBusterWebSocket } from '@/context/BusterWebSocket'; import { useMemo, useRef, useTransition } from 'react'; import type { InferBusterSocketResponseData } from './types'; import { useMemoizedFn, useMount, useUnmount } from 'ahooks'; -import { queryOptionsConfig } from './queryKeyConfig'; -import { BusterChat } from '@/api/asset_interfaces'; + +import { queryKeys } from '../asset_interfaces'; + +//TEST +import type { BusterChat } from '@/api/asset_interfaces'; type UseSocketQueryOnResult = UseQueryResult; @@ -79,23 +82,23 @@ const defaultCallback = ( d: InferBusterSocketResponseData ) => d as TData; -const _ExampleComponent = () => { - const options = queryOptionsConfig['/chats/get:getChat']('123'); - const { data } = useSocketQueryOn('/chats/get:getChat', options); +// const _ExampleComponent = () => { +// const options = queryKeys['/chats/get:getChat']('123'); +// const { data } = useSocketQueryOn('/chats/get:getChat', options); - const options2 = queryOptionsConfig['/chats/list:getChatsList'](); - const { data: data2 } = useSocketQueryOn('/chats/list:getChatsList', options2); +// const options2 = queryKeys['/chats/list:getChatsList'](); +// const { data: data2 } = useSocketQueryOn('/chats/list:getChatsList', options2); - const options3 = queryOptionsConfig['/chats/delete:deleteChat']('123'); +// const options3 = queryKeys['/chats/delete:deleteChat']('123'); - // Create fresh options for delete chat that match the expected BusterChat type - const deleteChatInitialData = { - id: '123' - } as unknown as BusterChat; +// // Create fresh options for delete chat that match the expected BusterChat type +// const deleteChatInitialData = { +// id: '123' +// } as unknown as BusterChat; - const { data: data3 } = useSocketQueryOn('/chats/delete:deleteChat', options3, (d, x) => { - d?.[0].is_favorited; - x[0].id; - return []; - }); -}; +// const { data: data3 } = useSocketQueryOn('/chats/delete:deleteChat', options3, (d, x) => { +// d?.[0].is_favorited; +// x[0].id; +// return []; +// }); +// }; diff --git a/web/src/app/app/settings/(permissions)/dataset-groups/[datasetGroupId]/users/DatasetGroupUsersController.tsx b/web/src/app/app/settings/(permissions)/dataset-groups/[datasetGroupId]/users/DatasetGroupUsersController.tsx index b75e1c8e9..f498c5937 100644 --- a/web/src/app/app/settings/(permissions)/dataset-groups/[datasetGroupId]/users/DatasetGroupUsersController.tsx +++ b/web/src/app/app/settings/(permissions)/dataset-groups/[datasetGroupId]/users/DatasetGroupUsersController.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useGetDatasetGroupUsers, useGetPermissionGroupUsers } from '@/api'; +import { useGetDatasetGroupUsers } from '@/api/buster_rest'; import { AppMaterialIcons } from '@/components/icons'; import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; import { useDebounceSearch } from '@/hooks/useDebounceSearch'; diff --git a/web/src/app/app/settings/(permissions)/permission-groups/[permissionGroupId]/users/PermissionGroupUsersController.tsx b/web/src/app/app/settings/(permissions)/permission-groups/[permissionGroupId]/users/PermissionGroupUsersController.tsx index fb56d17c0..b95eddfca 100644 --- a/web/src/app/app/settings/(permissions)/permission-groups/[permissionGroupId]/users/PermissionGroupUsersController.tsx +++ b/web/src/app/app/settings/(permissions)/permission-groups/[permissionGroupId]/users/PermissionGroupUsersController.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useGetPermissionGroupUsers } from '@/api'; +import { useGetPermissionGroupUsers } from '@/api/buster_rest'; import { AppMaterialIcons } from '@/components/icons'; import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; import { useDebounceSearch } from '@/hooks/useDebounceSearch'; diff --git a/web/src/app/app/settings/(permissions)/users/[userId]/permission-groups/UserPermissionGroupSelectedPopup.tsx b/web/src/app/app/settings/(permissions)/users/[userId]/permission-groups/UserPermissionGroupSelectedPopup.tsx index f9c5e8f97..a8fc36f9b 100644 --- a/web/src/app/app/settings/(permissions)/users/[userId]/permission-groups/UserPermissionGroupSelectedPopup.tsx +++ b/web/src/app/app/settings/(permissions)/users/[userId]/permission-groups/UserPermissionGroupSelectedPopup.tsx @@ -1,4 +1,4 @@ -import { useUpdateUserPermissionGroups } from '@/api'; +import { useUpdateUserPermissionGroups } from '@/api/buster_rest'; import { PermissionAssignedButton } from '@/app/app/_components/PermissionComponents'; import { BusterListSelectedOptionPopupContainer } from '@/components/list'; import React from 'react'; diff --git a/web/src/hooks/index.ts b/web/src/hooks/index.ts index 8bdda625e..afff75619 100644 --- a/web/src/hooks/index.ts +++ b/web/src/hooks/index.ts @@ -1,4 +1,4 @@ export * from './react'; export * from './dom'; export * from './useDebounceSearch'; -export * from './useSocketQuery'; +export * from './useWebSocket';