From 65c17cfea28d603bdb84c428e8d20707dfaa7f57 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sat, 24 Apr 2021 13:54:50 +0200 Subject: [PATCH] dc_markseen_msgs() should not handle deaddrop messages are marked as 'noticed' already when the chat is opened as all UIs call dc_marknoticed_chat(); also marking messages as 'noticed' when dc_markseen_msgs() is called is not needed therefore - but stands in the way of further improvements for the deaddrop, eg. UI may let the user decide when the deaddrop can be removed from chatlist ('All done' button or so) --- deltachat-ffi/deltachat.h | 21 +++++++++++++++------ src/message.rs | 25 +++++++++++-------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 5134ee60a..9b366a6d0 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -1594,13 +1594,22 @@ void dc_marknoticed_contact (dc_context_t* context, uint32_t co /** - * Mark a message as _seen_, updates the IMAP state and - * sends MDNs. If the message is not in a real chat (e.g. a contact request), the - * message is only marked as NOTICED and no IMAP/MDNs is done. See also - * dc_marknoticed_chat(). + * Mark messages as presented to the user. + * Typically, UIs call this function on scrolling through the chatlist, + * when the messages are presented at least for a little moment. + * The concrete action depends on the type of the chat and on the users settings + * (dc_msgs_presented() may be a better name therefore, but well :) * - * Moreover, if messages belong to a chat with ephemeral messages enabled, - * the ephemeral timer is started for these messages. + * - For normal chats, the IMAP state is updated, MDN is sent + * (if dc_set_config()-options `mdns_enabled` is set) + * and the internal state is changed to DC_STATE_IN_SEEN to reflect these actions. + * + * - For the deaddrop, no IMAP or MNDs is done + * and the internal change is not changed therefore. + * See also dc_marknoticed_chat(). + * + * Moreover, timer is started for incoming ephemeral messages. + * This also happens for messages in the deaddrop. * * One #DC_EVENT_MSGS_NOTICED event is emitted per modified chat. * diff --git a/src/message.rs b/src/message.rs index 1418e836c..df42d2338 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1545,21 +1545,18 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec) -> bool { continue; } - if curr_blocked == Blocked::Not { - if curr_state == MessageState::InFresh || curr_state == MessageState::InNoticed { - update_msg_state(context, id, MessageState::InSeen).await; - info!(context, "Seen message {}.", id); + if curr_blocked == Blocked::Not + && (curr_state == MessageState::InFresh || curr_state == MessageState::InNoticed) + { + update_msg_state(context, id, MessageState::InSeen).await; + info!(context, "Seen message {}.", id); - job::add( - context, - job::Job::new(Action::MarkseenMsgOnImap, id.to_u32(), Params::new(), 0), - ) - .await; - updated_chat_ids.insert(curr_chat_id, true); - } - } else if curr_state == MessageState::InFresh { - update_msg_state(context, id, MessageState::InNoticed).await; - updated_chat_ids.insert(DC_CHAT_ID_DEADDROP, true); + job::add( + context, + job::Job::new(Action::MarkseenMsgOnImap, id.to_u32(), Params::new(), 0), + ) + .await; + updated_chat_ids.insert(curr_chat_id, true); } }