You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To fix the relation selection issue in create state for Activity, follow these steps:
Locate Cache Update Logic: Open src/components/ActivityEditorEffect.tsx and src/components/ActivityBodyEditor.tsx.
Update Cache on Create: In src/hooks/useCreateActivityInCache.ts, ensure the cache is updated when a new activity is created. Add logic to update relations in the cache.
// src/hooks/useCreateActivityInCache.tsimport{useQueryClient}from'react-query';constuseCreateActivityInCache=()=>{constqueryClient=useQueryClient();constupdateCache=(newActivity)=>{queryClient.setQueryData(['activities'],(oldData)=>{return{
...oldData,activities: [...oldData.activities,newActivity],};});// Add logic to update relations in the cachequeryClient.setQueryData(['relations'],(oldData)=>{return{
...oldData,relations: [...oldData.relations, ...newActivity.relations],};});};return{ updateCache };};exportdefaultuseCreateActivityInCache;
Ensure Cache Consistency: In src/components/ActivityEditorFields.tsx, ensure that the relations are correctly passed and updated in the cache when the activity is created.
// src/components/ActivityEditorFields.tsximportuseCreateActivityInCachefrom'src/hooks/useCreateActivityInCache';constActivityEditorFields=()=>{const{ updateCache }=useCreateActivityInCache();consthandleCreateActivity=(newActivity)=>{// Your existing logic to create activityupdateCache(newActivity);};return(// Your component JSX);};exportdefaultActivityEditorFields;
Scope & Context
https://github.com/twentyhq/twenty/assets/51697796/7d095d3a-0b8a-4f1e-a439-d11f10852db0
(To reproduce, we must be in create mode, meaning not have given a title nor description to the task)
Technical inputs
The relations are well persisted in the DB but disappearing from the cache. We may need to update the cache ourselves.
The text was updated successfully, but these errors were encountered: