From 9027a7dd1e7e6e66835b746e9bdeaa50d5535b08 Mon Sep 17 00:00:00 2001 From: ABHISHEK PATEL Date: Fri, 25 Aug 2023 15:20:26 -0400 Subject: [PATCH] Fix: Manually delete company cache #1214 (#1315) * Fix: Manually delete company cache #1214 * Fix: Prettier error --- .../modules/companies/hooks/useDeleteCompanies.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/front/src/modules/companies/hooks/useDeleteCompanies.ts b/front/src/modules/companies/hooks/useDeleteCompanies.ts index 67b21b220..56687fb89 100644 --- a/front/src/modules/companies/hooks/useDeleteCompanies.ts +++ b/front/src/modules/companies/hooks/useDeleteCompanies.ts @@ -33,10 +33,20 @@ export function useDeleteSelectedComapnies() { count: rowIdsToDelete.length, }, }, - update: () => { + update: (cache) => { setTableRowIds( tableRowIds.filter((id) => !rowIdsToDelete.includes(id)), ); + + // Manually update the cache to match the mutations + rowIdsToDelete.forEach((companyId) => { + cache.evict({ + id: cache.identify({ + __typename: 'Company', + id: companyId, + }), + }); + }); }, }); }