diff options
-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); |