aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Matrix.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 8c9b1c1..d3e8117 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -674,13 +674,17 @@ namespace QuickMedia {
for(size_t i = 0; i < body->items.size(); ++i) {
RoomData *room_i = static_cast<RoomData*>(body->items[i]->userdata);
- if((int)i != selected_item && room_i && room->last_message_timestamp > room_i->last_message_timestamp) {
+ if((int)i == room_body_index)
+ return;
+ if((int)i != selected_item && room_i && room->last_message_timestamp >= room_i->last_message_timestamp) {
auto body_item_to_insert = body->items[room_body_index];
body->items.erase(body->items.begin() + room_body_index);
- if((int)i <= room_body_index)
+ if(room_body_index >= (int)i)
body->items.insert(body->items.begin() + i, std::move(body_item_to_insert));
else
body->items.insert(body->items.begin() + (i - 1), std::move(body_item_to_insert));
+ if((int)i < selected_item && room_body_index > selected_item && body->items.size() > 1 && i != body->items.size() - 1)
+ body->set_selected_item(selected_item + 1);
return;
}
}