Files
buzz/mobile/lib/shared/relay
Logan Johnson 547de61aa5 fix(mobile): show channel posts before a burst of join notices (#8798)
## Summary

When many people join a channel at once, the mobile app could open that
channel and show only a "… joined" line, with none of the channel's
posts. You had to scroll up before any messages appeared. With this
change, the posts always show first, and the join lines appear among
them in the right places.

The cause: the app loads the newest 50 timeline rows when a channel
opens, and join notices counted toward those 50. A burst of 50 or more
joins filled the whole first page. The app combines a run of joins into
one line only when it draws the screen, so the user saw a single "Guest
10 joined … and 48 others" line. The app loads older rows only after the
user scrolls.

This is the mobile port of the desktop app's fix,
https://github.com/block/buzz-app/pull/1983, which has already merged.
It needs no relay change.

- History pages no longer include join notices, so the first page is all
posts.
- The app reads join notices with a separate read, newest first, 500 per
read. It reads down to the oldest post loaded so far, and continues
after each older page loads. Like desktop, it stops after 2,000 notices.
- Each notice read also reads the reactions on those notices, and any
removals of those reactions. A page brings these back for its own rows,
but notices are no longer on the pages, so they need their own read.
These reads name the channel in `#h`, so a system channel, or an
unlisted channel opened by a non-member, still returns them (NIP-CL).
Deletions are also read without `#h`, because a deletion can be stored
with no channel. Each read names at most 500 target ids, so it stays
under the relay's 1 MiB request limit. A notice's reactions show even
when they sort below the oldest loaded post.
- Posts show as soon as their page loads. The notices follow and are
merged into the timeline, so they do not replace rows that arrived live
in the meantime.
- A notice that is older than the oldest loaded post waits until its
page loads. This prevents a join from showing at the top of the timeline
with a gap of missing posts below it.
- If a notice read fails, the posts still show. The next page load tries
the notices again; if a page loaded while the read was running, the read
runs once more right away.
- The same applies to every system notice (joins, topic changes, channel
created or archived), as they share one event kind.

### Related issue

AIDA-2328. Desktop fix (merged):
https://github.com/block/buzz-app/pull/1983.

### Testing

Before (left, older build) and after (right, this branch) on the Android
emulator, against a local relay. #general and #4things each have 4 posts
followed by 60 joins:


https://github.com/user-attachments/assets/53b80942-d8c3-4604-8b95-cc5ca7ab6946

![Before and after: the old build shows only a joins line; the fix shows
the 4 posts above the joins
line](https://github.com/user-attachments/assets/58e121b9-855c-4844-a73a-c71b54252db2)

- New `channel_messages_provider_test.dart` cases run against the real
channel provider, with only relay responses faked:
- A burst of 500+ joins does not hold posts back. If the first notice
read fails, the posts still show. A later page read retries the notices
and continues the descent.
- Notices in the same second as the oldest loaded post follow the post's
position within that second.
  - The descent stops at 2,000 notices.
- A notice keeps its reactions, and a removed reaction stays removed.
Reactions are read past the relay's 1,000-event page. The fake relay
applies the NIP-CL rule, so a read without `#h` finds no channel
reactions.
  - A page that loads while a notice read fails still gets its notices.
- `just mobile-check` and the full `just mobile-test` pass at
`7a38763af`.

Not yet tested on a physical device, or on iOS.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Logan Johnson <loganj@squareup.com>
Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 20:34:41 -04:00
..