From 43f21b54ff2ff80ed1d480b07116ba0cfa0b5e47 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 9 Feb 2021 12:34:00 +0100 Subject: Matrix: dont change seleection, or something --- src/QuickMedia.cpp | 1 - src/plugins/Matrix.cpp | 13 +++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 5d4f7bd..6970920 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1114,7 +1114,6 @@ namespace QuickMedia { } else if(new_tabs.size() == 1 && new_tabs[0].page->get_type() == PageTypez::CHAT) { current_page = PageType::CHAT; current_chat_room = matrix->get_room_by_id(selected_item->url); - tabs[selected_tab].body->select_first_item(); while(window.isOpen()) { bool move_room = chat_page(static_cast(new_tabs[0].page.get()), current_chat_room, tabs, selected_tab, tab_associated_data[selected_tab]); if(!move_room) diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index b16b551..4133637 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -433,6 +433,15 @@ namespace QuickMedia { }); } + static void body_set_selected_item(Body *body, BodyItem *selected_item) { + for(size_t i = 0; i < body->items.size(); ++i) { + if(body->items[i]->url == selected_item->url) { + body->set_selected_item(i); + return; + } + } + } + void MatrixQuickMedia::update(MatrixPageType page_type) { update_pending_room_messages(page_type); std::lock_guard room_body_lock(room_body_items_mutex); @@ -625,7 +634,9 @@ namespace QuickMedia { } if(sort_on_update) { sort_on_update = false; + BodyItem *selected_item = body->get_selected(); sort_room_body_items(body->items); + body_set_selected_item(body, selected_item); } matrix_delegate->update(MatrixPageType::ROOM_LIST); if(filter_on_update) { @@ -697,7 +708,9 @@ namespace QuickMedia { Body *body_ptr = body.get(); TagData &tag_data = tag_body_items_by_name[url]; body->items = tag_data.room_body_items; + BodyItem *selected_item = body->get_selected(); sort_room_body_items(body->items); + body_set_selected_item(body.get(), selected_item); auto search_bar = create_search_bar("Search...", SEARCH_DELAY_FILTER); auto rooms_page = std::make_unique(program, body_ptr, tag_data.tag_item->get_title(), this, search_bar.get()); rooms_page->matrix_delegate = matrix_delegate; -- cgit v1.2.3