fix(gallery): forward imeta poster when adding media to gallery
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
+6
-1
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -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) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user