From b835819f97411e2f32ed0e351e9ff9d75dd501b2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 20 Jun 2026 19:37:00 +0000 Subject: [PATCH] refactor: de-duplicate shareId and correct ShareActionRows docs Hoist the AddressableNote-vs-id shareId computation out of the two image share rows, and fix the KDoc rationale: "Share as Image" shares a local PNG (no relay write); the rows are hidden on private rumors because they expose the note's content publicly, not because they publish an e-tag. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01Jc7PP3PLwT4spvjB2c72pk --- .../amethyst/ui/note/elements/ShareActions.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/ShareActions.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/ShareActions.kt index 57f3ee9dbd..15693b2e7e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/ShareActions.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/ShareActions.kt @@ -41,8 +41,9 @@ import com.vitorpamplona.amethyst.ui.stringRes * file, image URL. The copy-to-clipboard options stay in the 3-dot menu, so * they are intentionally NOT part of this shared element. * - * Callers only render this for non-private notes, since each row publishes an - * e-tag of the note (a browser link / an uploaded image referencing it). + * Callers only render these for non-private notes: every option exposes the + * note publicly (a shareable web link, or an image of it), which must never + * happen for a private gift-wrapped rumor. */ @Composable fun ShareActionRows( @@ -51,6 +52,9 @@ fun ShareActionRows( onDismiss: () -> Unit, ) { val actContext = LocalContext.current + // AddressableNotes are shared by their replaceable address; everything else + // by event id. The two image routes resolve the note from this same id. + val shareId = if (note is AddressableNote) note.address.toValue() else note.idHex M3ActionRow(icon = MaterialSymbols.Share, text = stringRes(R.string.quick_action_share)) { val sendIntent = @@ -65,12 +69,10 @@ fun ShareActionRows( onDismiss() } M3ActionRow(icon = MaterialSymbols.Image, text = stringRes(R.string.share_as_image)) { - val shareId = if (note is AddressableNote) note.address.toValue() else note.idHex nav.nav(Route.ShareNoteAsImageFile(shareId)) onDismiss() } M3ActionRow(icon = MaterialSymbols.Image, text = stringRes(R.string.share_as_image_url)) { - val shareId = if (note is AddressableNote) note.address.toValue() else note.idHex nav.nav(Route.ShareNoteAsImage(shareId)) onDismiss() }