Contacts fix on deletion

This commit is contained in:
Julien Wadel 2022-11-21 16:57:47 +01:00
parent 8fdf862a27
commit 91833adbae
4 changed files with 7 additions and 2 deletions

View file

@ -100,6 +100,10 @@ QSharedPointer<ContactModel> ContactsListModel::findContactModelFromUsername (co
}
// -----------------------------------------------------------------------------
ContactModel *ContactsListModel::getContactModelFromAddress (const QString& address) const{
auto contact = findContactModelFromSipAddress(address);
return contact.get();
}
ContactModel *ContactsListModel::addContact (VcardModel *vcardModel) {
// Try to merge vcardModel to an existing contact.

View file

@ -49,6 +49,7 @@ public:
QSharedPointer<ContactModel> findContactModelFromSipAddress (const QString &sipAddress) const;
QSharedPointer<ContactModel> findContactModelFromUsername (const QString &username) const;
Q_INVOKABLE ContactModel *getContactModelFromAddress (const QString& address) const;
Q_INVOKABLE ContactModel *addContact (VcardModel *vcardModel);
Q_INVOKABLE void removeContact (ContactModel *contact);

View file

@ -79,7 +79,7 @@ function removeContact () {
if (status) {
window.unlockView()
window.setView('Contacts')
Linphone.ContactsListModel.remove(_contact)
Linphone.ContactsListModel.removeContact(_contact)
}
})
}

View file

@ -35,7 +35,7 @@ ColumnLayout {
Component.onDestruction: {_vcard=null}// Need to set it to null because of not calling destructor if not.
Component.onCompleted:{
var sipAddress = contactEdit.sipAddress
var contact = contactEdit._contact = SipAddressesModel.mapSipAddressToContact(sipAddress)
var contact = contactEdit._contact = ContactsListModel.getContactModelFromAddress(sipAddress)
if (!contact) {
// Add a new contact.