feat: sort apps by recently-updated (#6875)

closes #6873 , see there for reasoning.

tested that on iOS already, works like a charm - and was much easier
than expected as @iequidoo already updated `timestamp_rcvd` on status
updates in https://github.com/chatmail/core/pull/5388

~~a test is missing, ordering is not tested at all, will check if that
is doable reasonably easy~~ EDIT: added a test
This commit is contained in:
bjoern
2025-05-26 18:33:48 +02:00
committed by GitHub
parent 776b2247dd
commit a24e6d4278
2 changed files with 106 additions and 26 deletions

View File

@@ -2924,6 +2924,61 @@ async fn test_get_chat_media() -> Result<()> {
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_get_chat_media_webxdc_order() -> Result<()> {
let mut tcm = TestContextManager::new();
let alice = tcm.alice().await;
let bob = tcm.bob().await;
let chat = alice.create_chat(&bob).await;
let mut instance1 = Message::new(Viewtype::Webxdc);
instance1.set_file_from_bytes(
&alice,
"test1.xdc",
include_bytes!("../../test-data/webxdc/minimal.xdc"),
None,
)?;
let instance1_id = send_msg(&alice, chat.id, &mut instance1).await?;
let mut instance2 = Message::new(Viewtype::Webxdc);
instance2.set_file_from_bytes(
&alice,
"test2.xdc",
include_bytes!("../../test-data/webxdc/minimal.xdc"),
None,
)?;
let instance2_id = send_msg(&alice, chat.id, &mut instance2).await?;
// list is ordered oldest to newest, check that
let media = get_chat_media(
&alice,
Some(chat.id),
Viewtype::Webxdc,
Viewtype::Unknown,
Viewtype::Unknown,
)
.await?;
assert_eq!(media.first().unwrap(), &instance1_id);
assert_eq!(media.get(1).unwrap(), &instance2_id);
// add a status update for the oder instance; that resorts the list
alice
.send_webxdc_status_update(instance1_id, r#"{"payload": {"foo": "bar"}}"#)
.await?;
let media = get_chat_media(
&alice,
Some(chat.id),
Viewtype::Webxdc,
Viewtype::Unknown,
Viewtype::Unknown,
)
.await?;
assert_eq!(media.first().unwrap(), &instance2_id);
assert_eq!(media.get(1).unwrap(), &instance1_id);
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_blob_renaming() -> Result<()> {
let alice = TestContext::new_alice().await;