aboutsummaryrefslogtreecommitdiff
path: root/src/AsyncImageLoader.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-12-16 21:13:38 +0100
committerdec05eba <dec05eba@protonmail.com>2022-12-16 21:47:06 +0100
commit442fc29582b5581111e3ffd286f4f3d282877f3c (patch)
treecfcc2a18381bded582f1054ac8072d448b523edf /src/AsyncImageLoader.cpp
parente47a34f3c4d9f892c002d0dce7fb43a3ca1b4f28 (diff)
Fix bug where image are not removed from loading when not visible
Matrix: fix invites not showing notification
Diffstat (limited to 'src/AsyncImageLoader.cpp')
-rw-r--r--src/AsyncImageLoader.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/AsyncImageLoader.cpp b/src/AsyncImageLoader.cpp
index 4021c55..8613cf9 100644
--- a/src/AsyncImageLoader.cpp
+++ b/src/AsyncImageLoader.cpp
@@ -312,15 +312,19 @@ namespace QuickMedia {
}
std::shared_ptr<ThumbnailData> AsyncImageLoader::get_thumbnail(const std::string &url, bool local, mgl::vec2i resize_target_size) {
- // TODO: Instead of generating a new hash everytime to access thumbnail, cache the hash of the thumbnail url
- auto &thumbnail_data = thumbnails[url + "_" + std::to_string(resize_target_size.x) + "x" + std::to_string(resize_target_size.y)];
- if(!thumbnail_data)
+ // TODO: Instead of generating a new hash everytime to access thumbnail, cache the hash of the thumbnail url.
+ // TODO: Cache this resize_url
+ std::string resize_url = url + "_" + std::to_string(resize_target_size.x) + "x" + std::to_string(resize_target_size.y);
+ auto &thumbnail_data = thumbnails[resize_url];
+ if(!thumbnail_data) {
thumbnail_data = std::make_shared<ThumbnailData>();
+ thumbnail_data->url = url;
+ }
thumbnail_data->counter = counter;
if(thumbnail_data->thumbnail_path.data.empty()) {
SHA256 sha256;
- sha256.add(url.data(), url.size());
+ sha256.add(resize_url.data(), resize_url.size());
thumbnail_data->thumbnail_path = get_cache_dir().join("thumbnails").join(sha256.getHash());
}
@@ -358,7 +362,7 @@ namespace QuickMedia {
if(download.read_program.pid == -1)
continue;
- if(download.url == it->first) {
+ if(download.url == it->second->url) {
reset_download(download);
break;
}
@@ -366,7 +370,7 @@ namespace QuickMedia {
}
image_thumbnail_create_queue.erase_if([&it](ThumbnailLoadData &load_data) {
- return load_data.path.data == it->first;
+ return load_data.path.data == it->second->url;
});
it = thumbnails.erase(it);