From f5099d8e0423e089c57a1a99f1d0ab2ef28d107e Mon Sep 17 00:00:00 2001 From: AmirReza Jamali Date: Mon, 18 May 2026 11:06:54 +0330 Subject: [PATCH] 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. --- src/hooks/queries/useCompaniesQueries.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hooks/queries/useCompaniesQueries.ts b/src/hooks/queries/useCompaniesQueries.ts index 28d2e0c..ae991ed 100644 --- a/src/hooks/queries/useCompaniesQueries.ts +++ b/src/hooks/queries/useCompaniesQueries.ts @@ -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], - }); }, }); };