Fix optimistic rendering when deleting multiple records (#9198)
Fixes https://discord.com/channels/1130383047699738754/1319676302944370730/1319676302944370730
This commit is contained in:
@ -75,14 +75,12 @@ export const triggerUpdateRecordOptimisticEffectByBatch = ({
|
|||||||
objectMetadataItem,
|
objectMetadataItem,
|
||||||
});
|
});
|
||||||
|
|
||||||
const updatedRecordIndexInRootQueryEdges =
|
const updatedRecordFoundInRootQueryEdges = isDefined(
|
||||||
rootQueryCurrentEdges.findIndex(
|
rootQueryCurrentEdges.find(
|
||||||
(cachedEdge) =>
|
(cachedEdge) =>
|
||||||
readField('id', cachedEdge.node) === updatedRecord.id,
|
readField('id', cachedEdge.node) === updatedRecord.id,
|
||||||
);
|
),
|
||||||
|
);
|
||||||
const updatedRecordFoundInRootQueryEdges =
|
|
||||||
updatedRecordIndexInRootQueryEdges > -1;
|
|
||||||
|
|
||||||
const updatedRecordShouldBeAddedToRootQueryEdges =
|
const updatedRecordShouldBeAddedToRootQueryEdges =
|
||||||
updatedRecordMatchesThisRootQueryFilter &&
|
updatedRecordMatchesThisRootQueryFilter &&
|
||||||
@ -105,7 +103,10 @@ export const triggerUpdateRecordOptimisticEffectByBatch = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (updatedRecordShouldBeRemovedFromRootQueryEdges) {
|
if (updatedRecordShouldBeRemovedFromRootQueryEdges) {
|
||||||
rootQueryNextEdges.splice(updatedRecordIndexInRootQueryEdges, 1);
|
rootQueryNextEdges = rootQueryNextEdges.filter(
|
||||||
|
(cachedEdge) =>
|
||||||
|
readField('id', cachedEdge.node) !== updatedRecord.id,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user