Fixes content title for the video playback notification

pull/792/head
Vitor Pamplona 2024-03-02 16:11:01 -05:00
rodzic a301421915
commit 4fb68dd014
4 zmienionych plików z 12 dodań i 6 usunięć

Wyświetl plik

@ -497,7 +497,11 @@ private fun RenderContentAsMarkdown(
ZoomableContentView(
content =
remember(destination, tags) {
RichTextParser().parseMediaUrl(destination, tags ?: EmptyTagList) ?: MediaUrlImage(url = destination)
RichTextParser().parseMediaUrl(
destination,
tags ?: EmptyTagList,
title.ifEmpty { null } ?: content,
) ?: MediaUrlImage(url = destination, description = title.ifEmpty { null } ?: content)
},
roundedCorner = true,
accountViewModel = accountViewModel,

Wyświetl plik

@ -3575,7 +3575,7 @@ fun FileHeaderDisplay(
val blurHash = event.blurhash()
val hash = event.hash()
val dimensions = event.dimensions()
val description = event.alt() ?: event.content
val description = event.content.ifEmpty { null } ?: event.alt()
val isImage = RichTextParser.isImageUrl(fullUrl)
val uri = note.toNostrUri()
@ -3634,7 +3634,7 @@ fun VideoDisplay(
val blurHash = event.blurhash()
val hash = event.hash()
val dimensions = event.dimensions()
val description = event.alt() ?: event.content
val description = event.content.ifBlank { null } ?: event.alt()
val isImage = RichTextParser.isImageUrl(fullUrl)
val uri = note.toNostrUri()

Wyświetl plik

@ -49,6 +49,7 @@ class RichTextParserBenchmark {
RichTextParser().parseMediaUrl(
"https://github.com/vitorpamplona/amethyst/releases/download/v0.83.10/amethyst-googleplay-universal-v0.83.10.apk",
EmptyTagList,
null,
),
)
}

Wyświetl plik

@ -45,6 +45,7 @@ class RichTextParser() {
fun parseMediaUrl(
fullUrl: String,
eventTags: ImmutableListOfLists<String>,
description: String?,
): MediaUrlContent? {
val removedParamsFromUrl = removeQueryParamsForExtensionComparison(fullUrl)
return if (imageExtensions.any { removedParamsFromUrl.endsWith(it) }) {
@ -53,7 +54,7 @@ class RichTextParser() {
MediaUrlImage(
url = fullUrl,
description = frags[FileHeaderEvent.ALT] ?: tags[FileHeaderEvent.ALT],
description = description ?: frags[FileHeaderEvent.ALT] ?: tags[FileHeaderEvent.ALT],
hash = frags[FileHeaderEvent.HASH] ?: tags[FileHeaderEvent.HASH],
blurhash = frags[FileHeaderEvent.BLUR_HASH] ?: tags[FileHeaderEvent.BLUR_HASH],
dim = frags[FileHeaderEvent.DIMENSION] ?: tags[FileHeaderEvent.DIMENSION],
@ -64,7 +65,7 @@ class RichTextParser() {
val tags = Nip92MediaAttachments().parse(fullUrl, eventTags.lists)
MediaUrlVideo(
url = fullUrl,
description = frags[FileHeaderEvent.ALT] ?: tags[FileHeaderEvent.ALT],
description = description ?: frags[FileHeaderEvent.ALT] ?: tags[FileHeaderEvent.ALT],
hash = frags[FileHeaderEvent.HASH] ?: tags[FileHeaderEvent.HASH],
blurhash = frags[FileHeaderEvent.BLUR_HASH] ?: tags[FileHeaderEvent.BLUR_HASH],
dim = frags[FileHeaderEvent.DIMENSION] ?: tags[FileHeaderEvent.DIMENSION],
@ -106,7 +107,7 @@ class RichTextParser() {
val urlSet = parseValidUrls(content)
val imagesForPager =
urlSet.mapNotNull { fullUrl -> parseMediaUrl(fullUrl, tags) }.associateBy { it.url }
urlSet.mapNotNull { fullUrl -> parseMediaUrl(fullUrl, tags, content) }.associateBy { it.url }
val imageList = imagesForPager.values.toList()
val emojiMap = Nip30CustomEmoji.createEmojiMap(tags)