aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-11-05 16:46:06 +0100
committerdec05eba <dec05eba@protonmail.com>2020-11-05 16:46:06 +0100
commita90f4e0b27ead8dc609522d772d6ede250b258dd (patch)
treedd84c4d9f75966997908dcf15f05adc35e867f1c
parentaa4ff4cc74e7c654df8e399d4aae4cb8aa8fbd33 (diff)
Do not sort rooms after navigating back
-rw-r--r--include/Body.hpp1
-rw-r--r--src/QuickMedia.cpp12
-rw-r--r--src/plugins/Matrix.cpp6
3 files changed, 13 insertions, 6 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index 99f8b1c..294295b 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -123,6 +123,7 @@ namespace QuickMedia {
sf::Vector2i thumbnail_size;
private:
// TODO: Clean up these strings when set in text, and get_title for example should return |title_text.getString()|
+ // TODO: Use sf::String instead, removes the need to convert to utf32 every time the text is dirty (for example when resizing window)
std::string title;
std::string description;
std::string author;
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index f3aeda5..9bb5231 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()) {
@@ -1047,7 +1053,7 @@ namespace QuickMedia {
current_page = PageType::CHAT;
current_chat_room = matrix->get_room_by_id(selected_item->url);
chat_page(static_cast<MatrixChatPage*>(new_tabs[0].page.get()), current_chat_room);
- select_body_item_by_room(tabs[selected_tab].body.get(), current_chat_room);
+ //select_body_item_by_room(tabs[selected_tab].body.get(), current_chat_room);
current_chat_room = nullptr;
} else {
page_loop(new_tabs);
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index e085912..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<std::mutex> lock(mutex);
-#if 0
+#if 1
BodyItem *room_body_item = static_cast<BodyItem*>(room->userdata);
int room_body_index = body->get_index_by_body_item(room_body_item);
if(room_body_index != -1) {
@@ -574,7 +574,7 @@ namespace QuickMedia {
Body *body_ptr = body.get();
TagData &tag_data = tag_body_items_by_name[url];
body->items = tag_data.room_body_items;
- //sort_room_body_items(body->items);
+ sort_room_body_items(body->items);
auto search_bar = create_search_bar("Search...", SEARCH_DELAY_FILTER);
auto rooms_page = std::make_unique<MatrixRoomsPage>(program, body_ptr, tag_data.tag_item->get_title(), this, search_bar.get());
rooms_page->matrix_delegate = matrix_delegate;