aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-03 22:35:02 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-03 22:35:02 +0200
commit8a21f2d4f70ecd4509aa8976c5e40ee70395a6a0 (patch)
treef6919c2533cf0e936b741b363f4facf6b1d0e2a1
parentdf8cbfada237cb4c0467215b55ccb697cc64d568 (diff)
Matrix: do not set avatar url for users with no avatar
-rw-r--r--TODO3
-rw-r--r--src/QuickMedia.cpp6
-rw-r--r--src/plugins/Matrix.cpp4
3 files changed, 7 insertions, 6 deletions
diff --git a/TODO b/TODO
index 7df55ec..c5ca1d1 100644
--- a/TODO
+++ b/TODO
@@ -87,4 +87,5 @@ Remove tidy dependency and use my own html-parser.
Add option to sort by other than timestamp for nyaa.si.
Add url preview for matrix (using matrix api, fallback to client url preview (using our own url preview project)).
Cleanup old messages in matrix (from matrix plugin), and instead either save them to disk or refetch them from server when going up to read old messages.
-Use memberName() instead of key() when iterating json object. key() creates a copy, memberName() doesn't. \ No newline at end of file
+Use memberName() instead of key() when iterating json object. key() creates a copy, memberName() doesn't.
+Do not try to reload/redownload thumbnail that fails to download after its cleared when its no longer visible on screen and then becomes visible. \ No newline at end of file
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index ca3cedb..6c3bc34 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1945,9 +1945,9 @@ namespace QuickMedia {
image_path.join(std::to_string(image_index + 1));
if(get_file_type(image_path) == FileType::REGULAR) {
- std::string image_data;
- if(file_get_content(image_path, image_data) == 0) {
- if(image_texture.loadFromMemory(image_data.data(), image_data.size())) {
+ sf::Image image;
+ if(image.loadFromFile(image_path.data)) {
+ if(image_texture.loadFromImage(image)) {
image_texture.setSmooth(true);
//image_texture.generateMipmap();
return LoadImageResult::OK;
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 8ef7f47..d4fdd03 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -411,8 +411,8 @@ namespace QuickMedia {
user_info->avatar_url = std::move(avatar_url_str);
if(strncmp(user_info->avatar_url.c_str(), "mxc://", 6) == 0)
user_info->avatar_url.erase(user_info->avatar_url.begin(), user_info->avatar_url.begin() + 6);
- // TODO: What if the user hasn't selected an avatar?
- user_info->avatar_url = homeserver + "/_matrix/media/r0/thumbnail/" + user_info->avatar_url + "?width=32&height=32&method=crop";
+ if(!user_info->avatar_url.empty())
+ user_info->avatar_url = homeserver + "/_matrix/media/r0/thumbnail/" + user_info->avatar_url + "?width=32&height=32&method=crop";
user_info->display_name = display_name_json.asString();
user_info->display_name_color = user_id_to_color(sender_json_str);