[Technical] Open stickers using the thumbnail url if the main url is empty (#2157)
* Explicitely use the thumbnail url to show stickers if the content's url is an empty string --------- Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>
This commit is contained in:
parent
4f6c7421bd
commit
a81fdddab0
3 changed files with 19 additions and 17 deletions
1
changelog.d/1949.bugfix
Normal file
1
changelog.d/1949.bugfix
Normal file
|
|
@ -0,0 +1 @@
|
|||
Make sure the media viewer tries the main url first (if not empty) then the thumbnail url and then not open if both are missing instead of failing with an error dialog
|
||||
|
|
@ -255,17 +255,21 @@ class MessagesFlowNode @AssistedInject constructor(
|
|||
overlay.show(navTarget)
|
||||
}
|
||||
is TimelineItemStickerContent -> {
|
||||
val navTarget = NavTarget.MediaViewer(
|
||||
mediaInfo = MediaInfo(
|
||||
name = event.content.body,
|
||||
mimeType = event.content.mimeType,
|
||||
formattedFileSize = event.content.formattedFileSize,
|
||||
fileExtension = event.content.fileExtension
|
||||
),
|
||||
mediaSource = event.content.mediaSource,
|
||||
thumbnailSource = event.content.thumbnailSource,
|
||||
)
|
||||
overlay.show(navTarget)
|
||||
/* Sticker may have an empty url and no thumbnail
|
||||
if encrypted on certain bridges */
|
||||
if (event.content.preferredMediaSource != null) {
|
||||
val navTarget = NavTarget.MediaViewer(
|
||||
mediaInfo = MediaInfo(
|
||||
name = event.content.body,
|
||||
mimeType = event.content.mimeType,
|
||||
formattedFileSize = event.content.formattedFileSize,
|
||||
fileExtension = event.content.fileExtension
|
||||
),
|
||||
mediaSource = event.content.preferredMediaSource,
|
||||
thumbnailSource = event.content.thumbnailSource,
|
||||
)
|
||||
overlay.show(navTarget)
|
||||
}
|
||||
}
|
||||
is TimelineItemVideoContent -> {
|
||||
val navTarget = NavTarget.MediaViewer(
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package io.element.android.features.messages.impl.timeline.model.event
|
||||
|
||||
import io.element.android.libraries.core.mimetype.MimeTypes
|
||||
import io.element.android.libraries.matrix.api.media.MediaSource
|
||||
|
||||
data class TimelineItemStickerContent(
|
||||
|
|
@ -33,9 +32,7 @@ data class TimelineItemStickerContent(
|
|||
) : TimelineItemEventContent {
|
||||
override val type: String = "TimelineItemStickerContent"
|
||||
|
||||
val preferredMediaSource = if (mimeType == MimeTypes.Gif) {
|
||||
mediaSource
|
||||
} else {
|
||||
thumbnailSource ?: mediaSource
|
||||
}
|
||||
/* Stickers are supposed to be small images so
|
||||
we allow using the mediaSource (unless the url is empty) */
|
||||
val preferredMediaSource = if (mediaSource.url.isEmpty()) thumbnailSource else mediaSource
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue