From ba92d4414432c808c2b3865a08737e4e1b818761 Mon Sep 17 00:00:00 2001 From: EdwinKato Date: Tue, 3 Dec 2024 15:57:31 +0300 Subject: [PATCH 1/2] Prevent multiple calls to get custom fields on saving a survey --- front/app/api/custom_fields/useUpdateCustomFields.ts | 8 -------- front/app/components/FormBuilder/edit/index.tsx | 8 +++----- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/front/app/api/custom_fields/useUpdateCustomFields.ts b/front/app/api/custom_fields/useUpdateCustomFields.ts index fb71404868e9..46c2d22d6792 100644 --- a/front/app/api/custom_fields/useUpdateCustomFields.ts +++ b/front/app/api/custom_fields/useUpdateCustomFields.ts @@ -1,8 +1,6 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'; import { CLErrors } from 'typings'; -import customFieldOptionKeys from 'api/custom_field_options/keys'; - import fetcher from 'utils/cl-react-query/fetcher'; import customFieldsKeys from './keys'; @@ -45,12 +43,6 @@ const useUpdateCustomField = () => { phaseId: variables.phaseId, }), }); - queryClient.invalidateQueries({ - queryKey: customFieldsKeys.lists(), - }); - queryClient.invalidateQueries({ - queryKey: customFieldOptionKeys.items(), - }); }, }); }; diff --git a/front/app/components/FormBuilder/edit/index.tsx b/front/app/components/FormBuilder/edit/index.tsx index 7fe35d6bf558..5855c0c180ea 100644 --- a/front/app/components/FormBuilder/edit/index.tsx +++ b/front/app/components/FormBuilder/edit/index.tsx @@ -262,11 +262,9 @@ const FormEdit = ({ }, { onSuccess: () => { - refetch().then(() => { - setIsUpdatingForm(true); - setSuccessMessageIsVisible(true); - resetCopyFrom(); - }); + setIsUpdatingForm(true); + setSuccessMessageIsVisible(true); + resetCopyFrom(); }, } ); From b85147ea133f66109e3e36128a29cbd4fbf9e153 Mon Sep 17 00:00:00 2001 From: EdwinKato Date: Tue, 3 Dec 2024 16:01:11 +0300 Subject: [PATCH 2/2] Remove unused refetch --- front/app/components/FormBuilder/edit/index.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/front/app/components/FormBuilder/edit/index.tsx b/front/app/components/FormBuilder/edit/index.tsx index 5855c0c180ea..0819ad06f088 100644 --- a/front/app/components/FormBuilder/edit/index.tsx +++ b/front/app/components/FormBuilder/edit/index.tsx @@ -84,11 +84,7 @@ const FormEdit = ({ const { formSavedSuccessMessage, isFormPhaseSpecific } = builderConfig; const { mutateAsync: updateFormCustomFields } = useUpdateCustomField(); const showWarningNotice = totalSubmissions > 0; - const { - data: formCustomFields, - refetch, - isFetching, - } = useFormCustomFields({ + const { data: formCustomFields, isFetching } = useFormCustomFields({ projectId, phaseId: isFormPhaseSpecific ? phaseId : undefined, });