mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-12 01:07:46 +00:00
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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jc7PP3PLwT4spvjB2c72pk
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user