3757 update frontend to show correct view count (#3967)
* Add totalCount to fetch record request * Add totalCount to object board * WIP Add totalCount to object table * Update query total count on update / delete optimistic effects * Remove console log * Load fewer data for totalcount --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -63,6 +63,13 @@ export const triggerCreateRecordsOptimisticEffect = ({
|
||||
'edges',
|
||||
rootQueryCachedObjectRecordConnection,
|
||||
);
|
||||
|
||||
const rootQueryCachedRecordTotalCount =
|
||||
readField<number>(
|
||||
'totalCount',
|
||||
rootQueryCachedObjectRecordConnection,
|
||||
) || 0;
|
||||
|
||||
const nextRootQueryCachedRecordEdges = rootQueryCachedRecordEdges
|
||||
? [...rootQueryCachedRecordEdges]
|
||||
: [];
|
||||
@ -109,6 +116,7 @@ export const triggerCreateRecordsOptimisticEffect = ({
|
||||
return {
|
||||
...rootQueryCachedObjectRecordConnection,
|
||||
edges: nextRootQueryCachedRecordEdges,
|
||||
totalCount: rootQueryCachedRecordTotalCount + 1,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
@ -50,6 +50,12 @@ export const triggerDeleteRecordsOptimisticEffect = ({
|
||||
rootQueryCachedObjectRecordConnection,
|
||||
);
|
||||
|
||||
const totalCount =
|
||||
readField<number>(
|
||||
'totalCount',
|
||||
rootQueryCachedObjectRecordConnection,
|
||||
) || 0;
|
||||
|
||||
const nextCachedEdges =
|
||||
cachedEdges?.filter((cachedEdge) => {
|
||||
const nodeId = readField<string>('id', cachedEdge.node);
|
||||
@ -71,6 +77,7 @@ export const triggerDeleteRecordsOptimisticEffect = ({
|
||||
return {
|
||||
...rootQueryCachedObjectRecordConnection,
|
||||
edges: nextCachedEdges,
|
||||
totalCount: totalCount - recordIdsToDelete.length,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user