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" # Explicitly rename contact on ac2 to "Renamed"
ac2.create_contact(contact, name="Renamed") ac2.create_contact(contact, name="Renamed")
assert 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" # ac1 also renames itself into "Renamed"
assert update_name() == "Renamed" assert update_name() == "Renamed"

View File

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