From 03ca623e4fc50552fd5b2bc219bd1d033eb60814 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Mon, 24 Jul 2017 12:29:18 +0200 Subject: [PATCH] do not erase existing contact when cancelling the edition --- Classes/ContactDetailsView.m | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index bc75671ff..dcb94708e 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -102,6 +102,21 @@ } } +- (void)modifyTmpContact:(Contact *)acontact { + if (_tmpContact) { + _tmpContact = nil; + } + if (!acontact) { + return; + } + _tmpContact = [[Contact alloc] initWithPerson:ABPersonCreate()]; + _tmpContact.firstName = acontact.firstName.copy; + _tmpContact.lastName = acontact.lastName.copy; + _tmpContact.sipAddresses = acontact.sipAddresses.copy; + _tmpContact.emails = acontact.emails.copy; + _tmpContact.phoneNumbers = acontact.phoneNumbers.copy; +} + - (void)addCurrentContactContactField:(NSString *)address { LinphoneAddress *linphoneAddress = linphone_core_interpret_url(LC, address.UTF8String); NSString *username = @@ -136,10 +151,12 @@ } - (void)editContact:(Contact *)acontact { + [self modifyTmpContact:acontact]; [self selectContact:acontact andReload:YES]; } - (void)editContact:(Contact *)acontact address:(NSString *)address { + [self modifyTmpContact:acontact]; [self selectContact:acontact andReload:NO]; [self addCurrentContactContactField:address]; } @@ -467,12 +484,7 @@ static UICompositeViewDescription *compositeDescription = nil; _deleteButton.hidden = FALSE; _editButton.hidden = FALSE; } else { - _tmpContact = [[Contact alloc] initWithPerson:ABPersonCreate()]; - _tmpContact.firstName = _contact.firstName.copy; - _tmpContact.lastName = _contact.lastName.copy; - _tmpContact.sipAddresses = _contact.sipAddresses.copy; - _tmpContact.emails = _contact.emails.copy; - _tmpContact.phoneNumbers = _contact.phoneNumbers.copy; + [self modifyTmpContact:_contact]; [self setEditing:TRUE]; } }