aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-11-05 15:30:56 +0100
committerdec05eba <dec05eba@protonmail.com>2020-11-05 15:30:56 +0100
commitff207b4c7f160be58a747f0115e74ea136459f2c (patch)
tree00eaea785bb8a419eeab5c3464bc978510e3b7fe /src/plugins
parent772e5c493615d7bdb4275a921c4132d7fe9e8a3a (diff)
First sort alphabetically and then by mention/unread..
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Matrix.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index baa3ec5..e05d85c 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -323,6 +323,9 @@ namespace QuickMedia {
}
static void sort_room_body_items(std::vector<std::shared_ptr<BodyItem>> &room_body_items) {
+ std::sort(room_body_items.begin(), room_body_items.end(), [](const std::shared_ptr<BodyItem> &body_item1, const std::shared_ptr<BodyItem> &body_item2) {
+ return strcasecmp(body_item1->get_title().c_str(), body_item2->get_title().c_str()) < 0;
+ });
#if 1
std::sort(room_body_items.begin(), room_body_items.end(), [](const std::shared_ptr<BodyItem> &body_item1, const std::shared_ptr<BodyItem> &body_item2) {
RoomData *room1 = static_cast<RoomData*>(body_item1->userdata);
@@ -405,8 +408,8 @@ namespace QuickMedia {
room_body_item->set_title_color(sf::Color(255, 100, 100));
room->last_message_read = false;
- //rooms_page->move_room_to_top(room);
- //room_tags_page->move_room_to_top(room);
+ rooms_page->move_room_to_top(room);
+ room_tags_page->move_room_to_top(room);
} else if(is_initial_sync) {
Message *last_message = nullptr;
if(!messages.empty())
@@ -477,8 +480,10 @@ namespace QuickMedia {
body->clear_items();
}
- if(!pending_remove_body_items.empty() || !room_body_items.empty())
+ if(!pending_remove_body_items.empty() || !room_body_items.empty()) {
+ sort_on_update = true;
filter_on_update = true;
+ }
for(const std::string &room_id : pending_remove_body_items) {
remove_body_item_by_url(body->items, room_id);
@@ -496,14 +501,14 @@ namespace QuickMedia {
}
if(sort_on_update) {
sort_on_update = false;
- //sort_room_body_items(body->items);
+ sort_room_body_items(body->items);
}
matrix_delegate->update(MatrixPageType::ROOM_LIST);
if(filter_on_update) {
filter_on_update = false;
if(search_bar)
body->filter_search_fuzzy(search_bar->get_text());
- sort_room_body_items(body->items);
+ //sort_room_body_items(body->items);
}
}
@@ -516,6 +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
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) {
@@ -533,6 +539,9 @@ namespace QuickMedia {
body->items.insert(body->items.begin() + (body_swap_index - 1), std::move(body_item));
}
}
+#else
+ sort_on_update = true;
+#endif
}
void MatrixRoomsPage::remove_body_item_by_room_id(const std::string &room_id) {