Skip to content

fix(chat): refetch the reactors sheet's rows when reactions change - #1596

Merged
bmc08gt merged 1 commit into
code/cashfrom
fix/reactors-sheet-refresh
Sep 28, 2026
Merged

bmc08gt merged 1 commit into
code/cashfrom
fix/reactors-sheet-refresh

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

The reactors sheet's title and pills are live, but its rows were fetched once per ChatViewModel: ReactorsPrefetchCache.start returned early for any message it had already fetched, and nothing called clear(). 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.

  • start now 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.
  • The previous rows stay published while the refetch is in flight, so the sheet doesn't drop back to placeholders.
  • A round superseded mid-flight is cancelled and can't overwrite the newer rows. An empty set clears the message's rows.
  • FlowReactorsScreen collects reactionPills(messageId) and calls the new ChatViewModel.syncReactors, so changes made while the sheet is open reach the rows. It collects the flow directly because collectAsStateWithLifecycle's empty initial value would read as "all reactions removed".

ReactorsPrefetchCacheTest gains 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.

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.
@bmc08gt bmc08gt self-assigned this Sep 28, 2026
@github-actions github-actions Bot added the type: fix Bug fix label Sep 28, 2026
@bmc08gt
bmc08gt merged commit 937f5dc into code/cash Sep 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant