Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix activity editor #9165

Merged
merged 3 commits into from
Dec 20, 2024
Merged

Fix activity editor #9165

merged 3 commits into from
Dec 20, 2024

Conversation

charlesBochet
Copy link
Member

No description provided.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR refactors the activity editor by separating title and body management concerns, focusing on a more specialized rich text editing implementation for activities.

  • Renamed RichTextEditor to ActivityRichTextEditor in /packages/twenty-front/src/modules/activities/components/ActivityRichTextEditor.tsx and removed title-related functionality
  • Added new hook useReplaceActivityBlockEditorContent with potential JSON parsing vulnerability and incorrect replaceBlocks implementation
  • Added ActivityRichTextEditorChangeOnActivityIdEffect component to handle content updates, though it may have race condition issues
  • Removed activityBodyFamilyState and activityTitleHasBeenSetFamilyState for simpler state management
  • Eliminated drag bug workaround that used debounced state setter

4 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +19 to +21
const content = isNonEmptyString(activityInStore?.body)
? JSON.parse(activityInStore?.body)
: [{ type: 'paragraph', content: '' }];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: JSON.parse could throw for malformed JSON. Wrap in try/catch and fallback to empty paragraph

Comment on lines +21 to +23
replaceBlockEditorContent(activityId);
setCurrentActivityId(activityId);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Potential race condition between replaceBlockEditorContent and setCurrentActivityId. Consider using an async/await pattern or ensuring replaceBlockEditorContent completes before updating state.

const { replaceBlockEditorContent } =
useReplaceActivityBlockEditorContent(editor);

const [currentActivityId, setCurrentActivityId] = useState(activityId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Initial state could be unnecessary since the effect already handles the first render. Consider removing the state and tracking changes differently.

@charlesBochet charlesBochet merged commit f499c72 into main Dec 20, 2024
18 checks passed
@charlesBochet charlesBochet deleted the fix-activity-body-editor branch December 20, 2024 10:52
mdrazak2001 pushed a commit to mdrazak2001/twenty that referenced this pull request Dec 20, 2024
samyakpiya pushed a commit to samyakpiya/twenty that referenced this pull request Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants