Fix URL preview thumbnail GIFs not being animated

This commit is contained in:
miruka 2020-09-02 11:37:51 -04:00
parent 519eaa2ca0
commit 377f1ffd4a
3 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,7 @@
# TODO # TODO
- Fix right margin of own `<image url>\n<image url>` messages
- handle invalid access token - handle invalid access token
- If an account is gone from the user's config, discard UI state last page - If an account is gone from the user's config, discard UI state last page
- filter > enter > room list is always scrolled to top - filter > enter > room list is always scrolled to top

View File

@ -64,7 +64,7 @@ HMxcImage {
clientUserId: chat.userId clientUserId: chat.userId
title: thumbnail ? loader.thumbnailTitle : loader.title title: thumbnail ? loader.thumbnailTitle : loader.title
animated: eventList.isAnimated(loader.singleMediaInfo) animated: eventList.isAnimated(loader.singleMediaInfo, loader.mediaUrl)
thumbnail: ! animated && loader.thumbnailMxc thumbnail: ! animated && loader.thumbnailMxc
mxc: thumbnail ? mxc: thumbnail ?
(loader.thumbnailMxc || loader.mediaUrl) : (loader.thumbnailMxc || loader.mediaUrl) :

View File

@ -395,10 +395,13 @@ Rectangle {
) )
} }
function isAnimated(event) { function isAnimated(event, forLink="") {
const link = forLink || event.media_url
print(forLink, "-", link)
return ( return (
event.media_mime === "image/gif" || event.media_mime === "image/gif" ||
utils.urlExtension(event.media_url).toLowerCase() === "gif" utils.urlExtension(link).toLowerCase() === "gif"
) )
} }
@ -425,7 +428,7 @@ Rectangle {
// The thumbnail/cached path will be the full GIF // The thumbnail/cached path will be the full GIF
const fullMxc = const fullMxc =
forLink || (isAnimated(event) ? "" : event.media_url) forLink || (isAnimated(event, forLink) ? "" : event.media_url)
window.makePopup( window.makePopup(
"Popups/ImageViewerPopup/ImageViewerPopup.qml", "Popups/ImageViewerPopup/ImageViewerPopup.qml",