From 087b4289e5443758b2b28d73d089fa69be0ecfb5 Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Sat, 7 Jan 2023 00:34:47 +0100 Subject: [PATCH] jsonrpc: add fresh message count to the archive-link chatlistitem variant (#3920) this is a followup to #3918 I went with option "C" from my comment: https://github.com/deltachat/deltachat-core-rust/pull/3918#issuecomment-1371224339 - Archive link is (still) very different from a normal chat, so most of the options would be empty / not relevant - avatar path is not needed as desktop renders it differently anyway, it's not really a chat like saved messages or device messages where it made more sense for the core to supply the icon, vs. using the svg directly. - translating the string in the coreas stock-string is more annoying than doing it from the ui, especially when this special pseudo chat has different rendering anyway so also no need to provide a name property --- CHANGELOG.md | 1 + deltachat-jsonrpc/src/api/types/chat_list.rs | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf0e1b21b..37715b863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ ### API-Changes - jsonrpc: add python API for webxdc updates #3872 +- jsonrpc: add fresh message count to ChatListItemFetchResult::ArchiveLink - Add ffi functions to retrieve `verified by` information #3786 ### Fixes diff --git a/deltachat-jsonrpc/src/api/types/chat_list.rs b/deltachat-jsonrpc/src/api/types/chat_list.rs index 45933770f..83b84dd3d 100644 --- a/deltachat-jsonrpc/src/api/types/chat_list.rs +++ b/deltachat-jsonrpc/src/api/types/chat_list.rs @@ -48,12 +48,10 @@ pub enum ChatListItemFetchResult { dm_chat_contact: Option, was_seen_recently: bool, }, - ArchiveLink, #[serde(rename_all = "camelCase")] - Error { - id: u32, - error: String, - }, + ArchiveLink { fresh_message_counter: usize }, + #[serde(rename_all = "camelCase")] + Error { id: u32, error: String }, } pub(crate) async fn get_chat_list_item_by_id( @@ -66,8 +64,12 @@ pub(crate) async fn get_chat_list_item_by_id( _ => Some(MsgId::new(entry.1)), }; + let fresh_message_counter = chat_id.get_fresh_msg_cnt(ctx).await?; + if chat_id.is_archived_link() { - return Ok(ChatListItemFetchResult::ArchiveLink); + return Ok(ChatListItemFetchResult::ArchiveLink { + fresh_message_counter, + }); } let chat = Chat::load_from_db(ctx, chat_id).await?; @@ -111,7 +113,6 @@ pub(crate) async fn get_chat_list_item_by_id( (None, false) }; - let fresh_message_counter = chat_id.get_fresh_msg_cnt(ctx).await?; let color = color_int_to_hex_string(chat.get_color(ctx).await?); Ok(ChatListItemFetchResult::ChatListItem {