fix: dedupe Discover apps by coordinate to avoid duplicate LazyGrid keys

The Browser home "Discover nsites/napplets" sections render each followed
manifest in a LazyVerticalGrid keyed by "ns:"/"np:" + coordinate. The
observed store (NoteListMatchingFilter, backed by a ConcurrentSkipListSet
ordered by created-at/id) can surface the same addressable note twice when a
replaceable manifest gets a new version — mutating the note's sort key inside
the set breaks dedup. Both copies map to the same coordinate, producing a
duplicate grid key and crashing with IllegalArgumentException.

Collapse the mapped list by coordinate so each app appears once and grid keys
stay unique.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9TomvuP9YnPUDCZuiQae6
This commit is contained in:
Claude
2026-07-28 17:09:31 +00:00
parent 84a96f1f86
commit 5174c8e5a3
@@ -619,6 +619,10 @@ private fun List<Note>.toDiscoverApps(
matchAuthor(author)
}.mapNotNull { it.toDiscoverNostrApp() }
.filter { it.app.coordinate !in excludeCoordinates }
// The observed store can surface the same addressable manifest twice (a replaceable note whose
// new version mutates its sort key inside the backing set), so collapse by coordinate to keep the
// grid keys unique — otherwise LazyVerticalGrid throws on the duplicate "ns:"/"np:" key.
.distinctBy { it.app.coordinate }
.take(DISCOVER_NOSTR_LIMIT)
.toList()