From 80c9459f878ea108fec83a0af6754c5e27e26b23 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 5 Nov 2020 18:10:35 +0100 Subject: Fucking annoying shit --- src/QuickMedia.cpp | 14 ++++++++++---- src/plugins/Matrix.cpp | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 937510c..3867237 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -982,8 +982,14 @@ namespace QuickMedia { after_submit_handler(); if(tabs[selected_tab].page->clear_search_after_submit() && tabs[selected_tab].search_bar) { - tabs[selected_tab].search_bar->clear(); - tabs[selected_tab].search_bar->onTextUpdateCallback(""); + if(!tabs[selected_tab].search_bar->get_text().empty()) { + tabs[selected_tab].search_bar->clear(); + tabs[selected_tab].search_bar->onTextUpdateCallback(""); + } else { + int selected_item_index = tabs[selected_tab].body->get_selected_item(); + tabs[selected_tab].body->select_first_item(); + tabs[selected_tab].body->set_selected_item(selected_item_index, false); + } } if(tabs[selected_tab].page->is_single_page()) { @@ -3484,9 +3490,9 @@ namespace QuickMedia { bool fetched_enough_messages = false; bool initial_prev_messages_fetch = true; - auto fetch_more_previous_messages_if_needed = [this, &all_messages, ¤t_room, &fetched_enough_messages, &previous_messages_future]() { + auto fetch_more_previous_messages_if_needed = [this, &all_messages, ¤t_room, &fetched_enough_messages, &previous_messages_future, &initial_prev_messages_fetch]() { if(!fetched_enough_messages && !previous_messages_future.ready()) { - bool fetch_latest_messages = !matrix->is_initial_sync_finished(); + bool fetch_latest_messages = !matrix->is_initial_sync_finished() && initial_prev_messages_fetch; if(all_messages.size() < 10) { previous_messages_future = [this, ¤t_room, fetch_latest_messages]() { Messages messages; diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 50296a8..b99aa02 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -469,7 +469,7 @@ namespace QuickMedia { void MatrixRoomsPage::on_navigate_to_page(Body *body) { if(search_bar) body->filter_search_fuzzy(search_bar->get_text()); - sort_room_body_items(body->items); + //sort_room_body_items(body->items); } void MatrixRoomsPage::update() { @@ -521,7 +521,7 @@ namespace QuickMedia { // Swap order of rooms in body list to put rooms with mentions at the top and then unread messages and then all the other rooms // TODO: Optimize with hash map instead of linear search? or cache the index std::lock_guard lock(mutex); -#if 0 +#if 1 BodyItem *room_body_item = static_cast(room->userdata); int room_body_index = body->get_index_by_body_item(room_body_item); if(room_body_index != -1) { -- cgit v1.2.3