fix: refresh NIP-82 app version chip when a new release arrives

The Apps feed version chip read the latest SoftwareReleaseEvent (kind
30063) once via a produceState keyed only on the app event id. NIP-82
releases point back to the app through an `i` tag rather than an `a`
tag, so they are never indexed as replies to the app note and never
ping its flows. As a result a newer release arriving while the card was
visible left the chip showing the old version.

Re-scan LocalCache on every new-event bundle (the same pattern used by
the calendar RSVP/calendar scans) so the chip updates without a manual
refresh.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EbCTsBoGtBCJ1rTKCcar6w
This commit is contained in:
Claude
2026-06-20 00:45:43 +00:00
parent 2f46293a69
commit ed23f81f3a
@@ -189,9 +189,12 @@ fun RenderSoftwareApplication(
/**
* Looks up the latest NIP-82 [SoftwareReleaseEvent] for [app] from
* [LocalCache] and exposes the version string. Recomputes on event identity
* change; relay-driven recompositions of the surrounding feed will pick up
* newer releases via re-keying.
* [LocalCache] and exposes the version string. Releases (kind 30063) are
* separate events that point back to the app via an `i` tag, so they are not
* indexed as replies to the app note and never ping its flows. We therefore
* re-scan on every [LocalCache.live] new-event bundle so a newer release that
* arrives while the card is visible updates the version chip without a manual
* refresh.
*/
@Composable
fun produceLatestReleaseVersion(app: SoftwareApplicationEvent) =
@@ -200,6 +203,16 @@ fun produceLatestReleaseVersion(app: SoftwareApplicationEvent) =
withContext(Dispatchers.Default) {
findLatestNip82Release(app)?.version()
}
LocalCache.live.newEventBundles.collect {
val newVersion =
withContext(Dispatchers.Default) {
findLatestNip82Release(app)?.version()
}
if (newVersion != value) {
value = newVersion
}
}
}
fun findLatestNip82Release(app: SoftwareApplicationEvent): SoftwareReleaseEvent? {