[BUG] Handle optimistic cache deletion operation (#9914)

# Introduction
This PR is highly related to previous optimistic cache refactor:
https://github.com/twentyhq/twenty/pull/9881
Here we've added some logic within the
`triggerUpdateRelationsOptimisticEffect` which will now run if given
recordInput `deletedAt` field is defined.

If deletion, we will iterate over all the fields searching for
`RELATION` for which deletion might implies necessity to detach the
relation

## Known troubleshooting ( also on main )

![image](https://github.com/user-attachments/assets/10ad59cd-e87b-4f26-89df-0a028fcfa518)
We might have to refactor the `prefillRecord` to spread and
overrides`inputValue` over defaultOne as inputValue could be a partial
one for more info please a look to

# Conclusion
Any suggestions are welcomed !
fixes https://github.com/twentyhq/twenty/issues/9580

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Paul Rastoin
2025-01-30 11:12:37 +01:00
committed by GitHub
parent e7da9b6b87
commit 9635fe9222
15 changed files with 177 additions and 140 deletions

View File

@ -92,28 +92,26 @@ export const useOpenCreateActivityDrawer = ({
const targetableObjectRelationIdName = `${targetableObjects[0].targetObjectNameSingular}Id`;
await createOneActivityTarget({
taskId:
activityObjectNameSingular === CoreObjectNameSingular.Task
? activity.id
: undefined,
noteId:
activityObjectNameSingular === CoreObjectNameSingular.Note
? activity.id
: undefined,
...(activityObjectNameSingular === CoreObjectNameSingular.Task
? {
taskId: activity.id,
}
: {
noteId: activity.id,
}),
[targetableObjectRelationIdName]: targetableObjects[0].id,
});
setActivityTargetableEntityArray(targetableObjects);
} else {
await createOneActivityTarget({
taskId:
activityObjectNameSingular === CoreObjectNameSingular.Task
? activity.id
: undefined,
noteId:
activityObjectNameSingular === CoreObjectNameSingular.Note
? activity.id
: undefined,
...(activityObjectNameSingular === CoreObjectNameSingular.Task
? {
taskId: activity.id,
}
: {
noteId: activity.id,
}),
});
setActivityTargetableEntityArray([]);