mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
jsonrpc: Remove message id from chatlist item (#3071)
Why? because desktop currently fetches the chatlist multiple times, even though it just needs the chatlistitem for one chat. Note: @r10s was worried before that exposing the method to get a single updated chatlistitem could lead to race conditions where the chatlist item is newer than the chatlist order. But I don't think this will change anything for desktop besides making it a little faster (because currently desktop fetches the whole chatlist instead of just the entry it needs when an entry updates).
This commit is contained in:
@@ -362,6 +362,25 @@ pub async fn get_archived_cnt(context: &Context) -> Result<usize> {
|
||||
Ok(count)
|
||||
}
|
||||
|
||||
/// Gets the last message of a chat, the message that would also be displayed in the ChatList
|
||||
/// Used for passing to `deltachat::chatlist::Chatlist::get_summary2`
|
||||
pub async fn get_last_message_for_chat(
|
||||
context: &Context,
|
||||
chat_id: ChatId,
|
||||
) -> Result<Option<MsgId>> {
|
||||
context
|
||||
.sql
|
||||
.query_get_value(
|
||||
"SELECT id
|
||||
FROM msgs
|
||||
WHERE chat_id=?2
|
||||
AND (hidden=0 OR state=?1)
|
||||
ORDER BY timestamp DESC, id DESC LIMIT 1",
|
||||
(MessageState::OutDraft, chat_id),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user