Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions deltachat-jsonrpc/src/api/types/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,20 @@ pub enum EventType {
msg_id: u32,
},

/// A single message is read by the receiver. State changed from DC_STATE_OUT_DELIVERED to
/// DC_STATE_OUT_MDN_RCVD, see `Message.state`.
/// A single message is read by a receiver.
#[serde(rename_all = "camelCase")]
MsgRead {
/// ID of the chat which the message belongs to.
chat_id: u32,

/// ID of the message that was read.
msg_id: u32,

/// Read for the first time (e.g. by just one group member
/// / channel subscriber).
/// State changed from DC_STATE_OUT_DELIVERED to
/// DC_STATE_OUT_MDN_RCVD, see dc_msg_get_state().
first_time: bool,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is anyone going to use this? Otherwise if there are no API users probably better not add it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we're gonna need this on Desktop, at least right away.
About other platforms (Android, iOS) I'm not sure.

},

/// A single message was deleted.
Expand Down Expand Up @@ -540,9 +545,14 @@ impl From<CoreEventType> for EventType {
chat_id: chat_id.to_u32(),
msg_id: msg_id.to_u32(),
},
CoreEventType::MsgRead { chat_id, msg_id } => MsgRead {
CoreEventType::MsgRead {
chat_id,
msg_id,
first_time,
} => MsgRead {
chat_id: chat_id.to_u32(),
msg_id: msg_id.to_u32(),
first_time,
},
CoreEventType::MsgDeleted { chat_id, msg_id } => MsgDeleted {
chat_id: chat_id.to_u32(),
Expand Down
9 changes: 7 additions & 2 deletions src/events/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,19 @@ pub enum EventType {
msg_id: MsgId,
},

/// A single message is read by the receiver. State changed from DC_STATE_OUT_DELIVERED to
/// DC_STATE_OUT_MDN_RCVD, see dc_msg_get_state().
/// A single message is read by a receiver.
MsgRead {
/// ID of the chat which the message belongs to.
chat_id: ChatId,

/// ID of the message that was read.
msg_id: MsgId,

/// Read for the first time (e.g. by just one group member
/// / channel subscriber).
/// State changed from DC_STATE_OUT_DELIVERED to
/// DC_STATE_OUT_MDN_RCVD, see dc_msg_get_state().
first_time: bool,
},

/// A single message was deleted.
Expand Down
6 changes: 5 additions & 1 deletion src/mimeparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2596,8 +2596,12 @@ async fn handle_mdn(
(msg_id, from_id, timestamp_sent),
)
.await?;
context.emit_event(EventType::MsgRead {
chat_id,
msg_id,
first_time: !has_mdns,
});
if !has_mdns {
context.emit_event(EventType::MsgRead { chat_id, msg_id });
// note(treefit): only matters if it is the last message in chat (but probably too expensive to check, debounce also solves it)
chatlist_events::emit_chatlist_item_changed(context, chat_id);
}
Expand Down
Loading