Repository navigation
fix(chat): refetch the reactors sheet's rows when reactions change - #1596
Merged
Merged
Conversation
ReactorsPrefetchCache.start returned early for any message it had fetched before, and nothing called clear(), so a message's reactor rows were fetched once per ChatViewModel. The title and summary pills read the live reaction overlay, so the sheet could show 4 reactions over 2 rows. An emoji added after the first open was never fetched at all. start now takes the pills and keeps the emoji to count set it fetched for. The same set reuses the cached rows; a different one refetches from the first page, keeping the previous rows up until the new round lands. A round superseded while in flight no longer publishes, and an empty set clears the message's rows. The open sheet collects the message's pills and calls syncReactors on each change, so reactions added or removed while it's up reach the rows too.
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.
The reactors sheet's title and pills are live, but its rows were fetched once per
ChatViewModel:ReactorsPrefetchCache.startreturned early for any message it had already fetched, and nothing calledclear(). Reopening the sheet after more reactions came in showed, for example, 4 reactions over 2 rows. An emoji added after the first open was never fetched.startnow takes the pills and remembers the emoji → count set it fetched for. The same set reuses the cache; a changed set refetches from the first page.FlowReactorsScreencollectsreactionPills(messageId)and calls the newChatViewModel.syncReactors, so changes made while the sheet is open reach the rows. It collects the flow directly becausecollectAsStateWithLifecycle's empty initial value would read as "all reactions removed".ReactorsPrefetchCacheTestgains cases for a count change, a new emoji, rows kept during a refetch, a superseded round, and removal of every reaction.A pending self-reaction still has a gap: if the sheet refetches before the server has the add, the rows miss it, and the count doesn't change again when the server catches up, so nothing triggers another fetch.