Closed Devessier closed 1 month ago
Here are the advice Charles gave to me:
network-only
unless the back-end logic is heavySolved Discard Draft doesn't update all the app! Now checking the other bug.
Solved the other issue!
Found another issue.
When the user activates the draft version while being on its show page, the query getting the current draft version is not updated. It should return that there is no more draft version.
https://github.com/user-attachments/assets/45a3d4a4-1858-4cf3-bada-2be1693a160c
In this issue, I will document the problems I found with data synchronization on the workflow pages. The issues arise after mutations and are apparent when the Apollo cache is empty, notably after a full-page refresh.
Several active versions
Suppose you have an activated v2 version (cached by Apollo, i.e., you've already been to the version page) and create a new v3 version you publish; you can end up with two activated versions. Both versions are marked as active on their respective show pages.
https://github.com/user-attachments/assets/f4b4822c-2dab-45fd-839b-055f62c845b0
Technical details
The
useWorkflowVersion
hook that fetches the data used here to display the status of the version: https://github.com/twentyhq/twenty/blob/ae3054196d476efd45216c6172e260b7679f4940/packages/twenty-front/src/modules/workflow/hooks/useWorkflowVersion.tsxThe
activeWorkflowVersion
function: https://github.com/twentyhq/twenty/blob/ae3054196d476efd45216c6172e260b7679f4940/packages/twenty-front/src/modules/workflow/hooks/useActivateWorkflowVersion.tsx#L28-L43The
activeWorkflowVersion
function will fetch the data of the activated workflow version but not the data of all the other workflows, one of which was archived.Discard Draft doesn't update all the app
Clicking Discard Draft after arriving via a full-page refresh performs the essential modification. Still, the front is partially updated: the list of versions on the left is updated, not the header or visualizer.
https://github.com/user-attachments/assets/a9a13483-a078-40de-abb6-5cfd3f617ccc
Technical details
The component is not re-rendered with the updated workflow data. The component is: https://github.com/twentyhq/twenty/blob/1863636003ee034ff4cc764aecf3c1f8ad6d8a38/packages/twenty-front/src/modules/workflow/components/RecordShowPageWorkflowHeader.tsx
The code called when clicking on "Discard Draft": https://github.com/twentyhq/twenty/blob/ae3054196d476efd45216c6172e260b7679f4940/packages/twenty-front/src/modules/workflow/components/RecordShowPageWorkflowHeader.tsx#L44-L59
The code of the
deleteOneWorkflowVersion
function: https://github.com/twentyhq/twenty/blob/ae3054196d476efd45216c6172e260b7679f4940/packages/twenty-front/src/modules/workflow/hooks/useDeleteOneWorkflowVersion.tsx#L18How to solve that?
If I were a TanStack Query, I would invalidate the data of all the workflows when activating or deactivating. A more granular option would be invalidating only the last workflow version we deactivated. That's putting more logic on the front end, which might be false—the other workflow versions could have been updated in another tab simultaneously—but we might be okay with this approach.
I'm open to any recommendation and will apply it everywhere on the workflow module.