Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vrack-services): fix error message not disappearing on overview page #11561

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions packages/manager/apps/vrack-services/src/utils/vs-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,7 @@ export const useUpdateVrackServices = ({
const [isErrorVisible, setIsErrorVisible] = React.useState(false);
const queryClient = useQueryClient();

const {
mutateAsync: updateVS,
isPending,
isError,
error: updateError,
} = useMutation<
const { mutateAsync: updateVS, isPending, error: updateError } = useMutation<
ApiResponse<VrackServices>,
ApiError,
UpdateVrackServicesParams
Expand All @@ -105,9 +100,11 @@ export const useUpdateVrackServices = ({
queryClient.invalidateQueries({
queryKey: getVrackServicesResourceListQueryKey,
});
queryClient.invalidateQueries({
queryKey: getVrackServicesResourceQueryKey(result.data?.id || key),
});
if (result) {
queryClient.invalidateQueries({
queryKey: getVrackServicesResourceQueryKey(result.data?.id || key),
});
}
},
onSuccess: (result: ApiResponse<VrackServices>) => {
queryClient.setQueryData(
Expand Down Expand Up @@ -139,19 +136,16 @@ export const useUpdateVrackServices = ({
}, updateTriggerDelay);
onSuccess?.(result);
},
onError,
});

React.useEffect(() => {
if (isError) {
onError: (result) => {
setIsErrorVisible(true);
}
}, [isError]);
onError?.(result);
},
});

return {
updateVS,
isPending,
isErrorVisible,
isErrorVisible: updateError && isErrorVisible,
hideError: () => setIsErrorVisible(false),
updateError,
};
Expand Down
Loading