Skip to content

Commit

Permalink
fix(24361): refactor hook to handle disabled request
Browse files Browse the repository at this point in the history
  • Loading branch information
vanch3d committed Jul 18, 2024
1 parent a8739f8 commit 369d293
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ import { useHttpClient } from '@/api/hooks/useHttpClient/useHttpClient.ts'
import { ApiError, ValuesTree } from '@/api/__generated__'
import { QUERY_KEYS } from '@/api/utils.ts'

export const useGetDataPoints = (isDiscoverable: boolean, adapterId: string, root?: string, depth?: number) => {
export const useGetDataPoints = (
isDiscoverable: boolean,
adapterId: string | undefined,
root?: string,
depth?: number
) => {
const appClient = useHttpClient()

return useQuery<ValuesTree, ApiError>({
queryKey: [QUERY_KEYS.ADAPTERS, adapterId, QUERY_KEYS.DISCOVERY_POINTS, root, depth],
queryFn: () => appClient.protocolAdapters.discoverDataPoints(adapterId, root, depth),
enabled: isDiscoverable,
queryFn: () => appClient.protocolAdapters.discoverDataPoints(adapterId || '', root, depth),
enabled: Boolean(isDiscoverable && adapterId),
})
}

0 comments on commit 369d293

Please sign in to comment.