Hide empty URL previews
Change-Id: I10a2f78e7efa96249adb7cd4849e54150a08001a
This commit is contained in:
parent
9e99fcb7ff
commit
12eb1ea68d
|
@ -48,4 +48,11 @@ data class PreviewUrlData(
|
||||||
val description: String?,
|
val description: String?,
|
||||||
// Value of field "og:image"
|
// Value of field "og:image"
|
||||||
val mxcUrl: String?
|
val mxcUrl: String?
|
||||||
)
|
) {
|
||||||
|
fun isPreviewable(): Boolean {
|
||||||
|
return siteName?.isNotEmpty() == true ||
|
||||||
|
title?.isNotEmpty() == true ||
|
||||||
|
description?.isNotEmpty() == true ||
|
||||||
|
mxcUrl?.isNotEmpty() == true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -65,6 +65,8 @@ class PreviewUrlRetriever(session: Session) {
|
||||||
// Blocked after the request has been sent?
|
// Blocked after the request has been sent?
|
||||||
if (urlToRetrieve in blockedUrl) {
|
if (urlToRetrieve in blockedUrl) {
|
||||||
updateState(eventId, PreviewUrlUiState.NoUrl)
|
updateState(eventId, PreviewUrlUiState.NoUrl)
|
||||||
|
} else if (!it.isPreviewable()) { // Nothing to show
|
||||||
|
updateState(eventId, PreviewUrlUiState.NoUrl)
|
||||||
} else {
|
} else {
|
||||||
updateState(eventId, PreviewUrlUiState.Data(eventId, urlToRetrieve, it))
|
updateState(eventId, PreviewUrlUiState.Data(eventId, urlToRetrieve, it))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue