Hide empty URL previews

Change-Id: I10a2f78e7efa96249adb7cd4849e54150a08001a
This commit is contained in:
SpiritCroc 2020-12-22 14:26:20 +01:00
parent 9e99fcb7ff
commit 12eb1ea68d
2 changed files with 10 additions and 1 deletions

View file

@ -48,4 +48,11 @@ data class PreviewUrlData(
val description: String?,
// Value of field "og:image"
val mxcUrl: String?
)
) {
fun isPreviewable(): Boolean {
return siteName?.isNotEmpty() == true ||
title?.isNotEmpty() == true ||
description?.isNotEmpty() == true ||
mxcUrl?.isNotEmpty() == true
}
}

View file

@ -65,6 +65,8 @@ class PreviewUrlRetriever(session: Session) {
// Blocked after the request has been sent?
if (urlToRetrieve in blockedUrl) {
updateState(eventId, PreviewUrlUiState.NoUrl)
} else if (!it.isPreviewable()) { // Nothing to show
updateState(eventId, PreviewUrlUiState.NoUrl)
} else {
updateState(eventId, PreviewUrlUiState.Data(eventId, urlToRetrieve, it))
}