fix: disabling API call when the panel type is EMPTY (#3087)

This commit is contained in:
dnazarenkoo 2023-07-10 16:34:21 +03:00 committed by GitHub
parent f0f93c64d2
commit ed200e50c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,6 +83,11 @@ function GridCardGraph({
const updatedQuery = useStepInterval(widget?.query);
const isEmptyWidget = useMemo(
() => widget?.id === 'empty' || isEmpty(widget),
[widget],
);
const queryResponse = useGetQueryRange(
{
selectedTime: widget?.timePreferance,
@ -101,7 +106,7 @@ function GridCardGraph({
variables,
],
keepPreviousData: true,
enabled: isGraphVisible,
enabled: isGraphVisible && !isEmptyWidget,
refetchOnMount: false,
onError: (error) => {
setErrorMessage(error.message);
@ -131,8 +136,6 @@ function GridCardGraph({
);
const onDeleteHandler = useCallback(() => {
const isEmptyWidget = widget?.id === 'empty' || isEmpty(widget);
const widgetId = isEmptyWidget ? layout[0].i : widget?.id;
featureResponse
@ -147,7 +150,8 @@ function GridCardGraph({
});
});
}, [
widget,
isEmptyWidget,
widget?.id,
layout,
featureResponse,
deleteWidget,