From 12cdc09759edf506fbafe051895343b20a67798c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 17 Oct 2020 18:56:44 +0200 Subject: Matrix: make text that mentions us red --- src/plugins/Matrix.cpp | 7 ++++--- src/plugins/NyaaSi.cpp | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index ea5f86c..f9bfe30 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -415,7 +415,7 @@ namespace QuickMedia { } // TODO: Do not show notification if mention is a reply to somebody else that replies to me? also dont show notification everytime a mention is edited - static bool message_contains_user_mention(const std::string &msg, const std::string &username) { + bool message_contains_user_mention(const std::string &msg, const std::string &username) { if(msg.empty()) return false; @@ -447,6 +447,7 @@ namespace QuickMedia { return; std::vector> new_messages; + auto me = get_me(room_data); for(const rapidjson::Value &event_item_json : events_json.GetArray()) { std::shared_ptr new_message = parse_message_event(event_item_json, room_data.get()); @@ -454,8 +455,8 @@ namespace QuickMedia { continue; // TODO: Is @room ok? shouldn't we also check if the user has permission to do @room? (only when notifications are limited to @mentions) - if(has_unread_notifications && !username.empty()) - new_message->mentions_me = message_contains_user_mention(new_message->body, username) || message_contains_user_mention(new_message->body, "@room"); + if(has_unread_notifications && me) + new_message->mentions_me = message_contains_user_mention(new_message->body, me->display_name) || message_contains_user_mention(new_message->body, "@room"); new_messages.push_back(std::move(new_message)); } diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp index 8d0679e..dc6e19f 100644 --- a/src/plugins/NyaaSi.cpp +++ b/src/plugins/NyaaSi.cpp @@ -170,9 +170,9 @@ namespace QuickMedia { body_item->set_description(std::move(description)); body_item->url = "https://nyaa.si" + std::move(view_url); if(is_trusted) - body_item->title_color = sf::Color(43, 255, 47); + body_item->set_title_color(sf::Color(43, 255, 47)); else if(is_remake) - body_item->title_color = sf::Color(255, 45, 47); + body_item->set_title_color(sf::Color(255, 45, 47)); result_items.push_back(std::move(body_item)); } -- cgit v1.2.3