Fix person deletion not reflected on Opportunities POC (#1387)

* Fix person deletion not reflected on Opportunities POC

* Fix companies, user deletion
This commit is contained in:
Charles Bochet 2023-08-31 15:06:17 +02:00 committed by GitHub
parent ec23ca3d12
commit 2d5cb9c750
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 12 deletions

View File

@ -38,14 +38,11 @@ export function useDeleteSelectedComapnies() {
tableRowIds.filter((id) => !rowIdsToDelete.includes(id)), tableRowIds.filter((id) => !rowIdsToDelete.includes(id)),
); );
// Manually update the cache to match the mutations
rowIdsToDelete.forEach((companyId) => { rowIdsToDelete.forEach((companyId) => {
cache.evict({ cache.evict({
id: cache.identify({ id: cache.identify({ __typename: 'Company', id: companyId }),
__typename: 'Company',
id: companyId,
}),
}); });
cache.gc();
}); });
}, },
}); });

View File

@ -47,10 +47,14 @@ export function usePersonTableActionBarEntries() {
count: rowIdsToDelete.length, count: rowIdsToDelete.length,
}, },
}, },
update: () => { update: (cache) => {
setTableRowIds( setTableRowIds(
tableRowIds.filter((id) => !rowIdsToDelete.includes(id)), tableRowIds.filter((id) => !rowIdsToDelete.includes(id)),
); );
rowIdsToDelete.forEach((id) => {
cache.evict({ id: cache.identify({ id, __typename: 'Person' }) });
cache.gc();
});
}, },
}); });
} }

View File

@ -64,15 +64,20 @@ export function SettingsWorkspaceMembers() {
return; return;
} }
const normalizedId = cache.identify({ cache.evict({
id: responseData.deleteWorkspaceMember.id, id: cache.identify({
__typename: 'WorkspaceMember', id: responseData.deleteWorkspaceMember.id,
__typename: 'WorkspaceMember',
}),
}); });
// Evict object from cache cache.evict({
cache.evict({ id: normalizedId }); id: cache.identify({
id: userId,
__typename: 'User',
}),
});
// Clean up relation to this object
cache.gc(); cache.gc();
}, },
}); });