Fix cached thumbnails extensions

This commit is contained in:
miruka 2020-03-09 12:06:58 -04:00
parent 7ee83c5fe4
commit 46f3f15694
6 changed files with 21 additions and 2 deletions

View File

@ -2,7 +2,7 @@
## Before release
- Downloaded media filenames
- Fix highlighted account/room in MainPane
- "exception during sync" aren't caught
- nio ClientTimeout
- Name
@ -153,6 +153,8 @@
## Backend
- Have a `Thubmnail.from_existing_file()` to be called after generating and
and uploading a thumbnail, like the equivalent `Media.from_existing_file()`
- Saving the room settings
- Refetch profile after manual profile change, don't wait for a room event

View File

@ -553,6 +553,8 @@ class MatrixClient(nio.AsyncClient):
content["info"].get("thumbnail_info", {}).get("w", 0),
thumbnail_height =
content["info"].get("thumbnail_info", {}).get("h", 0),
thumbnail_mime =
content["info"].get("thumbnail_info", {}).get("mimetype", ""),
)
await self._send_message(room_id, content)

View File

@ -197,6 +197,7 @@ class Event(ModelItem):
media_crypt_dict: Dict[str, Any] = field(default_factory=dict)
thumbnail_url: str = ""
thumbnail_mime: str = ""
thumbnail_width: int = 0
thumbnail_height: int = 0
thumbnail_crypt_dict: Dict[str, Any] = field(default_factory=dict)

View File

@ -140,6 +140,7 @@ class NioCallbacks:
thumbnail_width = thumb_info.get("w") or 0,
thumbnail_height = thumb_info.get("h") or 0,
thumbnail_mime = thumb_info.get("mimetype") or "",
thumbnail_crypt_dict = thumb_crypt_dict,
)

View File

@ -9,7 +9,7 @@ HMxcImage {
height: fitSize.height
horizontalAlignment: Image.AlignLeft
title: loader.title
title: thumbnail ? loader.thumbnailTitle : loader.title
animated: loader.singleMediaInfo.media_mime === "image/gif" ||
utils.urlExtension(loader.mediaUrl).toLowerCase() === "gif"
thumbnail: ! animated && loader.thumbnailMxc

View File

@ -31,6 +31,19 @@ HLoader {
readonly property string title:
singleMediaInfo.media_title || utils.urlFileName(mediaUrl)
readonly property string thumbnailTitle:
singleMediaInfo.media_title.replace(
/\.[^\.]+$/,
singleMediaInfo.thumbnail_mime === "image/jpeg" ? ".jpg" :
singleMediaInfo.thumbnail_mime === "image/png" ? ".png" :
singleMediaInfo.thumbnail_mime === "image/gif" ? ".gif" :
singleMediaInfo.thumbnail_mime === "image/tiff" ? ".tiff" :
singleMediaInfo.thumbnail_mime === "image/svg+xml" ? ".svg" :
singleMediaInfo.thumbnail_mime === "image/webp" ? ".webp" :
singleMediaInfo.thumbnail_mime === "image/bmp" ? ".bmp" :
".thumbnail"
) || utils.urlFileName(mediaUrl)
readonly property var imageExtensions: [
"bmp", "gif", "jpg", "jpeg", "png", "pbm", "pgm", "ppm", "xbm", "xpm",
"tiff", "webp", "svg",