diff --git a/app/src/main/java/com/rosetta/messenger/database/MessageEntities.kt b/app/src/main/java/com/rosetta/messenger/database/MessageEntities.kt index 11a743f..666e77a 100644 --- a/app/src/main/java/com/rosetta/messenger/database/MessageEntities.kt +++ b/app/src/main/java/com/rosetta/messenger/database/MessageEntities.kt @@ -550,8 +550,8 @@ interface DialogDao { (SELECT delivered FROM messages WHERE account = :account AND from_me = 1 - AND ((from_public_key = :opponentKey AND to_public_key = :account) - OR (from_public_key = :account AND to_public_key = :opponentKey)) + AND from_public_key = :account + AND to_public_key = :opponentKey ORDER BY timestamp DESC LIMIT 1), 0 ) AS last_message_delivered, @@ -559,8 +559,8 @@ interface DialogDao { (SELECT read FROM messages WHERE account = :account AND from_me = 1 - AND ((from_public_key = :opponentKey AND to_public_key = :account) - OR (from_public_key = :account AND to_public_key = :opponentKey)) + AND from_public_key = :account + AND to_public_key = :opponentKey ORDER BY timestamp DESC LIMIT 1), 0 ) AS last_message_read