mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 00:46:31 +03:00
fix: always sort "Messages are end-to-end encrypted" notice to the beginning
We set timestamp of this info message to 0 to make it always appear in the beginning of the chat. To avoid new chats being sorted to the end of the chatlist, we ignore such 0 and use chat creation timestamp when sorting the chatlist.
This commit is contained in:
@@ -477,12 +477,17 @@ impl ChatId {
|
|||||||
/// Adds message "Messages are end-to-end encrypted".
|
/// Adds message "Messages are end-to-end encrypted".
|
||||||
pub(crate) async fn add_e2ee_notice(self, context: &Context, timestamp: i64) -> Result<()> {
|
pub(crate) async fn add_e2ee_notice(self, context: &Context, timestamp: i64) -> Result<()> {
|
||||||
let text = stock_str::messages_e2ee_info_msg(context);
|
let text = stock_str::messages_e2ee_info_msg(context);
|
||||||
|
|
||||||
|
// Sort this notice to the very beginning of the chat.
|
||||||
|
// We don't want any message to appear before this notice
|
||||||
|
// which is normally added when encrypted chat is created.
|
||||||
|
let sort_timestamp = 0;
|
||||||
add_info_msg_with_cmd(
|
add_info_msg_with_cmd(
|
||||||
context,
|
context,
|
||||||
self,
|
self,
|
||||||
&text,
|
&text,
|
||||||
SystemMessage::ChatE2ee,
|
SystemMessage::ChatE2ee,
|
||||||
Some(timestamp),
|
Some(sort_timestamp),
|
||||||
timestamp,
|
timestamp,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ impl Chatlist {
|
|||||||
AND c.blocked!=1
|
AND c.blocked!=1
|
||||||
AND c.id IN(SELECT chat_id FROM chats_contacts WHERE contact_id=?2 AND add_timestamp >= remove_timestamp)
|
AND c.id IN(SELECT chat_id FROM chats_contacts WHERE contact_id=?2 AND add_timestamp >= remove_timestamp)
|
||||||
GROUP BY c.id
|
GROUP BY c.id
|
||||||
ORDER BY c.archived=?3 DESC, IFNULL(m.timestamp,c.created_timestamp) DESC, m.id DESC;",
|
ORDER BY c.archived=?3 DESC, IFNULL(NULLIF(m.timestamp,0),c.created_timestamp) DESC, m.id DESC;",
|
||||||
(MessageState::OutDraft, query_contact_id, ChatVisibility::Pinned),
|
(MessageState::OutDraft, query_contact_id, ChatVisibility::Pinned),
|
||||||
process_row,
|
process_row,
|
||||||
).await?
|
).await?
|
||||||
@@ -168,7 +168,7 @@ impl Chatlist {
|
|||||||
AND c.blocked!=1
|
AND c.blocked!=1
|
||||||
AND c.archived=1
|
AND c.archived=1
|
||||||
GROUP BY c.id
|
GROUP BY c.id
|
||||||
ORDER BY IFNULL(m.timestamp,c.created_timestamp) DESC, m.id DESC;",
|
ORDER BY IFNULL(NULLIF(m.timestamp,0),c.created_timestamp) DESC, m.id DESC;",
|
||||||
(MessageState::OutDraft,),
|
(MessageState::OutDraft,),
|
||||||
process_row,
|
process_row,
|
||||||
)
|
)
|
||||||
@@ -204,7 +204,7 @@ impl Chatlist {
|
|||||||
AND IFNULL(c.name_normalized,c.name) LIKE ?3
|
AND IFNULL(c.name_normalized,c.name) LIKE ?3
|
||||||
AND (NOT ?4 OR EXISTS (SELECT 1 FROM msgs m WHERE m.chat_id = c.id AND m.state == ?5 AND hidden=0))
|
AND (NOT ?4 OR EXISTS (SELECT 1 FROM msgs m WHERE m.chat_id = c.id AND m.state == ?5 AND hidden=0))
|
||||||
GROUP BY c.id
|
GROUP BY c.id
|
||||||
ORDER BY IFNULL(m.timestamp,c.created_timestamp) DESC, m.id DESC;",
|
ORDER BY IFNULL(NULLIF(m.timestamp,0),c.created_timestamp) DESC, m.id DESC;",
|
||||||
(MessageState::OutDraft, skip_id, str_like_cmd, only_unread, MessageState::InFresh),
|
(MessageState::OutDraft, skip_id, str_like_cmd, only_unread, MessageState::InFresh),
|
||||||
process_row,
|
process_row,
|
||||||
)
|
)
|
||||||
@@ -253,7 +253,7 @@ impl Chatlist {
|
|||||||
AND NOT c.archived=?
|
AND NOT c.archived=?
|
||||||
AND (c.type!=? OR c.id IN(SELECT chat_id FROM chats_contacts WHERE contact_id=? AND add_timestamp >= remove_timestamp))
|
AND (c.type!=? OR c.id IN(SELECT chat_id FROM chats_contacts WHERE contact_id=? AND add_timestamp >= remove_timestamp))
|
||||||
GROUP BY c.id
|
GROUP BY c.id
|
||||||
ORDER BY c.id=? DESC, c.archived=? DESC, IFNULL(m.timestamp,c.created_timestamp) DESC, m.id DESC;",
|
ORDER BY c.id=? DESC, c.archived=? DESC, IFNULL(NULLIF(m.timestamp,0),c.created_timestamp) DESC, m.id DESC;",
|
||||||
(
|
(
|
||||||
MessageState::OutDraft, skip_id, ChatVisibility::Archived,
|
MessageState::OutDraft, skip_id, ChatVisibility::Archived,
|
||||||
Chattype::Group, ContactId::SELF,
|
Chattype::Group, ContactId::SELF,
|
||||||
@@ -279,7 +279,7 @@ impl Chatlist {
|
|||||||
AND (c.blocked=0 OR c.blocked=2)
|
AND (c.blocked=0 OR c.blocked=2)
|
||||||
AND NOT c.archived=?
|
AND NOT c.archived=?
|
||||||
GROUP BY c.id
|
GROUP BY c.id
|
||||||
ORDER BY c.id=0 DESC, c.archived=? DESC, IFNULL(m.timestamp,c.created_timestamp) DESC, m.id DESC;",
|
ORDER BY c.id=0 DESC, c.archived=? DESC, IFNULL(NULLIF(m.timestamp,0),c.created_timestamp) DESC, m.id DESC;",
|
||||||
(MessageState::OutDraft, skip_id, ChatVisibility::Archived, ChatVisibility::Pinned),
|
(MessageState::OutDraft, skip_id, ChatVisibility::Archived, ChatVisibility::Pinned),
|
||||||
process_row,
|
process_row,
|
||||||
).await?
|
).await?
|
||||||
|
|||||||
Reference in New Issue
Block a user