fix: folders call when saving flow (#3658)

* Removed refetching of get folder on save

* Made component appear if its loading

* Rebaned query key to not refetch folders

* Changed isLoading to isFetching for the component to be unclickable while refetching
This commit is contained in:
Lucas Oliveira 2024-09-03 14:41:53 -03:00 • committed by GitHub
commit 61e5bbb482
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 13 deletions

View file

@ -33,14 +33,7 @@ export const usePatchUpdateFlow: useMutationFunctionType<
}; };
const mutation: UseMutationResult<IPatchUpdateFlow, any, IPatchUpdateFlow> = const mutation: UseMutationResult<IPatchUpdateFlow, any, IPatchUpdateFlow> =
mutate(["usePatchUpdateFlow"], PatchUpdateFlowFn, { mutate(["usePatchUpdateFlow"], PatchUpdateFlowFn, options);
...options,
onSettled: () => {
queryClient.refetchQueries({
queryKey: ["useGetFolder"],
});
},
});
return mutation; return mutation;
}; };

View file

@ -20,6 +20,10 @@ export const useGetDownloadFolders: useMutationFunctionType<
return res.data; return res.data;
}; };
const mutation = mutate(["useGetFolders"], downloadFoldersFn, options); const mutation = mutate(
["useGetDownloadFolders"],
downloadFoldersFn,
options,
);
return mutation; return mutation;
}; };

View file

@ -234,7 +234,7 @@ export default function ComponentsComponent({
<EmptyComponent /> <EmptyComponent />
) : ( ) : (
<div className="grid w-full gap-4 md:grid-cols-2 lg:grid-cols-2"> <div className="grid w-full gap-4 md:grid-cols-2 lg:grid-cols-2">
{data?.length > 0 && isLoading === false ? ( {data?.length > 0 ? (
<> <>
{data?.map((item) => ( {data?.map((item) => (
<FormProvider {...methods} key={item.id}> <FormProvider {...methods} key={item.id}>

View file

@ -13,7 +13,7 @@ const MyCollectionComponent = ({ type }: MyCollectionComponentProps) => {
const { folderId } = useParams(); const { folderId } = useParams();
const myCollectionId = useFolderStore((state) => state.myCollectionId); const myCollectionId = useFolderStore((state) => state.myCollectionId);
const { data, isLoading } = useGetFolderQuery( const { data, isFetching } = useGetFolderQuery(
{ {
id: folderId ?? myCollectionId ?? "", id: folderId ?? myCollectionId ?? "",
}, },
@ -27,13 +27,13 @@ const MyCollectionComponent = ({ type }: MyCollectionComponentProps) => {
return ( return (
<> <>
<HeaderTabsSearchComponent loading={isLoading || isLoadingFolders} /> <HeaderTabsSearchComponent loading={isFetching || isLoadingFolders} />
<div className="mt-5 flex h-full flex-col"> <div className="mt-5 flex h-full flex-col">
<ComponentsComponent <ComponentsComponent
key={type} key={type}
type={type} type={type}
currentFolder={data} currentFolder={data}
isLoading={isLoading || isLoadingFolders} isLoading={isFetching || isLoadingFolders}
/> />
</div> </div>
</> </>