Set contact ID in ContactsChanged on modification

This commit is contained in:
Alexander Krotov
2020-09-19 18:15:36 +03:00
committed by link2xt
parent 332a387c98
commit fe1c99c5e8
2 changed files with 8 additions and 7 deletions

View File

@@ -1750,6 +1750,8 @@ class TestOnlineAccount:
# Explicitly rename contact on ac2 to "Renamed"
ac2.create_contact(contact, name="Renamed")
assert contact.name == "Renamed"
ev = ac2._evtracker.get_matching("DC_EVENT_CONTACTS_CHANGED")
assert ev.data1 == contact.id
# ac1 also renames itself into "Renamed"
assert update_name() == "Renamed"

View File

@@ -247,13 +247,12 @@ impl Contact {
let (contact_id, sth_modified) =
Contact::add_or_lookup(context, name, addr, Origin::ManuallyCreated).await?;
let blocked = Contact::is_blocked_load(context, contact_id).await;
context.emit_event(EventType::ContactsChanged(
if sth_modified == Modifier::Created {
Some(contact_id)
} else {
None
},
));
match sth_modified {
Modifier::None => {}
Modifier::Modified | Modifier::Created => {
context.emit_event(EventType::ContactsChanged(Some(contact_id)))
}
}
if blocked {
Contact::unblock(context, contact_id).await;
}