mirror of
https://github.com/chatmail/core.git
synced 2026-04-05 15:02:11 +03:00
split DC_EVENT_MSGS_NOTICED off DC_EVENT_MSGS_CHANGED
the new event can be used for updating the badge counter. to get the old behaviour, implementations can just do the same on both events.
This commit is contained in:
@@ -1122,7 +1122,7 @@ dc_array_t* dc_get_fresh_msgs (dc_context_t* context);
|
||||
* but are still waiting for being marked as "seen" using dc_markseen_msgs()
|
||||
* (IMAP/MDNs is not done for noticed messages).
|
||||
*
|
||||
* Calling this function usually results in the event #DC_EVENT_MSGS_CHANGED.
|
||||
* Calling this function usually results in the event #DC_EVENT_MSGS_NOTICED.
|
||||
* See also dc_marknoticed_all_chats(), dc_marknoticed_contact() and dc_markseen_msgs().
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
@@ -1517,7 +1517,7 @@ void dc_forward_msgs (dc_context_t* context, const uint3
|
||||
* as _noticed_. See also dc_marknoticed_chat() and
|
||||
* dc_markseen_msgs()
|
||||
*
|
||||
* Calling this function usually results in the event #DC_EVENT_MSGS_CHANGED.
|
||||
* Calling this function usually results in the event #DC_EVENT_MSGS_NOTICED.
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object.
|
||||
@@ -1536,6 +1536,8 @@ void dc_marknoticed_contact (dc_context_t* context, uint32_t co
|
||||
* Moreover, if messages belong to a chat with ephemeral messages enabled,
|
||||
* the ephemeral timer is started for these messages.
|
||||
*
|
||||
* Calling this function usually results in the event #DC_EVENT_MSGS_NOTICED.
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object.
|
||||
* @param msg_ids An array of uint32_t containing all the messages IDs that should be marked as seen.
|
||||
@@ -4607,6 +4609,20 @@ void dc_event_unref(dc_event_t* event);
|
||||
#define DC_EVENT_INCOMING_MSG 2005
|
||||
|
||||
|
||||
/**
|
||||
* Messages were marked noticed or seen.
|
||||
* The ui may update badge counters or stop showing a chatlist-item with a bold font.
|
||||
*
|
||||
* This event is emitted eg. when calling dc_markseen_msgs(), dc_marknoticed_chat() or dc_marknoticed_contact().
|
||||
* Do not try to derive the state of an item from just the fact you received the event;
|
||||
* use eg. dc_msg_get_state() or dc_get_fresh_msg_cnt() for this purpose.
|
||||
*
|
||||
* @param data1 (int) chat_id or 0 if the event affects multiple chats.
|
||||
* @param data2 0
|
||||
*/
|
||||
#define DC_EVENT_MSGS_NOTICED 2008
|
||||
|
||||
|
||||
/**
|
||||
* A single message is sent successfully. State changed from DC_STATE_OUT_PENDING to
|
||||
* DC_STATE_OUT_DELIVERED, see dc_msg_get_state().
|
||||
|
||||
@@ -362,6 +362,7 @@ pub unsafe extern "C" fn dc_event_get_data1_int(event: *mut dc_event_t) -> libc:
|
||||
| EventType::ErrorSelfNotInGroup(_) => 0,
|
||||
EventType::MsgsChanged { chat_id, .. }
|
||||
| EventType::IncomingMsg { chat_id, .. }
|
||||
| EventType::MsgsNoticed(chat_id)
|
||||
| EventType::MsgDelivered { chat_id, .. }
|
||||
| EventType::MsgFailed { chat_id, .. }
|
||||
| EventType::MsgRead { chat_id, .. }
|
||||
@@ -407,6 +408,7 @@ pub unsafe extern "C" fn dc_event_get_data2_int(event: *mut dc_event_t) -> libc:
|
||||
| EventType::ConfigureProgress { .. }
|
||||
| EventType::ImexProgress(_)
|
||||
| EventType::ImexFileWritten(_)
|
||||
| EventType::MsgsNoticed(_)
|
||||
| EventType::ChatModified(_) => 0,
|
||||
EventType::MsgsChanged { msg_id, .. }
|
||||
| EventType::IncomingMsg { msg_id, .. }
|
||||
@@ -446,6 +448,7 @@ pub unsafe extern "C" fn dc_event_get_data2_str(event: *mut dc_event_t) -> *mut
|
||||
}
|
||||
EventType::MsgsChanged { .. }
|
||||
| EventType::IncomingMsg { .. }
|
||||
| EventType::MsgsNoticed(_)
|
||||
| EventType::MsgDelivered { .. }
|
||||
| EventType::MsgFailed { .. }
|
||||
| EventType::MsgRead { .. }
|
||||
|
||||
10
src/chat.rs
10
src/chat.rs
@@ -1795,10 +1795,7 @@ pub async fn marknoticed_chat(context: &Context, chat_id: ChatId) -> Result<(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
context.emit_event(EventType::MsgsChanged {
|
||||
chat_id: ChatId::new(0),
|
||||
msg_id: MsgId::new(0),
|
||||
});
|
||||
context.emit_event(EventType::MsgsNoticed(chat_id));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1827,10 +1824,7 @@ pub async fn marknoticed_all_chats(context: &Context) -> Result<(), Error> {
|
||||
)
|
||||
.await?;
|
||||
|
||||
context.emit_event(EventType::MsgsChanged {
|
||||
msg_id: MsgId::new(0),
|
||||
chat_id: ChatId::new(0),
|
||||
});
|
||||
context.emit_event(EventType::MsgsNoticed(ChatId::new(0)));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use crate::error::{bail, ensure, format_err, Result};
|
||||
use crate::events::EventType;
|
||||
use crate::key::{DcKey, SignedPublicKey};
|
||||
use crate::login_param::LoginParam;
|
||||
use crate::message::{MessageState, MsgId};
|
||||
use crate::message::MessageState;
|
||||
use crate::mimeparser::AvatarAction;
|
||||
use crate::param::*;
|
||||
use crate::peerstate::*;
|
||||
@@ -263,7 +263,7 @@ impl Contact {
|
||||
/// Mark all messages sent by the given contact
|
||||
/// as *noticed*. See also dc_marknoticed_chat() and dc_markseen_msgs()
|
||||
///
|
||||
/// Calling this function usually results in the event `#DC_EVENT_MSGS_CHANGED`.
|
||||
/// Calling this function usually results in the event `#DC_EVENT_MSGS_NOTICED`.
|
||||
pub async fn mark_noticed(context: &Context, id: u32) {
|
||||
if context
|
||||
.sql
|
||||
@@ -274,10 +274,7 @@ impl Contact {
|
||||
.await
|
||||
.is_ok()
|
||||
{
|
||||
context.emit_event(EventType::MsgsChanged {
|
||||
chat_id: ChatId::new(0),
|
||||
msg_id: MsgId::new(0),
|
||||
});
|
||||
context.emit_event(EventType::MsgsNoticed(ChatId::new(0)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,6 +186,11 @@ pub enum EventType {
|
||||
#[strum(props(id = "2005"))]
|
||||
IncomingMsg { chat_id: ChatId, msg_id: MsgId },
|
||||
|
||||
/// Messages were seen or noticed.
|
||||
/// If chat_id is 0, this affects multiple chats.
|
||||
#[strum(props(id = "2008"))]
|
||||
MsgsNoticed(ChatId),
|
||||
|
||||
/// A single message is sent successfully. State changed from DC_STATE_OUT_PENDING to
|
||||
/// DC_STATE_OUT_DELIVERED, see dc_msg_get_state().
|
||||
#[strum(props(id = "2010"))]
|
||||
|
||||
@@ -1283,10 +1283,7 @@ pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> bool {
|
||||
}
|
||||
|
||||
if send_event {
|
||||
context.emit_event(EventType::MsgsChanged {
|
||||
chat_id: ChatId::new(0),
|
||||
msg_id: MsgId::new(0),
|
||||
});
|
||||
context.emit_event(EventType::MsgsNoticed(ChatId::new(0)));
|
||||
}
|
||||
|
||||
true
|
||||
|
||||
Reference in New Issue
Block a user