From 0009006c39ce4bfebc3c5260b83063c800cb4fdf Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 15 Aug 2021 11:39:51 +0200 Subject: Matrix: use white avatar for users with no avatar, optimize notifications update --- src/QuickMedia.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/QuickMedia.cpp') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index a45da87..6a37b1d 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3124,6 +3124,8 @@ namespace QuickMedia { } AsyncImageLoader::get_instance().update(); + if(matrix) + matrix->update(); if(!video_loaded) { window.clear(get_current_theme().background_color); @@ -4528,6 +4530,10 @@ namespace QuickMedia { body_item->thumbnail_size = message->thumbnail_size; } else { body_item->thumbnail_url = room->get_user_avatar_url(message->user); + if(body_item->thumbnail_url.empty()) { + body_item->thumbnail_url = get_resource_loader_root_path() + std::string("images/no_avatar.png"); + body_item->thumbnail_is_local = true; + } body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; // if construct is not configured to use ImageMagic then it wont give thumbnails of size 32x32 even when requested and the spec says that the server SHOULD do that body_item->thumbnail_size = AVATAR_THUMBNAIL_SIZE; @@ -4602,6 +4608,10 @@ namespace QuickMedia { if(!is_visual_media_message_type(message->type)) { body_item->thumbnail_url = room->get_user_avatar_url(message->user); + if(body_item->thumbnail_url.empty()) { + body_item->thumbnail_url = get_resource_loader_root_path() + std::string("images/no_avatar.png"); + body_item->thumbnail_is_local = true; + } body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; // if construct is not configured to use ImageMagic then it wont give thumbnails of size 32x32 even when requested and the spec says that the server SHOULD do that body_item->thumbnail_size = AVATAR_THUMBNAIL_SIZE; @@ -4765,6 +4775,10 @@ namespace QuickMedia { Message *original_message = static_cast(body_item->userdata); if(original_message && !is_system_message_type(original_message->type)) { body_item->thumbnail_url = current_room->get_user_avatar_url(original_message->user); + if(body_item->thumbnail_url.empty()) { + body_item->thumbnail_url = get_resource_loader_root_path() + std::string("images/no_avatar.png"); + body_item->thumbnail_is_local = true; + } body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; } body_item->set_description("Message deleted"); @@ -5200,7 +5214,7 @@ namespace QuickMedia { msgtype = "m.reaction"; text.erase(text.begin(), text.begin() + 7); } else { - show_notification("QuickMedia", "Error: invalid command: " + text + ", expected /upload, /join [room], /invite, /logout, /me [text] or /react [text]", Urgency::NORMAL); + show_notification("QuickMedia", "Error: invalid command: " + text + ", expected /upload, /join [room], /invite, /logout, /leave, /me [text] or /react [text]", Urgency::NORMAL); return false; } } else if(chat_state == ChatState::REPLYING && text[0] == '/') { @@ -6477,14 +6491,12 @@ namespace QuickMedia { // TODO: Maybe set this instead when the mention is visible on the screen? current_room->unread_notification_count = 0; - matrix_chat_page->set_room_as_read(current_room); - Message *read_message = static_cast(body_items[last_timeline_message]->userdata); if(read_message->replaced_by) read_message = read_message->replaced_by.get(); // TODO: What if two messages have the same timestamp? if(!read_message->event_id.empty() && read_message->timestamp > current_room->last_read_message_timestamp) { - //read_marker_timeout_ms = read_marker_timeout_ms_default; + matrix_chat_page->set_room_as_read(current_room); current_room->last_read_message_timestamp = read_message->timestamp; // TODO: What if the message is no longer valid? setting_read_marker = true; -- cgit v1.2.3