Display found items after full items loaded (#18914)
The performCombinedFindManyRecords call was previously fire-and-forget (.then()), meaning the loading state was set to false and the picker became interactive before the full records were written into the Apollo cache. Fixes https://github.com/twentyhq/twenty/issues/17669 Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
This commit is contained in:
+24
-26
@@ -321,33 +321,31 @@ export const useMultipleRecordPickerPerformSearch = () => {
|
||||
},
|
||||
}));
|
||||
|
||||
if (operationSignatures.length === 0) {
|
||||
return;
|
||||
if (operationSignatures.length > 0) {
|
||||
const { result } = await performCombinedFindManyRecords({
|
||||
operationSignatures,
|
||||
});
|
||||
|
||||
Object.values(result)
|
||||
.flat()
|
||||
.forEach((objectRecord) => {
|
||||
const searchRecord = searchRecords.find(
|
||||
({ recordId }) => recordId === objectRecord.id,
|
||||
);
|
||||
|
||||
if (!searchRecord) {
|
||||
return;
|
||||
}
|
||||
|
||||
store.set(
|
||||
searchRecordStoreFamilyState.atomFamily(objectRecord.id),
|
||||
{
|
||||
...searchRecord,
|
||||
record: objectRecord,
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
performCombinedFindManyRecords({ operationSignatures }).then(
|
||||
({ result }) => {
|
||||
Object.values(result)
|
||||
.flat()
|
||||
.forEach((objectRecord) => {
|
||||
const searchRecord = searchRecords.find(
|
||||
({ recordId }) => recordId === objectRecord.id,
|
||||
);
|
||||
|
||||
if (!searchRecord) {
|
||||
return;
|
||||
}
|
||||
|
||||
store.set(
|
||||
searchRecordStoreFamilyState.atomFamily(objectRecord.id),
|
||||
{
|
||||
...searchRecord,
|
||||
record: objectRecord,
|
||||
},
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
store.set(multipleRecordPickerPaginationState.atomFamily(atomFamilyKey), {
|
||||
|
||||
Reference in New Issue
Block a user