fix: fix record deletion optimistic effect (#3683)
* fix: fix record deletion optimistic effect * fix: fix renamed method after rebase * Re-add evict --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -29,7 +29,7 @@ export const triggerCreateRecordsOptimisticEffect = ({
|
||||
[objectMetadataItem.namePlural]: (
|
||||
cachedConnection,
|
||||
{
|
||||
INVALIDATE: _INVALIDATE,
|
||||
DELETE: _DELETE,
|
||||
readField,
|
||||
storeFieldName: _storeFieldName,
|
||||
toReference,
|
||||
@ -97,7 +97,7 @@ export const triggerCreateRecordsOptimisticEffect = ({
|
||||
cachedEdges?.length === variables.first &&
|
||||
nextCachedEdges.length < variables.first
|
||||
) {
|
||||
return INVALIDATE;
|
||||
return DELETE;
|
||||
}
|
||||
|
||||
if (nextCachedEdges.length > variables.first) {
|
||||
|
||||
@ -21,7 +21,7 @@ export const triggerDeleteRecordsOptimisticEffect = ({
|
||||
fields: {
|
||||
[objectMetadataItem.namePlural]: (
|
||||
cachedConnection,
|
||||
{ INVALIDATE, readField, storeFieldName },
|
||||
{ DELETE, readField, storeFieldName },
|
||||
) => {
|
||||
if (
|
||||
!isCachedObjectConnection(
|
||||
@ -49,12 +49,14 @@ export const triggerDeleteRecordsOptimisticEffect = ({
|
||||
return nodeId && !recordIds.includes(nodeId);
|
||||
}) || [];
|
||||
|
||||
if (nextCachedEdges.length === cachedEdges?.length)
|
||||
return cachedConnection;
|
||||
|
||||
if (
|
||||
isDefined(variables?.first) &&
|
||||
cachedEdges?.length === variables.first &&
|
||||
nextCachedEdges.length < variables.first
|
||||
cachedEdges?.length === variables.first
|
||||
) {
|
||||
return INVALIDATE;
|
||||
return DELETE;
|
||||
}
|
||||
|
||||
return { ...cachedConnection, edges: nextCachedEdges };
|
||||
|
||||
@ -28,7 +28,7 @@ export const triggerUpdateRecordOptimisticEffect = ({
|
||||
fields: {
|
||||
[objectMetadataItem.namePlural]: (
|
||||
cachedConnection,
|
||||
{ INVALIDATE, readField, storeFieldName, toReference },
|
||||
{ DELETE, readField, storeFieldName, toReference },
|
||||
) => {
|
||||
if (
|
||||
!isCachedObjectConnection(
|
||||
@ -93,7 +93,7 @@ export const triggerUpdateRecordOptimisticEffect = ({
|
||||
cachedEdges?.length === variables.first &&
|
||||
nextCachedEdges.length < variables.first
|
||||
) {
|
||||
return INVALIDATE;
|
||||
return DELETE;
|
||||
}
|
||||
|
||||
// If next edges length exceeds the required limit,
|
||||
|
||||
Reference in New Issue
Block a user