refactor(useCompaniesQueries): optimize cache update logic for category publishing
- Removed the invalidateQueries call to prevent unnecessary refetching and duplicate animations during category updates. - Added a comment to clarify the rationale behind the change, ensuring better understanding of the cache synchronization process.
This commit is contained in:
@@ -227,10 +227,9 @@ export const useToggleCompanyCategoryPublished = () => {
|
|||||||
if (toastMessage) {
|
if (toastMessage) {
|
||||||
toast.success(toastMessage);
|
toast.success(toastMessage);
|
||||||
}
|
}
|
||||||
|
// Sync cache only — avoid invalidateQueries here: it refetches and produces a
|
||||||
|
// second `data` reference, which retriggers table row GSAP animations twice.
|
||||||
updateOptimisticCategories(categoryId);
|
updateOptimisticCategories(categoryId);
|
||||||
queryClient.invalidateQueries({
|
|
||||||
queryKey: [API_ENDPOINTS.COMPANIES.CATEGORIES.READ_ALL],
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user