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:
AmirReza Jamali
2026-05-18 11:06:54 +03:30
parent a238edc563
commit f5099d8e04
+2 -3
View File
@@ -227,10 +227,9 @@ export const useToggleCompanyCategoryPublished = () => {
if (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);
queryClient.invalidateQueries({
queryKey: [API_ENDPOINTS.COMPANIES.CATEGORIES.READ_ALL],
});
},
});
};