fix: flickering when updating relation counts (#11943)

https://github.com/user-attachments/assets/f5a87f1d-7c9f-4351-b43a-8b9b47715f94

Closes #11853
This commit is contained in:
Abdul Rahman
2025-05-09 11:58:20 +05:30
committed by GitHub
parent 1a761e39a9
commit ff4db92900

View File

@ -102,17 +102,16 @@ export const RecordDetailRelationSection = ({
} satisfies RecordGqlOperationFilter) } satisfies RecordGqlOperationFilter)
: {}; : {};
const { data: relationAggregateResult, loading: aggregateLoading } = const { data: relationAggregateResult } = useAggregateRecords<{
useAggregateRecords<{ id: { COUNT: number };
id: { COUNT: number }; }>({
}>({ objectNameSingular: relationObjectMetadataItem.nameSingular,
objectNameSingular: relationObjectMetadataItem.nameSingular, filter: filtersForAggregate,
filter: filtersForAggregate, skip: !isToManyObjects,
skip: !isToManyObjects, recordGqlFieldsAggregate: {
recordGqlFieldsAggregate: { id: [AGGREGATE_OPERATIONS.count],
id: [AGGREGATE_OPERATIONS.count], },
}, });
});
const isRecordReadOnly = useIsRecordReadOnly({ const isRecordReadOnly = useIsRecordReadOnly({
recordId, recordId,
@ -123,7 +122,7 @@ export const RecordDetailRelationSection = ({
isRecordReadOnly, isRecordReadOnly,
}); });
if (loading || aggregateLoading || isFieldReadOnly) return null; if (loading || isFieldReadOnly) return null;
const relationRecordsCount = relationAggregateResult?.id?.COUNT ?? 0; const relationRecordsCount = relationAggregateResult?.id?.COUNT ?? 0;