mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-10 00:16:59 +00:00
A draw now has no winner. winning() used maxByOrNull, which handed the green highlight and the check to whichever tied option happened to come first — on a 1-1 poll, an outright lie about the result. The feed card no longer sorts every voter on the UI thread to draw four avatars. filterTo ran during composition and again on every tally change, sorting an option's whole voter list so UserGallery could take(4). TallyResults now keeps its voters unsorted, materialises the ordered list lazily for the screens that list everyone, and offers topUsers(n) via a bounded insertion. Desktop's own gallery and its is-this-my-vote check go through the same paths instead of forcing the sort. Voter rows are keyed by pubkey rather than by User instance. The cache normally hands out one User per pubkey, but an eviction and re-create would leave two live instances for one person — and two rows sharing a LazyColumn key is a crash, not a cosmetic duplicate. The tally still counts them separately; this stops the crash. An empty poll that is still loading no longer says "No votes yet" and "Loading every vote..." at the same time. The results opt-in fires on a deep link. It read note.event inside an id-keyed LaunchedEffect, so when the poll event arrived after first composition the effect never ran again and the visit went unrecorded. Keyed on the observed note state now, via observeNote, which also carries the subscription the screen already needed. The backfill remembers. The ViewModel is rebuilt on every visit, so bouncing in and out of a poll re-walked every relay's whole history; a completed drain now stands in for the next five minutes, which the live subscription makes safe. Smaller: the ViewModel factory, loader and mapped Flow are remembered instead of rebuilt each recomposition; winning() is computed once per build rather than once per option; myVote falls out of the loop already running instead of a second scan; option bars grow from zero on first show; the vote column has a max width instead of a fixed one; and a no-HLL merge reports approximate when any relay said so, not just when the highest did. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AQorYBSv9oMvKa8hF1uGBv