emit MsgsChanged(chat_id, 0) on full downloads (#2696)

before, MsgsChanged(chat_id, new_msg_id) was emitted,
but that does not cover the deleted message.

in theory, we could emit both,
however, that would just be a waste of refresh in uis.

also before, events were used this way,
however, also the documentations are updated to
reflect reality better.
This commit is contained in:
bjoern
2021-09-20 20:50:22 +02:00
committed by GitHub
parent 3e0f601212
commit 43d1d9b1b3
3 changed files with 10 additions and 4 deletions

View File

@@ -5141,8 +5141,8 @@ void dc_event_unref(dc_event_t* event);
* - Chats created, deleted or archived * - Chats created, deleted or archived
* - A draft has been set * - A draft has been set
* *
* @param data1 (int) chat_id for single added messages * @param data1 (int) chat_id if only a single chat is affected by the changes, otherwise 0
* @param data2 (int) msg_id for single added messages * @param data2 (int) msg_id if only a single message is affected by the changes, otherwise 0
*/ */
#define DC_EVENT_MSGS_CHANGED 2000 #define DC_EVENT_MSGS_CHANGED 2000

View File

@@ -327,7 +327,12 @@ pub(crate) async fn dc_receive_imf_inner(
} }
} }
if let Some(create_event_to_send) = create_event_to_send { if replace_partial_download {
context.emit_event(EventType::MsgsChanged {
msg_id: MsgId::new(0),
chat_id,
});
} else if let Some(create_event_to_send) = create_event_to_send {
for (chat_id, msg_id) in created_db_entries { for (chat_id, msg_id) in created_db_entries {
let event = match create_event_to_send { let event = match create_event_to_send {
CreateEvent::MsgsChanged => EventType::MsgsChanged { msg_id, chat_id }, CreateEvent::MsgsChanged => EventType::MsgsChanged { msg_id, chat_id },

View File

@@ -203,7 +203,8 @@ pub enum EventType {
/// - Chats created, deleted or archived /// - Chats created, deleted or archived
/// - A draft has been set /// - A draft has been set
/// ///
/// The `chat_id` and `msg_id` values will be 0 if more than one message is changed. /// `chat_id` is set if only a single chat is affected by the changes, otherwise 0.
/// `msg_id` is set if only a single message is affected by the changes, otherwise 0.
#[strum(props(id = "2000"))] #[strum(props(id = "2000"))]
MsgsChanged { chat_id: ChatId, msg_id: MsgId }, MsgsChanged { chat_id: ChatId, msg_id: MsgId },