mirror of
https://github.com/chatmail/core.git
synced 2026-04-25 09:26:30 +03:00
Move event emitting for a new message to a separate function
This commit is contained in:
16
src/chat.rs
16
src/chat.rs
@@ -545,6 +545,16 @@ impl ChatId {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Emits an appropriate event for a message. `important` is whether a notification should be
|
||||
/// shown.
|
||||
pub(crate) fn emit_msg_event(self, context: &Context, msg_id: MsgId, important: bool) {
|
||||
if important {
|
||||
context.emit_incoming_msg(self, msg_id);
|
||||
} else {
|
||||
context.emit_msgs_changed(self, msg_id);
|
||||
}
|
||||
}
|
||||
|
||||
/// Deletes a chat.
|
||||
pub async fn delete(self, context: &Context) -> Result<()> {
|
||||
ensure!(
|
||||
@@ -3469,11 +3479,7 @@ pub async fn add_device_msg_with_importance(
|
||||
}
|
||||
|
||||
if !msg_id.is_unset() {
|
||||
if important {
|
||||
context.emit_incoming_msg(chat_id, msg_id);
|
||||
} else {
|
||||
context.emit_msgs_changed(chat_id, msg_id);
|
||||
}
|
||||
chat_id.emit_msg_event(context, msg_id, important);
|
||||
}
|
||||
|
||||
Ok(msg_id)
|
||||
|
||||
Reference in New Issue
Block a user