The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix optimistic rendering when deleting multiple records (#9198)
Marie6abe735caddf
diff --git a/packages/twenty-front/src/modules/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffectByBatch.ts b/packages/twenty-front/src/modules/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffectByBatch.tsindex 0b115f958ec..52e88985e23 100644--- a/packages/twenty-front/src/modules/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffectByBatch.ts+++ b/packages/twenty-front/src/modules/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffectByBatch.ts@@ -75,14 +75,12 @@ export const triggerUpdateRecordOptimisticEffectByBatch = ({objectMetadataItem,});- const updatedRecordIndexInRootQueryEdges =- rootQueryCurrentEdges.findIndex(+ const updatedRecordFoundInRootQueryEdges = isDefined(+ rootQueryCurrentEdges.find((cachedEdge) =>readField('id', cachedEdge.node) === updatedRecord.id,- );-- const updatedRecordFoundInRootQueryEdges =- updatedRecordIndexInRootQueryEdges > -1;+ ),+ );const updatedRecordShouldBeAddedToRootQueryEdges =updatedRecordMatchesThisRootQueryFilter &&@@ -105,7 +103,10 @@ export const triggerUpdateRecordOptimisticEffectByBatch = ({}if (updatedRecordShouldBeRemovedFromRootQueryEdges) {- rootQueryNextEdges.splice(updatedRecordIndexInRootQueryEdges, 1);+ rootQueryNextEdges = rootQueryNextEdges.filter(+ (cachedEdge) =>+ readField('id', cachedEdge.node) !== updatedRecord.id,+ );}}