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