aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Matrix.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 1e8ee99..65e29a3 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -724,22 +724,34 @@ namespace QuickMedia {
Body *chat_body = chat_page ? chat_page->chat_body : nullptr;
bool set_room_as_unread = !is_window_focused || room != current_room || (!chat_body || chat_body->is_bottom_cut_off()) || (chat_page && !chat_page->messages_tab_visible);
+ bool unread_mentions = false;
std::string room_desc;
- if(set_room_as_unread)
- room_desc += "Unread: ";
- if(last_unread_message)
- room_desc += extract_first_line_remove_newline_elipses(matrix->message_get_author_displayname(last_unread_message), AUTHOR_MAX_LENGTH) + ": " + message_to_room_description_text(matrix, last_unread_message, custom_emoji_max_size);
-
- int unread_notification_count = room->unread_notification_count;
+ const int unread_notification_count = room->unread_notification_count;
if(unread_notification_count > 0 && set_room_as_unread) {
- if(!room_desc.empty())
- room_desc += '\n';
+ unread_mentions = true;
room_desc += "** " + std::to_string(unread_notification_count) + " unread mention(s) **"; // TODO: Better notification?
room->body_item->set_description_color(get_theme().attention_alert_text_color, true);
} else {
room->body_item->set_description_color(get_theme().faded_text_color);
}
+
+ if(last_unread_message) {
+ if(!room_desc.empty())
+ room_desc += '\n';
+ }
+
+ if(!unread_mentions && set_room_as_unread)
+ room_desc += "Unread: ";
+
+ if(last_unread_message) {
+ room->latest_message = extract_first_line_remove_newline_elipses(matrix->message_get_author_displayname(last_unread_message), AUTHOR_MAX_LENGTH) + ": " + message_to_room_description_text(matrix, last_unread_message, custom_emoji_max_size);
+ } else {
+ room->latest_message.clear();
+ }
+
+ room_desc += room->latest_message;
+
room->body_item->set_description(std::move(room_desc));
room->body_item->set_description_max_lines(3);
if(set_room_as_unread)
@@ -752,6 +764,7 @@ namespace QuickMedia {
room->body_item->set_description(extract_first_line_remove_newline_elipses(matrix->message_get_author_displayname(last_new_message.get()), AUTHOR_MAX_LENGTH) + ": " + message_to_room_description_text(matrix, last_new_message.get(), custom_emoji_max_size));
room->body_item->set_description_color(get_theme().faded_text_color);
room->body_item->set_description_max_lines(3);
+ room->latest_message = room->body_item->get_description();
rooms_page->move_room_to_top(room);
room_tags_page->move_room_to_top(room);