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> =
mutate(["usePatchUpdateFlow"], PatchUpdateFlowFn, {
...options,
onSettled: () => {
queryClient.refetchQueries({
queryKey: ["useGetFolder"],
});
},
});
mutate(["usePatchUpdateFlow"], PatchUpdateFlowFn, options);
return mutation;
};

View file

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

View file

@ -234,7 +234,7 @@ export default function ComponentsComponent({
<EmptyComponent />
) : (
<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) => (
<FormProvider {...methods} key={item.id}>

View file

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