mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 02:58:07 +00:00
Prevent crash by copying Friend addresses and phone numbers before removal
This commit is contained in:
parent
a7e2ebb600
commit
525e705b59
1 changed files with 8 additions and 4 deletions
|
|
@ -292,9 +292,11 @@ final class ContactsManager: ObservableObject {
|
|||
friend.organization = contact.organizationName
|
||||
|
||||
var friendAddresses: [Address] = []
|
||||
friend.addresses.forEach({ address in
|
||||
let existingAddresses = Array(friend.addresses)
|
||||
for address in existingAddresses {
|
||||
friend.removeAddress(address: address)
|
||||
})
|
||||
}
|
||||
|
||||
contact.sipAddresses.forEach { sipAddress in
|
||||
if !sipAddress.isEmpty {
|
||||
let address = core.interpretUrl(url: sipAddress, applyInternationalPrefix: true)
|
||||
|
|
@ -307,9 +309,11 @@ final class ContactsManager: ObservableObject {
|
|||
}
|
||||
|
||||
var friendPhoneNumbers: [PhoneNumber] = []
|
||||
friend.phoneNumbersWithLabel.forEach({ phoneNumber in
|
||||
let existingPhoneNumbers = Array(friend.phoneNumbersWithLabel)
|
||||
for phoneNumber in existingPhoneNumbers {
|
||||
friend.removePhoneNumberWithLabel(phoneNumber: phoneNumber)
|
||||
})
|
||||
}
|
||||
|
||||
contact.phoneNumbers.forEach { phone in
|
||||
do {
|
||||
if (friendPhoneNumbers.firstIndex(where: {$0.num == phone.num})) == nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue