mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-07-09 20:31:13 +02:00
Adds FileHeader loading to a thread.
This commit is contained in:
@ -781,25 +781,29 @@ fun BadgeDisplay(baseNote: Note) {
|
|||||||
@Composable
|
@Composable
|
||||||
fun FileHeaderDisplay(note: Note) {
|
fun FileHeaderDisplay(note: Note) {
|
||||||
val event = (note.event as? FileHeaderEvent) ?: return
|
val event = (note.event as? FileHeaderEvent) ?: return
|
||||||
|
|
||||||
val fullUrl = event.url() ?: return
|
val fullUrl = event.url() ?: return
|
||||||
val blurHash = event.blurhash()
|
|
||||||
val hash = event.hash()
|
|
||||||
val description = event.content
|
|
||||||
val removedParamsFromUrl = fullUrl.split("?")[0].lowercase()
|
|
||||||
val isImage = imageExtensions.any { removedParamsFromUrl.endsWith(it) }
|
|
||||||
val isVideo = videoExtensions.any { removedParamsFromUrl.endsWith(it) }
|
|
||||||
|
|
||||||
if (isImage || isVideo) {
|
var content by remember { mutableStateOf<ZoomableContent?>(null) }
|
||||||
val content = if (isImage) {
|
|
||||||
ZoomableImage(fullUrl, description, hash, blurHash)
|
LaunchedEffect(key1 = event.id) {
|
||||||
} else {
|
withContext(Dispatchers.IO) {
|
||||||
ZoomableVideo(fullUrl, description, hash)
|
val blurHash = event.blurhash()
|
||||||
|
val hash = event.hash()
|
||||||
|
val description = event.content
|
||||||
|
val removedParamsFromUrl = fullUrl.split("?")[0].lowercase()
|
||||||
|
val isImage = imageExtensions.any { removedParamsFromUrl.endsWith(it) }
|
||||||
|
val isVideo = videoExtensions.any { removedParamsFromUrl.endsWith(it) }
|
||||||
|
content = if (isImage) {
|
||||||
|
ZoomableImage(fullUrl, description, hash, blurHash)
|
||||||
|
} else {
|
||||||
|
ZoomableVideo(fullUrl, description, hash)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ZoomableContentView(content = content, listOf(content))
|
|
||||||
} else {
|
|
||||||
UrlPreview(fullUrl, "$fullUrl ")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content?.let {
|
||||||
|
ZoomableContentView(content = it, listOf(it))
|
||||||
|
} ?: UrlPreview(fullUrl, "$fullUrl ")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
Reference in New Issue
Block a user