-
Notifications
You must be signed in to change notification settings - Fork 6
Optimistic updates fix #651
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
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughCentralizes discussions cache key computation, passes root post context into comment payloads, changes optimistic-update handling to use a separate discussions optimistic entry and flip Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant DiscussionsCache
participant EntryCache
participant SDK
participant Blockchain
Client->>DiscussionsCache: insert optimistic discussion (is_optimistic = true)
Client->>EntryCache: insert optimistic entry for pending tx
Client->>SDK: call create-comment (includes rootAuthor/rootPermlink)
SDK->>Blockchain: submit transaction (fire-and-forget)
Blockchain-->>SDK: confirmation/event
SDK->>EntryCache: confirm/update entry (retain/update optimistic entry)
SDK->>DiscussionsCache: flip is_optimistic on matching discussion / invalidate predicate
DiscussionsCache-->>Client: refreshed/confirmed discussions
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 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 |
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/web/src/api/mutations/create-reply.ts`:
- Around line 120-126: The cache update is matching entries by permlink only
which can corrupt discussions cache because permlinks are only unique per
author; update all places that call
queryClient.setQueryData(getDiscussionsCacheKey(), ...) — including the .then()
branch that sets is_optimistic to false, the .catch() branch that removes
optimistic entries, and the onError handler — to compare both r.permlink ===
permlink AND r.author === author when mapping or filtering entries (use the
existing permlink and author variables) so only the intended author's entry is
modified or removed.
Summary by CodeRabbit
Bug Fixes
Improvements
Chores