fix archiving requests (#2563)

* add a test for archived requests

* fix archived requests

* move requests but the last one to "Archived Chats"

this way, the app looks familiar after the contact request upgrade.
the subselect was copied from the old get_last_deaddrop_fresh_msg()
(which was removed by the contact request upgrade #2514)

* just move all old requests to "Archived Chats"

ux-wise, the advantage of keeping the last one is questionable,
one may think, always the last one is shown in chatlist.

showing _all_ fresh request is not doable
as past cores did not really take care of that
and the db-state is not consistent in that regard.

that would make the already complicated code even more complicated,
so we decided to go the easy way.
This commit is contained in:
bjoern
2021-07-28 14:56:54 +02:00
committed by GitHub
parent 5856936f49
commit 9a77a7b66f
3 changed files with 52 additions and 3 deletions

View File

@@ -3993,6 +3993,48 @@ mod tests {
Ok(())
}
#[async_std::test]
async fn test_contact_request_archive() -> Result<()> {
let t = TestContext::new_alice().await;
dc_receive_imf(
&t,
b"From: bob@example.org\n\
To: alice@example.com\n\
Message-ID: <2@example.org>\n\
Chat-Version: 1.0\n\
Date: Sun, 22 Mar 2021 19:37:57 +0000\n\
\n\
hello\n",
"INBOX",
1,
false,
)
.await?;
let chats = Chatlist::try_load(&t, 0, None, None).await?;
assert_eq!(chats.len(), 1);
let chat_id = chats.get_chat_id(0);
assert!(Chat::load_from_db(&t, chat_id).await?.is_contact_request());
assert_eq!(dc_get_archived_cnt(&t).await?, 0);
// archive request without accepting or blocking
chat_id.set_visibility(&t, ChatVisibility::Archived).await?;
let chats = Chatlist::try_load(&t, 0, None, None).await?;
assert_eq!(chats.len(), 1);
let chat_id = chats.get_chat_id(0);
assert!(chat_id.is_archived_link());
assert_eq!(dc_get_archived_cnt(&t).await?, 1);
let chats = Chatlist::try_load(&t, DC_GCL_ARCHIVED_ONLY, None, None).await?;
assert_eq!(chats.len(), 1);
let chat_id = chats.get_chat_id(0);
assert!(Chat::load_from_db(&t, chat_id).await?.is_contact_request());
Ok(())
}
#[async_std::test]
async fn test_classic_email_chat() -> Result<()> {
let alice = TestContext::new_alice().await;