diff options
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r-- | src/QuickMedia.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 4de65d2..8d4dffb 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -4232,8 +4232,10 @@ namespace QuickMedia { }); }; + Message *last_visible_timeline_message = nullptr; + // TODO: How about instead fetching all messages we have, not only the visible ones? also fetch with multiple threads. - tabs[MESSAGES_TAB_INDEX].body->body_item_render_callback = [this, ¤t_room, &me, &fetch_message_future, &tabs, &fetch_body_item, &fetch_message_tab, MESSAGES_TAB_INDEX](BodyItem *body_item) { + tabs[MESSAGES_TAB_INDEX].body->body_item_render_callback = [this, ¤t_room, &me, &last_visible_timeline_message, &fetch_message_future, &tabs, &fetch_body_item, &fetch_message_tab, MESSAGES_TAB_INDEX](BodyItem *body_item) { Message *message = static_cast<Message*>(body_item->userdata); if(!message) return; @@ -4253,6 +4255,9 @@ namespace QuickMedia { } #endif + if(message_is_timeline(message) && (!last_visible_timeline_message || message->timestamp > last_visible_timeline_message->timestamp)) + last_visible_timeline_message = message; + if(message->related_event_id.empty() || (body_item->embedded_item_status != FetchStatus::NONE && body_item->embedded_item_status != FetchStatus::QUEUED_LOADING)) return; @@ -5174,9 +5179,7 @@ namespace QuickMedia { } if(selected_tab == MESSAGES_TAB_INDEX && current_room && current_room->body_item && !current_room->last_message_read && matrix->is_initial_sync_finished()) { - BodyItem *last_visible_item = tabs[selected_tab].body->get_last_visible_item(); - Message *last_visible_item_message = static_cast<Message*>(last_visible_item->userdata); - if(last_visible_item && last_visible_item_message && tabs[selected_tab].body->is_last_item_fully_visible() && message_is_timeline(last_visible_item_message) && is_window_focused && chat_state != ChatState::URL_SELECTION && !setting_read_marker && read_marker_timer.getElapsedTime().asMilliseconds() >= read_marker_timeout_ms) { + if(last_visible_timeline_message && tabs[selected_tab].body->is_last_item_fully_visible() && is_window_focused && chat_state != ChatState::URL_SELECTION && !setting_read_marker && read_marker_timer.getElapsedTime().asMilliseconds() >= read_marker_timeout_ms) { std::string room_desc = current_room->body_item->get_description(); if(strncmp(room_desc.c_str(), "Unread: ", 8) == 0) room_desc = room_desc.substr(8); @@ -5195,7 +5198,7 @@ namespace QuickMedia { // TODO: Maybe set this instead when the mention is visible on the screen? current_room->unread_notification_count = 0; - Message *read_message = last_visible_item_message; + Message *read_message = last_visible_timeline_message; if(read_message->replaced_by) read_message = read_message->replaced_by.get(); // TODO: What if two messages have the same timestamp? |