Add API to get next fresh message

Rust: Context.get_next_fresh_msg()
C: dc_get_next_fresh_msg()
JSON-RPC: get_next_fresh_msg method
This commit is contained in:
link2xt
2022-11-27 11:37:24 +00:00
parent 08de326930
commit f02888e3cc
5 changed files with 58 additions and 2 deletions

View File

@@ -372,6 +372,15 @@ impl CommandApi {
.collect())
}
/// Returns the message ID of the oldest fresh message.
///
/// If there are no such messages, waits until there is one.
async fn get_next_fresh_msg(&self, account_id: u32) -> Result<u32> {
let ctx = self.get_context(account_id).await?;
let msg_id = ctx.get_next_fresh_msg().await?;
Ok(msg_id.to_u32())
}
/// Get the number of _fresh_ messages in a chat.
/// Typically used to implement a badge with a number in the chatlist.
///