From e7f82bda1534880bf4c6695b9f074241dfc56ac3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 18 Nov 2020 11:23:52 +0100 Subject: Matrix: fix read marker if the last message is a redact or edit --- TODO | 1 - src/QuickMedia.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 82b04a9..7291a6e 100644 --- a/TODO +++ b/TODO @@ -125,7 +125,6 @@ Implement m.room.tombstone. Show a marker when a room uses encryption. Remove replied-to message text in room preview. That shows ignored users text and we want to see the reply message instead anyways. Update room name/avatar with new data in /sync. -Read marker is incorrect if the last message is an edit/redact, because they are hidden and replaces other body items instead. Scroll tabs if there are more than 3 tab items and show arrow on left/right side when there are more items to see. Make a shader for Text for changing color instead of updating the text geometry. Or loop vertices and set their color to the new color without updating the text geometry. Automatically retry sending messages that fails to send (after timeout). These failed to send messages should be stored on disk and retried when going back to the room or restarting QuickMedia. diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 7cface4..20c2371 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3516,6 +3516,11 @@ namespace QuickMedia { auto body_item_shared_ptr = tabs[MESSAGES_TAB_INDEX].body->items[body_item_index]; body_item_shared_ptr->set_description(text); body_item_shared_ptr->set_description_color(provisional_message_color); + + auto edit_body_item = message_to_body_item(current_room, message.get(), current_room->get_user_avatar_url(me), me->user_id); + edit_body_item->visible = false; + tabs[MESSAGES_TAB_INDEX].body->insert_items_by_timestamps({edit_body_item}); + //unreferenced_events.push_back(message); post_task_queue.push([this, ¤t_room, text, related_to_message, message, body_item_shared_ptr]() { ProvisionalMessage provisional_message; @@ -4549,6 +4554,8 @@ namespace QuickMedia { if(selected_tab == MESSAGES_TAB_INDEX && current_room && matrix->is_initial_sync_finished()) { BodyItem *last_visible_item = tabs[selected_tab].body->get_last_fully_visible_item(); + if(last_visible_item && tabs[selected_tab].body->is_last_item_fully_visible() && !tabs[selected_tab].body->items.empty()) + last_visible_item = tabs[selected_tab].body->items.back().get(); if(is_window_focused && chat_state != ChatState::URL_SELECTION && current_room && last_visible_item && !setting_read_marker && read_marker_timer.getElapsedTime().asMilliseconds() >= read_marker_timeout_ms) { Message *message = (Message*)last_visible_item->userdata; // TODO: What if two messages have the same timestamp? -- cgit v1.2.3