From fb872fb71914dd12fb0629178cfaee9078d72526 Mon Sep 17 00:00:00 2001 From: Sergei Kobec Date: Thu, 28 Jan 2016 11:32:48 +0200 Subject: [PATCH] Fixed issue in person update logic. Now person insert/update/delete callback will invoke only when person match to provider filter. Change-Id: I6d5bd03084be992af3c0c9fcab53b01d2d077c86 --- lib-contact/src/Contacts/List/Model/PersonProvider.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib-contact/src/Contacts/List/Model/PersonProvider.cpp b/lib-contact/src/Contacts/List/Model/PersonProvider.cpp index fea9d66..30229fd 100644 --- a/lib-contact/src/Contacts/List/Model/PersonProvider.cpp +++ b/lib-contact/src/Contacts/List/Model/PersonProvider.cpp @@ -171,18 +171,27 @@ void PersonProvider::onChanged(const char *viewUri) void PersonProvider::notify(contacts_changed_e changeType, int contactId) { + auto getPerson = [this, contactId]() -> PersonPtr { + contacts_record_h personRecord = getPersonRecord(contactId, m_ListFilterType); + return personRecord ? PersonPtr(new Person(personRecord)) : nullptr; + }; + PersonPtr person; switch (changeType) { case CONTACTS_CHANGE_INSERTED: - person.reset(new Person(getPersonRecord(contactId, m_ListFilterType))); - if (m_InsertCallback) { + person = getPerson(); + if (m_InsertCallback && person) { m_InsertCallback(std::move(person)); } break; case CONTACTS_CHANGE_UPDATED: //Todo: If will be link contact functionality, update only when display contact changed - person.reset(new Person(getPersonRecord(contactId, m_ListFilterType))); + person = getPerson(); + if (!person) { + return; + } + //Fallthrough case statement by intention case CONTACTS_CHANGE_DELETED: { auto it = m_ChangeCallbacks.find(contactId); -- 2.7.4