refactor(RoomView): observe the followed thread through useSyncExternalStore - #7634
Merged
diegolmello merged 1 commit intoSep 2, 2026
Conversation
diegolmello
requested a deployment
to
approve_e2e_testing
September 2, 2026 17:37 — with
GitHub Actions
Waiting
Contributor
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (4)
WalkthroughThe PR adds the ChangesObservable thread-following
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested labels: Sequence Diagram(s)sequenceDiagram
participant useThreadFollowing
participant WatermelonDBQuery
participant useObservable
useThreadFollowing->>WatermelonDBQuery: observeWithColumns replies
WatermelonDBQuery-->>useObservable: emit thread records
useObservable-->>useThreadFollowing: return latest thread
useThreadFollowing-->>useThreadFollowing: evaluate userId in replies
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 |
diegolmello
deleted the
diegolmello/useThreadFollowing-useSyncExternalStore
branch
September 2, 2026 17:38
diegolmello
requested a deployment
to
android_build
September 2, 2026 17:39 — with
GitHub Actions
Waiting
diegolmello
requested a deployment
to
ios_build
September 2, 2026 17:39 — with
GitHub Actions
Waiting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
useThreadFollowingfetched the thread message once withgetMessageById, then subscribed to the record inside auseEffectand mirrored it intouseState. It now builds a WatermelonDB query observable in render and reads it through a newuseObservablehook backed byuseSyncExternalStore.useObservable(observable)inlib/hooksbridges any rxjs observable to React. It keys the cached emission by source, so a changed observable returnsundefineduntil the new source emits instead of the previous source's value.observeWithColumns(['replies']), so the follow state re-emits whenreplieschanges on the already-matched record. A plainobserve()on a query only re-emits when the matching set changes.userIdis no longer a subscription dependency; the follow check is derived in render.Issue(s)
Follow-up to #7482
How to test or reproduce
Screenshots
Types of changes
Checklist
Further comments
Open questions kept out of this PR: whether
useObservableshould stay generic with a single caller or be inlined, whether the query belongs inlib/database/services/MessageasobserveMessageById, and whether a deleted thread record should report "following" (current behaviour) or something else.Summary by CodeRabbit
Bug Fixes
Tests