mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-25 07:52:00 +02:00
Adds FileHeader loading to a thread.
This commit is contained in:
parent
a5a320b889
commit
a5728daeb0
@ -781,25 +781,29 @@ fun BadgeDisplay(baseNote: Note) {
|
||||
@Composable
|
||||
fun FileHeaderDisplay(note: Note) {
|
||||
val event = (note.event as? FileHeaderEvent) ?: 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) {
|
||||
val content = if (isImage) {
|
||||
ZoomableImage(fullUrl, description, hash, blurHash)
|
||||
} else {
|
||||
ZoomableVideo(fullUrl, description, hash)
|
||||
var content by remember { mutableStateOf<ZoomableContent?>(null) }
|
||||
|
||||
LaunchedEffect(key1 = event.id) {
|
||||
withContext(Dispatchers.IO) {
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user