From f970cef325d94335b13240941c95a12c58f9ccb3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 6 Nov 2020 00:06:39 +0100 Subject: Do not show duplicate notifications for additional messages sync --- src/plugins/Matrix.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/plugins/Matrix.cpp') diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index b99aa02..86dfb3e 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -1301,7 +1301,7 @@ namespace QuickMedia { // TODO: Use /_matrix/client/r0/notifications ? or remove this and always look for displayname/user_id in messages bool has_unread_notifications = false; const rapidjson::Value &unread_notification_json = GetMember(it.value, "unread_notifications"); - if(unread_notification_json.IsObject() && is_initial_sync_finished()) { + if(unread_notification_json.IsObject() && is_initial_sync_finished() && !is_additional_messages_sync) { const rapidjson::Value &highlight_count_json = GetMember(unread_notification_json, "highlight_count"); if(highlight_count_json.IsNumber() && highlight_count_json.GetInt64() > 0) { room->unread_notification_count = highlight_count_json.GetInt64(); @@ -1644,7 +1644,7 @@ namespace QuickMedia { room_data->append_messages(new_messages); } - if(is_initial_sync_finished()) { + if(has_unread_notifications) { time_t read_marker_message_timestamp = 0; if(me) { auto read_marker_message = room_data->get_message_by_id(room_data->get_user_read_marker(me)); @@ -1655,7 +1655,7 @@ namespace QuickMedia { for(auto &message : new_messages) { // TODO: Is @room ok? shouldn't we also check if the user has permission to do @room? (only when notifications are limited to @mentions) // TODO: Is comparing against read marker timestamp ok enough? - if(has_unread_notifications && me && message->timestamp > read_marker_message_timestamp) + if(me && message->timestamp > read_marker_message_timestamp) message->mentions_me = message_contains_user_mention(message->body, me->display_name) || message_contains_user_mention(message->body, me->user_id) || message_contains_user_mention(message->body, "@room"); } } -- cgit v1.2.3