aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-09-28 00:30:13 +0200
committerdec05eba <dec05eba@protonmail.com>2020-09-28 00:43:35 +0200
commitb9c5c06d53f5b3927e125ec46e3d1d7efcae6f12 (patch)
tree0320d86d7ad2c913d23e40e43c5439e2549da462 /src/QuickMedia.cpp
parent90c13efab1fd1b67625ec23815ccc195803e230e (diff)
Matrix: remove deprecated login method
Scroll to bottom if the last item is the selected item, or when selecting another room.
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index e07c30a..994d14c 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3533,6 +3533,7 @@ namespace QuickMedia {
// TODO: Make asynchronous
if(matrix->get_all_synced_room_messages(current_room_id, new_items) == PluginResult::OK) {
tabs[MESSAGES_TAB_INDEX].body->append_items(std::move(new_items));
+ tabs[MESSAGES_TAB_INDEX].body->select_last_item();
} else {
std::string err_msg = "Failed to get messages in room: " + current_room_id;
show_notification("QuickMedia", err_msg, Urgency::CRITICAL);
@@ -3636,7 +3637,7 @@ namespace QuickMedia {
BodyItems result_items;
if(matrix->sync() == PluginResult::OK) {
fprintf(stderr, "Synced matrix\n");
- if(matrix->get_new_room_messages(sync_future_room_id, result_items) != PluginResult::OK) {
+ if(matrix->get_new_room_messages(sync_future_room_id, result_items) == PluginResult::OK) {
fprintf(stderr, "Failed to get new matrix messages in room: %s\n", sync_future_room_id.c_str());
}
} else {
@@ -3651,7 +3652,11 @@ namespace QuickMedia {
BodyItems new_body_items = sync_future.get();
// Ignore finished sync if it happened in another room. When we navigate back to the room we will get the messages again
if(sync_future_room_id == current_room_id) {
+ int num_items = tabs[MESSAGES_TAB_INDEX].body->items.size();
+ bool scroll_to_end = (num_items > 0 && tabs[MESSAGES_TAB_INDEX].body->get_selected_item() == num_items - 1);
tabs[MESSAGES_TAB_INDEX].body->append_items(std::move(new_body_items));
+ if(scroll_to_end)
+ tabs[MESSAGES_TAB_INDEX].body->select_last_item();
}
sync_running = false;
}