Fix optimistic rendering when deleting multiple records (#9198)

Fixes
https://discord.com/channels/1130383047699738754/1319676302944370730/1319676302944370730
This commit is contained in:
Marie
2024-12-23 14:19:25 +01:00
committed by GitHub
parent c947040137
commit 6abe735cad

View File

@ -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,
);
}
}