From 2ea25f73a3ee7deaf7f53500791dd4dab697cb77 Mon Sep 17 00:00:00 2001 From: davotoula Date: Sun, 3 May 2026 20:02:58 +0200 Subject: [PATCH] fix(gallery): forward imeta poster when adding media to gallery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Add Media to Gallery" action in the zoomable view passed only blurhash, dim, hash, and mime type — losing the poster URL that the underlying NIP-71 imeta carries on its `image` field. The resulting ProfileGalleryEntryEvent therefore had no `image` tag, and the gallery card fell back to the play-icon placeholder for any HLS URL because the .m3u8 playlist itself can't be decoded as an image. Thread the poster through Account.addToGallery and AccountViewModel.addMediaToGallery as an optional `image` parameter, and pull it from the MediaUrlVideo's artworkUri at the call site. Non-video content (MediaUrlImage, etc.) still passes null. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../main/java/com/vitorpamplona/amethyst/model/Account.kt | 3 +++ .../amethyst/ui/components/ZoomableContentView.kt | 7 ++++++- .../amethyst/ui/screen/loggedIn/AccountViewModel.kt | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index 612a2cbaf..826b8e079 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -135,6 +135,7 @@ import com.vitorpamplona.quartz.experimental.profileGallery.blurhash import com.vitorpamplona.quartz.experimental.profileGallery.dimension import com.vitorpamplona.quartz.experimental.profileGallery.fromEvent import com.vitorpamplona.quartz.experimental.profileGallery.hash +import com.vitorpamplona.quartz.experimental.profileGallery.image import com.vitorpamplona.quartz.experimental.profileGallery.mimeType import com.vitorpamplona.quartz.marmot.mip00KeyPackages.KeyPackageEvent import com.vitorpamplona.quartz.marmot.mls.group.MlsGroupStateStore @@ -2547,6 +2548,7 @@ class Account( hash: String?, mimeType: String?, thumbhash: String? = null, + image: String? = null, ) { val template = ProfileGalleryEntryEvent.build(url) { @@ -2556,6 +2558,7 @@ class Account( dim?.let { dimension(it) } blurhash?.let { blurhash(it) } thumbhash?.let { galleryThumbhash(it) } + image?.let { image(it) } } val event = signer.sign(template) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt index 1244e6a62..e530ec028 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt @@ -940,7 +940,12 @@ fun ShareMediaAction( if (videoUri != null) { val n19 = Nip19Parser.uriToRoute(postNostrUri)?.entity as? NEvent if (n19 != null) { - accountViewModel.addMediaToGallery(n19.hex, videoUri, n19.relay.getOrNull(0), blurhash, dim, hash, mimeType) + // Forward the imeta poster (only MediaUrlVideo carries it) so HLS + // gallery entries have a still to render — without this, a video + // event whose imeta only contains a .m3u8 URL renders as a black + // play-icon tile in the gallery. + val posterUrl = (content as? MediaUrlVideo)?.artworkUri + accountViewModel.addMediaToGallery(n19.hex, videoUri, n19.relay.getOrNull(0), blurhash, dim, hash, mimeType, image = posterUrl) accountViewModel.toastManager.toast(R.string.media_added, R.string.media_added_to_profile_gallery) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 216b5bcce..4036bb3ba 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -856,7 +856,8 @@ class AccountViewModel( dim: DimensionTag?, hash: String?, mimeType: String?, - ) = launchSigner { account.addToGallery(hex, url, relay, blurhash, dim, hash, mimeType) } + image: String? = null, + ) = launchSigner { account.addToGallery(hex, url, relay, blurhash, dim, hash, mimeType, image = image) } fun removeFromMediaGallery(note: Note) = launchSigner { account.removeFromGallery(note) }