diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-01-25 00:27:52 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-01-25 00:27:52 +0100 |
commit | 82d4273e445b85e15fe12caaa52c301fa77aaa6c (patch) | |
tree | 3420ee2dbba9c294ce4770927f5aeeef91bb98c3 /src | |
parent | 6a6d55fa1ba3797fb854ed2335129917f58c9d6a (diff) |
Matrix: edited message replies to user should still be red... and join event more blalbalba whatever
Diffstat (limited to 'src')
-rw-r--r-- | src/QuickMedia.cpp | 7 | ||||
-rw-r--r-- | src/plugins/Matrix.cpp | 10 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 4cf4b09..41c2c6e 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3231,6 +3231,7 @@ namespace QuickMedia { body_item->set_description("Message deleted"); body_item->set_description_color(sf::Color::White); body_item->thumbnail_size = sf::Vector2i(32, 32); + body_item->url.clear(); }; // TODO: Optimize with hash map? @@ -3251,8 +3252,9 @@ namespace QuickMedia { if(message->related_event_type == RelatedEventType::REDACTION) { set_body_as_deleted(message.get(), body_item.get()); } else { + Message *orig_message = static_cast<Message*>(body_item->userdata); body_item->set_description(message_get_body_remove_formatting(message.get())); - if(message_contains_user_mention(message->body, my_display_name) || message_contains_user_mention(message->body, me->user_id)) + if(message_contains_user_mention(message->body, my_display_name) || message_contains_user_mention(message->body, me->user_id) || (orig_message && orig_message->user == me)) body_item->set_description_color(sf::Color(255, 100, 100)); else body_item->set_description_color(sf::Color::White); @@ -3285,8 +3287,9 @@ namespace QuickMedia { if(message->related_event_type == RelatedEventType::REDACTION) { set_body_as_deleted(message.get(), body_item.get()); } else { + Message *orig_message = static_cast<Message*>(body_item->userdata); body_item->set_description(message_get_body_remove_formatting(message.get())); - if(message_contains_user_mention(message->body, my_display_name) || message_contains_user_mention(message->body, me->user_id)) + if(message_contains_user_mention(message->body, my_display_name) || message_contains_user_mention(message->body, me->user_id) || (orig_message && orig_message->user == me)) body_item->set_description_color(sf::Color(255, 100, 100)); else body_item->set_description_color(sf::Color::White); diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 4ed6409..ba8533b 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -1866,7 +1866,7 @@ namespace QuickMedia { const rapidjson::Value &prev_membership_json = GetMember(prev_content_json, "membership"); if(prev_membership_json.IsString() && strcmp(prev_membership_json.GetString(), "leave") == 0) { body = user_display_name + " joined the room"; - } else if(new_displayname_json.IsString() && (!prev_displayname_json.IsString() || strcmp(new_displayname_json.GetString(), prev_displayname_json.GetString()) != 0)) { + } else if(new_displayname_json.IsString() && new_displayname_json.GetStringLength() > 0 && (!prev_displayname_json.IsString() || strcmp(new_displayname_json.GetString(), prev_displayname_json.GetString()) != 0)) { std::string new_displayname_str = std::string(new_displayname_json.GetString()); std::string prev_displayname_str; if(prev_displayname_json.IsString()) @@ -1875,17 +1875,17 @@ namespace QuickMedia { prev_displayname_str = sender_json_str; body = prev_displayname_str + " changed their display name to " + new_displayname_str; room_data->set_user_display_name(user, std::move(new_displayname_str)); - } else if(!new_displayname_json.IsString() && prev_displayname_json.IsString()) { + } else if((!new_displayname_json.IsString() || new_displayname_json.GetStringLength() == 0) && prev_displayname_json.IsString()) { body = user_display_name + " removed their display name"; room_data->set_user_display_name(user, ""); - } else if(new_avatar_url_json.IsString() && (!prev_avatar_url_json.IsString() || strcmp(new_avatar_url_json.GetString(), prev_avatar_url_json.GetString()) != 0)) { + } else if(new_avatar_url_json.IsString() && new_avatar_url_json.GetStringLength() > 0 && (!prev_avatar_url_json.IsString() || strcmp(new_avatar_url_json.GetString(), prev_avatar_url_json.GetString()) != 0)) { body = user_display_name + " changed their profile picture"; std::string new_avatar_url_str = thumbnail_url_extract_media_id(new_avatar_url_json.GetString()); if(!new_avatar_url_str.empty()) new_avatar_url_str = homeserver + "/_matrix/media/r0/thumbnail/" + new_avatar_url_str + "?width=32&height=32&method=crop"; // TODO: Remove the constant strings around to reduce memory usage (6.3mb) room_data->set_user_avatar_url(user, std::move(new_avatar_url_str)); - } else if(!new_avatar_url_json.IsString() && prev_avatar_url_json.IsString()) { - body = user_display_name + " removed their profile picture."; + } else if((!new_avatar_url_json.IsString() || new_avatar_url_json.GetStringLength() == 0) && prev_avatar_url_json.IsString()) { + body = user_display_name + " removed their profile picture"; room_data->set_user_avatar_url(user, ""); } else { body = user_display_name + " joined the room"; |