From 938f40d568125bcf120969e2a135ef0ffc5ce7df Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 21 Jun 2026 21:10:31 +0000 Subject: [PATCH] refactor(amethyst): fall back to quartz KindNames for unknown kinds The relay kind chips, NIP-86 management screen, and app-recommendation labels all map kinds to translated R.string labels via kindDisplayName(), returning -1 for kinds without a localized name. Route that -1 case through the shared quartz KindNames registry so any kind known to the protocol layer renders its canonical English label instead of a bare "k"/empty placeholder. Translations still win where they exist; quartz is the canonical source for the rest. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_011SapGdtAc1j7woifoCZ9fY --- .../apps/recommendations/ProfileAppRecommendationsScreen.kt | 3 ++- .../ui/screen/loggedIn/relays/RelayInformationScreen.kt | 3 ++- .../ui/screen/loggedIn/relays/nip86/RelayManagementScreen.kt | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/apps/recommendations/ProfileAppRecommendationsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/apps/recommendations/ProfileAppRecommendationsScreen.kt index 15403e6a07..a3fd3f8bfe 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/apps/recommendations/ProfileAppRecommendationsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/apps/recommendations/ProfileAppRecommendationsScreen.kt @@ -75,6 +75,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.kindDisplayName import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.theme.Size20Modifier import com.vitorpamplona.amethyst.ui.theme.placeholderText +import com.vitorpamplona.quartz.kinds.KindNames import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent import kotlinx.coroutines.Dispatchers @@ -427,7 +428,7 @@ private fun supportedKindsLabel(kinds: List): String { val names = kinds.take(VISIBLE_KIND_NAMES).map { kind -> val nameRes = kindDisplayName(kind) - if (nameRes != -1) stringRes(nameRes) else "k$kind" + if (nameRes != -1) stringRes(nameRes) else (KindNames.nameFor(kind) ?: "k$kind") } val overflow = kinds.size - VISIBLE_KIND_NAMES val suffix = if (overflow > 0) " +$overflow" else "" diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt index f521fa90d1..ea9ed897bb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt @@ -133,6 +133,7 @@ import com.vitorpamplona.quartz.experimental.nns.NNSEvent import com.vitorpamplona.quartz.experimental.notifications.wake.WakeUpEvent import com.vitorpamplona.quartz.experimental.profileGallery.ProfileGalleryEntryEvent import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent +import com.vitorpamplona.quartz.kinds.KindNames import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.relay.client.stats.ErrorDebugMessage @@ -694,7 +695,7 @@ val reports = setOf(ReportEvent.KIND, MuteListEvent.KIND, DeletionEvent.KIND, Re @Composable fun KindChip(kind: Int) { val nameResId = kindDisplayName(kind) - val name = if (nameResId != -1) stringResource(nameResId) else "k$kind" + val name = if (nameResId != -1) stringResource(nameResId) else (KindNames.nameFor(kind) ?: "k$kind") val (bg, fg) = when (kind) { in posts -> { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/nip86/RelayManagementScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/nip86/RelayManagementScreen.kt index 79a87fffbf..db406f30eb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/nip86/RelayManagementScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/nip86/RelayManagementScreen.kt @@ -102,6 +102,7 @@ import com.vitorpamplona.amethyst.ui.theme.Size55dp import com.vitorpamplona.amethyst.ui.theme.SmallBorder import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer import com.vitorpamplona.amethyst.ui.theme.nip05 +import com.vitorpamplona.quartz.kinds.KindNames import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.relay.normalizer.displayUrl @@ -897,7 +898,7 @@ private fun KindEntryCard( verticalAlignment = Alignment.CenterVertically, ) { val nameResId = kindDisplayName(kind) - val name = if (nameResId != -1) stringResource(nameResId) else "" + val name = if (nameResId != -1) stringResource(nameResId) else (KindNames.nameFor(kind) ?: "") Text( "Kind $kind: $name",