Skip to content

Commit 8d41d02

Browse files
committed
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.
1 parent fce3f80 commit 8d41d02

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/receive_imf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,8 +1501,8 @@ pub(crate) async fn calc_sort_timestamp(
15011501
context
15021502
.sql
15031503
.query_get_value(
1504-
"SELECT MAX(timestamp) FROM msgs WHERE chat_id=?",
1505-
(chat_id,),
1504+
"SELECT MAX(timestamp) FROM msgs WHERE chat_id=? AND state!=?",
1505+
(chat_id, MessageState::OutDraft),
15061506
)
15071507
.await?
15081508
} else if incoming {
@@ -1517,7 +1517,7 @@ pub(crate) async fn calc_sort_timestamp(
15171517
context
15181518
.sql
15191519
.query_get_value(
1520-
"SELECT MAX(timestamp) FROM msgs WHERE chat_id=? AND state>?",
1520+
"SELECT MAX(timestamp) FROM msgs WHERE chat_id=? AND hidden=0 AND state>?",
15211521
(chat_id, MessageState::InFresh),
15221522
)
15231523
.await?

0 commit comments

Comments
 (0)