mirror of https://github.com/buster-so/buster.git
fix misfired query request
This commit is contained in:
parent
44a09810ce
commit
1841953e9c
|
@ -2,7 +2,6 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|||
import { create } from 'mutative';
|
||||
import { dashboardQueryKeys } from '@/api/query_keys/dashboard';
|
||||
import { getOriginalDashboard } from '@/context/Dashboards/useOriginalDashboardStore';
|
||||
import type { dashboardsUpdateDashboard } from '../requests';
|
||||
import { useSaveDashboard } from './useSaveDashboard';
|
||||
|
||||
/**
|
||||
|
|
|
@ -83,7 +83,9 @@ export const useGetMetric = <TData = BusterMetric>(
|
|||
|
||||
const { isFetched: isFetchedInitial, isError: isErrorInitial } = useQuery({
|
||||
...metricsQueryKeys.metricsGetMetric(id || '', 'LATEST'),
|
||||
queryFn: () => getMetricQueryFn({ id, version: 'LATEST', queryClient, password }),
|
||||
queryFn: () => {
|
||||
return getMetricQueryFn({ id, version: 'LATEST', queryClient, password });
|
||||
},
|
||||
retry(_failureCount, error) {
|
||||
if (error?.message !== undefined && id) {
|
||||
setProtectedAssetPasswordError({
|
||||
|
@ -93,16 +95,19 @@ export const useGetMetric = <TData = BusterMetric>(
|
|||
}
|
||||
return false;
|
||||
},
|
||||
enabled: (params?.enabled ?? true) && !!id,
|
||||
select: undefined,
|
||||
...params,
|
||||
enabled: (params?.enabled ?? true) && !!id,
|
||||
});
|
||||
|
||||
return useQuery({
|
||||
...metricsQueryKeys.metricsGetMetric(id || '', selectedVersionNumber),
|
||||
enabled: !!id && !!latestVersionNumber && isFetchedInitial && !isErrorInitial,
|
||||
queryFn: () => getMetricQueryFn({ id, version: selectedVersionNumber, queryClient, password }),
|
||||
queryFn: () => {
|
||||
return getMetricQueryFn({ id, version: selectedVersionNumber, queryClient, password });
|
||||
},
|
||||
...params,
|
||||
select: params?.select,
|
||||
enabled: !!id && !!latestVersionNumber && isFetchedInitial && !isErrorInitial,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ export const getMetric = async ({
|
|||
id,
|
||||
...params
|
||||
}: GetMetricParams & GetMetricQuery): Promise<GetMetricResponse> => {
|
||||
return mainApiV2.get<GetMetricResponse>(`/metric_files/${id}`, { params }).then((res) => {
|
||||
return res.data;
|
||||
});
|
||||
return mainApiV2
|
||||
.get<GetMetricResponse>(`/metric_files/${id}`, { params })
|
||||
.then(({ data }) => data);
|
||||
};
|
||||
|
||||
export const getMetricData = async ({
|
||||
|
|
Loading…
Reference in New Issue