Refactor upsertRecordsInStore to accept an object with partialRecords (#16707)

Fixes https://github.com/twentyhq/twenty/issues/16624

Original issue:
- while persisting a field (calling useUpdateOne), the response from the
backend is missing the taskTargets many to many (same for note). As we
optimistically update the cache, we lose the "Relations" in the UI
- I'm changing the behavior of useUpsertInRecordStore to accept
recordGqlFields to only update the fields we want in the record store
(this way, we are not losing the targets information in our case)
This commit is contained in:
Charles Bochet
2025-12-19 15:22:54 +01:00
committed by GitHub
parent 27ca79be7d
commit 8d1329953c
35 changed files with 680 additions and 87 deletions
@@ -148,12 +148,14 @@ export const useActivateWorkflowVersion = () => {
statuses: () => Array.from(newStatuses),
},
});
upsertRecordsInStore([
{
...cachedWorkflow,
statuses: Array.from(newStatuses) as WorkflowStatus[],
},
]);
upsertRecordsInStore({
partialRecords: [
{
...cachedWorkflow,
statuses: Array.from(newStatuses) as WorkflowStatus[],
},
],
});
}
},
});