1 Commits

Author SHA1 Message Date
Tom Brow
5b9dbcb4c2 perf(mobile): avoid redundant message list sorting (#7647)
When new messages arrive in a mobile channel, the app updates the list
of loaded messages on the UI thread. It currently sorts that list twice.
The second sort is needed only when the app has retained messages opened
through a link to a specific message.

This change uses the first sorted list when there are no retained
messages to merge. It reduces work during message bursts and keeps the
existing merge and ordering behavior for message links.

A controlled debug test with 2,000 loaded messages and 1,000 incoming
messages reduced processing time from 446 ms to 266 ms. This measures
the message update code, not screen rendering or release-device
performance. All 26 focused tests pass, including a regression test that
fails if the extra pass returns. Tests also cover message order and
retained messages.

Repository checks and downstream test/build suites passed, apart from
unrelated Rust timing failures in the full local run; each passed an
isolated retry. GitHub CI passed after retrying an unrelated desktop
attachment test failure.

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
2026-09-15 11:29:54 -07:00