aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--src/QuickMedia.cpp2
-rw-r--r--src/plugins/Matrix.cpp22
3 files changed, 14 insertions, 12 deletions
diff --git a/TODO b/TODO
index 8416a8a..e2005b8 100644
--- a/TODO
+++ b/TODO
@@ -85,4 +85,4 @@ Update 4chan thread in real time, just like 4chan-x.
Save the original event message, so when replying for example we can use the original message as the replying to message, rather than our converted "body" text.
Remove tidy dependency and use my own html-parser.
Add option to sort by other than timestamp for nyaa.si.
-Only have one page, and the plugin should have tabs and action after each tab action and use a stack for navigation. \ No newline at end of file
+Add url preview for matrix (using matrix api, fallback to client url preview (using our own url preview project)). \ No newline at end of file
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 01bef82..2607873 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1883,7 +1883,6 @@ namespace QuickMedia {
}
}
- // TODO: This code is duplicated in many places. Handle it in one place.
if(redraw) {
redraw = false;
search_bar->onWindowResize(window_size);
@@ -2459,7 +2458,6 @@ namespace QuickMedia {
}
}
- // TODO: This code is duplicated in many places. Handle it in one place.
if(redraw) {
redraw = false;
search_bar->onWindowResize(window_size);
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 8189806..69c2686 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -331,30 +331,34 @@ namespace QuickMedia {
if(!membership_json.isString() || strcmp(membership_json.asCString(), "join") != 0)
continue;
+ std::string avatar_url_str;
const Json::Value &avatar_url_json = content_json["avatar_url"];
- if(!avatar_url_json.isString())
- continue;
+ if(avatar_url_json.isString())
+ avatar_url_str = avatar_url_json.asString();
const Json::Value &display_name_json = content_json["displayname"];
if(!display_name_json.isString())
continue;
-
+
std::string sender_json_str = sender_json.asString();
- auto user_it = room_data->user_info_by_user_id.find(sender_json_str);
- if(user_it != room_data->user_info_by_user_id.end())
- continue;
UserInfo user_info;
user_info.user_id = sender_json_str;
- user_info.avatar_url = avatar_url_json.asString();
+ 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";
user_info.display_name = display_name_json.asString();
user_info.display_name_color = user_id_to_color(sender_json_str);
- room_data->user_info.push_back(user_info);
- room_data->user_info_by_user_id.insert(std::make_pair(sender_json_str, room_data->user_info.size() - 1));
+
+ auto user_it = room_data->user_info_by_user_id.find(sender_json_str);
+ if(user_it != room_data->user_info_by_user_id.end()) {
+ room_data->user_info[user_it->second] = std::move(user_info);
+ } else {
+ room_data->user_info.push_back(user_info);
+ room_data->user_info_by_user_id.insert(std::make_pair(sender_json_str, room_data->user_info.size() - 1));
+ }
}
}