mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Fix phone numbers
This commit is contained in:
parent
2ef76ae47b
commit
0cf8346c89
4 changed files with 47 additions and 15 deletions
|
|
@ -133,9 +133,31 @@ final class ContactsManager: ObservableObject {
|
|||
|
||||
MagicSearchSingleton.shared.searchForContacts(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
||||
self.friendListSuscription = self.friendList?.publisher?.onPresenceReceived?.postOnMainQueue { (cbValue: (friendList: FriendList, friends: [Friend])) in
|
||||
MagicSearchSingleton.shared.searchForContacts(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
self.friendListSuscription = nil
|
||||
self.friendListSuscription = self.friendList?.publisher?.onNewSipAddressDiscovered?.postOnMainQueue { (cbValue: (friendList: FriendList, linphoneFriend: Friend, sipUri: String)) in
|
||||
|
||||
cbValue.linphoneFriend.phoneNumbers.forEach { phone in
|
||||
do {
|
||||
let address = core.interpretUrl(url: phone, applyInternationalPrefix: true)
|
||||
|
||||
let presence = cbValue.linphoneFriend.getPresenceModelForUriOrTel(uriOrTel: address?.asStringUriOnly() ?? "")
|
||||
if address != nil && presence != nil {
|
||||
cbValue.linphoneFriend.edit()
|
||||
cbValue.linphoneFriend.addAddress(address: address!)
|
||||
cbValue.linphoneFriend.done()
|
||||
|
||||
self.avatarListModel.append(
|
||||
ContactAvatarModel(
|
||||
friend: cbValue.linphoneFriend,
|
||||
name: cbValue.linphoneFriend.name ?? "",
|
||||
address: cbValue.linphoneFriend.address?.clone()?.asStringUriOnly() ?? "",
|
||||
withPresence: true
|
||||
)
|
||||
)
|
||||
}
|
||||
} catch let error {
|
||||
print("\(#function) - Failed to create friend phone number for \(phone):", error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -224,11 +246,13 @@ final class ContactsManager: ObservableObject {
|
|||
friend.removeAddress(address: address)
|
||||
})
|
||||
contact.sipAddresses.forEach { sipAddress in
|
||||
let address = core.interpretUrl(url: sipAddress, applyInternationalPrefix: true)
|
||||
|
||||
if address != nil && ((friendAddresses.firstIndex(where: {$0.asString() == address?.asString()})) == nil) {
|
||||
friend.addAddress(address: address!)
|
||||
friendAddresses.append(address!)
|
||||
if !sipAddress.isEmpty {
|
||||
let address = core.interpretUrl(url: sipAddress, applyInternationalPrefix: true)
|
||||
|
||||
if address != nil && ((friendAddresses.firstIndex(where: {$0.asString() == address?.asString()})) == nil) {
|
||||
friend.addAddress(address: address!)
|
||||
friendAddresses.append(address!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,14 @@ final class CoreContext: ObservableObject {
|
|||
if cbVal.state == .Ok {
|
||||
self.loggingInProgress = false
|
||||
self.loggedIn = true
|
||||
|
||||
let newParams = cbVal.account.params?.clone()
|
||||
newParams?.internationalPrefix = "33"
|
||||
newParams?.internationalPrefixIsoCountryCode = "FRA"
|
||||
newParams?.useInternationalPrefixForCallsAndChats = true
|
||||
|
||||
cbVal.account.params = newParams
|
||||
|
||||
ContactsManager.shared.fetchContacts()
|
||||
} else if cbVal.state == .Progress {
|
||||
self.loggingInProgress = true
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ struct ContactsInnerFragment: View {
|
|||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
if !contactsManager.lastSearch.filter({ $0.friend?.starred == true }).isEmpty {
|
||||
if !contactsManager.avatarListModel.filter({ $0.friend?.starred == true }).isEmpty {
|
||||
HStack(alignment: .center) {
|
||||
Text("Favourites")
|
||||
.default_text_style_800(styleSize: 16)
|
||||
|
|
@ -80,7 +80,7 @@ struct ContactsInnerFragment: View {
|
|||
.listStyle(.plain)
|
||||
.overlay(
|
||||
VStack {
|
||||
if contactsManager.lastSearch.isEmpty {
|
||||
if contactsManager.avatarListModel.isEmpty {
|
||||
Spacer()
|
||||
Image("illus-belledonne")
|
||||
.resizable()
|
||||
|
|
|
|||
|
|
@ -32,21 +32,21 @@ struct ContactsListFragment: View {
|
|||
var startCallFunc: (_ addr: Address) -> Void
|
||||
|
||||
var body: some View {
|
||||
ForEach(0..<contactsManager.lastSearch.count, id: \.self) { index in
|
||||
ForEach(0..<contactsManager.avatarListModel.count, id: \.self) { index in
|
||||
HStack {
|
||||
HStack {
|
||||
if index == 0
|
||||
|| contactsManager.lastSearch[index].friend?.name!.lowercased().folding(
|
||||
|| contactsManager.avatarListModel[index].name.lowercased().folding(
|
||||
options: .diacriticInsensitive,
|
||||
locale: .current
|
||||
).first
|
||||
!= contactsManager.lastSearch[index-1].friend?.name!.lowercased().folding(
|
||||
!= contactsManager.avatarListModel[index-1].name.lowercased().folding(
|
||||
options: .diacriticInsensitive,
|
||||
locale: .current
|
||||
).first {
|
||||
Text(
|
||||
String(
|
||||
(contactsManager.lastSearch[index].friend?.name!.uppercased().folding(
|
||||
(contactsManager.avatarListModel[index].name.uppercased().folding(
|
||||
options: .diacriticInsensitive,
|
||||
locale: .current
|
||||
).first)!))
|
||||
|
|
@ -72,7 +72,7 @@ struct ContactsListFragment: View {
|
|||
.frame(width: 50, height: 50)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
Text((contactsManager.lastSearch[index].friend?.name)!)
|
||||
Text(contactsManager.avatarListModel[index].name)
|
||||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue