fix: calc_sort_timestamp: Skip messages that mustn't affect sorting of a new message (#5088)

Drafts mustn't affect sorting of any other messages, they aren't even displayed in the chat
window. Also hidden messages mustn't affect sorting of usual messages. But let hidden messages sort
together with protection messages because hidden messages also can be or not be verified, so let's
preserve this information -- even it's not useful currently, it can be useful in the future
versions.
This commit is contained in:
iequidoo
2023-12-07 21:45:31 -03:00
committed by iequidoo
parent fce3f80654
commit 8d41d02397

View File

@@ -1501,8 +1501,8 @@ pub(crate) async fn calc_sort_timestamp(
context
.sql
.query_get_value(
"SELECT MAX(timestamp) FROM msgs WHERE chat_id=?",
(chat_id,),
"SELECT MAX(timestamp) FROM msgs WHERE chat_id=? AND state!=?",
(chat_id, MessageState::OutDraft),
)
.await?
} else if incoming {
@@ -1517,7 +1517,7 @@ pub(crate) async fn calc_sort_timestamp(
context
.sql
.query_get_value(
"SELECT MAX(timestamp) FROM msgs WHERE chat_id=? AND state>?",
"SELECT MAX(timestamp) FROM msgs WHERE chat_id=? AND hidden=0 AND state>?",
(chat_id, MessageState::InFresh),
)
.await?