-
Notifications
You must be signed in to change notification settings - Fork 14
fix: multiselect undo and redo to update cache and render correctly #8609
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
base: main
Are you sure you want to change the base?
fix: multiselect undo and redo to update cache and render correctly #8609
Conversation
WalkthroughThe PR updates the NewMultiselectButton component and its tests to change GraphQL mock data from flat objects to array-based structures, enhance Apollo cache initialization, and extend undo/redo operations with comprehensive cache cleanup on deletion and block restoration on redo. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Component as NewMultiselectButton<br/>Component
participant Apollo as Apollo Cache
participant Mutation as GraphQL Mutation
User->>Component: Create multiselect
Component->>Mutation: Create mutation (multiselect, options,<br/>button, icons)
Mutation->>Apollo: Write optimistic response
Mutation-->>Component: Return created blocks
Apollo->>Apollo: Add block references to<br/>Journey blocks array
User->>Component: Undo (delete created blocks)
Component->>Mutation: Delete mutation
Mutation->>Apollo: Set fields to null<br/>(optimisticResponse)
Mutation-->>Component: Return mutation data
Apollo->>Apollo: Iterate createdBlocks
Apollo->>Apollo: Remove refs from<br/>Journey blocks list
Apollo->>Apollo: Evict each block<br/>cache entry
Apollo->>Apollo: Run garbage<br/>collection
User->>Component: Redo (restore blocks)
Component->>Mutation: Create mutation (restore)
Mutation-->>Component: Return restored blocks
Apollo->>Apollo: For each block,<br/>append ref to<br/>Journey blocks list
Apollo->>Apollo: Update Journey<br/>query cache
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…block-right-after-creation
|
View your CI Pipeline Execution ↗ for commit 050c941
☁️ Nx Cloud last updated this comment at |
|
The latest updates on your projects.
|
| const [multiselectWithButtonDelete] = useMutation( | ||
| MULTISELECT_WITH_BUTTON_DELETE | ||
| ) | ||
| const [multiselectWithButtonRestore] = useMutation( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to provide some type safety when using this mutation.
| const [multiselectWithButtonRestore] = useMutation<MultiselectWithButtonRestore, MultiselectWithButtonRestoreVariables>( |
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.