mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 10:26:29 +03:00
feat: mark messages as "fresh"
this adds an api to make the newest incoming message of a chat as "fresh", so that UI can offer a "mark chat unread" option as usual for messengers (eg. swipe right on iOS toggels between "read" and "unread"). "mark unread" is one of the most requested missing features, used by many ppl to organize their every day messenger usage - tho "pinning" and "saved messages" are similar, it seems to be missed often. we follow a very simple approach here and just reset the state to `MessageState::InFresh`. this does not introduce new states or flows. therefore, chats without any incoming message cannot be marked as fresh. in practise, this is probably not really an issue, as the "mark fresh" is usually used to undo a "mark noticed" operation - and then you have incoming message. also, most status messages as "all messages are e2ee" count as incoming. to avoid double sending of MDN, we remove `Param::WantsMdn` once the MDN is scheduled. in case MDN are used for syncing, MDN is still sent as before. many other messenger show a "badge without number", if we want that as well, we can always track the "manually set as fresh" state in a parameter. but for now, it is fine without and showing a "1", which alsso makes sense as badges may be summed up. there is an iOS pr that uses this new feature, jsonrpc is left out until api is settled. also out of scope is synchronisation - main reason is that "mark noticed" is not synced as well, so we avoid an imbalance here. both, "mark noticed" as well as "mark fresh" should be synced however, as soon as this feature is merged.
This commit is contained in:
@@ -1939,6 +1939,17 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> Result<()>
|
||||
&& curr_param.get_cmd() == SystemMessage::Unknown
|
||||
&& context.should_send_mdns().await?
|
||||
{
|
||||
// Clear WantsMdn to not handle a MDN twice
|
||||
// if the state later is InFresh again as markfresh_chat() was called.
|
||||
// BccSelf MDN messages in the next branch may be sent twice for syncing.
|
||||
context
|
||||
.sql
|
||||
.execute(
|
||||
"UPDATE msgs SET param=? WHERE id=?",
|
||||
(curr_param.clone().remove(Param::WantsMdn).to_string(), id),
|
||||
)
|
||||
.await
|
||||
.context("failed to clear WantsMdn")?;
|
||||
Some(curr_from_id)
|
||||
} else if context.get_config_bool(Config::BccSelf).await? {
|
||||
Some(ContactId::SELF)
|
||||
@@ -1956,6 +1967,7 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> Result<()>
|
||||
.context("failed to insert into smtp_mdns")?;
|
||||
context.scheduler.interrupt_smtp().await;
|
||||
}
|
||||
|
||||
if !curr_hidden {
|
||||
updated_chat_ids.insert(curr_chat_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user