diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-02-09 11:34:31 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-02-09 11:35:37 +0100 |
commit | 1fe091011c397d7b5ce5c3a6409b2351a791fa20 (patch) | |
tree | e3efde3c5a37707de4880408351446b2cca4695f /src | |
parent | 07c8a8f1d469672be5196570608cf0d14b4d5b21 (diff) |
Matrix: try sorting encrypted room messages as well
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/Matrix.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 6900dbc..051e951 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -492,8 +492,10 @@ namespace QuickMedia { void MatrixQuickMedia::update_room_description(RoomData *room, Messages &new_messages, bool is_initial_sync, bool sync_is_cache) { time_t read_marker_message_timestamp = 0; std::shared_ptr<UserInfo> me = matrix->get_me(room); + std::string my_user_read_marker; if(me) { - auto read_marker_message = room->get_message_by_id(room->get_user_read_marker(me)); + my_user_read_marker = room->get_user_read_marker(me); + auto read_marker_message = room->get_message_by_id(my_user_read_marker); if(read_marker_message) read_marker_message_timestamp = read_marker_message->timestamp; } @@ -512,8 +514,12 @@ namespace QuickMedia { last_message_by_room[room] = last_new_message; } + // The event id in encrypted rooms contain the timestamp. Sort by that if possible. Such messages contain a colon. + Message *last_unread_message = nullptr; - if(last_new_message->timestamp > read_marker_message_timestamp) + if(read_marker_message_timestamp != 0 && last_new_message->timestamp > read_marker_message_timestamp) + last_unread_message = last_new_message.get(); + else if(read_marker_message_timestamp == 0 && !my_user_read_marker.empty() && last_new_message->event_id.find(':') != std::string::npos && last_new_message->event_id > my_user_read_marker) last_unread_message = last_new_message.get(); //assert(room_body_item); |