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/plugins/Matrix.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/plugins') 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