Update the quoted message preview in threads when the quoted message is deleted or edited#6584
Conversation
…ted message is updated or deleted
|
@CodeRabbit review |
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
✅ Action performedReview finished.
|
WalkthroughChangesQuoted message reference handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
SDK Size Comparison 📏
|
…age-is-not-updated-after-deleting-a
|



Goal
When a message quoted by a thread reply is deleted or edited, the quoted preview inside the thread is not updated. The channel message list already handles this case, but the thread message list keeps showing the old content. This change applies the same update to the thread state.
Resolves AND-272
Implementation
The channel path refreshes quote previews when the
message.updated/message.deletedWebSocket event arrives:ChannelEventHandlerImplcallsChannelStateImpl.updateQuotedMessageReferences, which rewrites thereplyToof every quoting message. The thread path (EventHandlerSequential.updateThreadState->ThreadLogic.handleMessageEvents) only upserted the changed message itself, so quoting thread replies kept a stalereplyTo.ThreadStateLogic: newupdateQuotedMessageReferences(quotedMessage)anddeleteQuotedMessageReferences(quotedMessageId). They scan the in-memory thread messages forreplyTo?.id/replyMessageIdmatches instead of maintaining aquotedMessagesMaplike the channel state does, since the thread list is small and fully in memory.ThreadLogic.handleMessageEvents: after the existing upsert,MessageUpdatedEventand softMessageDeletedEventrefresh thereplyToof quoting messages with the enriched message, and a hard delete clears thereplyTo. This mirrors the channel event handler contract.ThreadLogicis shared by the new and legacy channel logic modes, so both are covered.@Ignorefromtest_originalQuoteIsDeletedByUser_deletedMessageIsShown_InThread, as required by the ticket.randomMessageDeletedEventbuilder to the shared test fixtures.One intentional difference from the channel counterpart: attachment URLs of the old
replyToare not preserved when rewriting it. Thread state upserts never preserve attachment URLs today, so this follows the existing thread module behavior.This also aligns with the iOS SDK, where the quote is a database relationship: quoting messages always render the current content of the quoted message, and a hard delete nullifies the reference.
Testing
Covered by new unit tests (
ThreadLogicTest,ThreadStateLogicTest) and by the re-enabled e2e testQuotedReplyTests#test_originalQuoteIsDeletedByUser_deletedMessageIsShown_InThread. The e2e test passes locally with this change and fails without it (verified by running both builds against the mock server).Manual steps:
Summary by CodeRabbit
Bug Fixes
Tests