forked from mirrors/linphone-iphone
Fix presence of phone numbers and updated subscription once for friends lists
This commit is contained in:
parent
6dfc870624
commit
a34a426827
1 changed files with 12 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ import linphonesw
|
|||
import Contacts
|
||||
import SwiftUI
|
||||
import ContactsUI
|
||||
import Combine
|
||||
|
||||
final class ContactsManager: ObservableObject {
|
||||
|
||||
|
|
@ -38,6 +39,8 @@ final class ContactsManager: ObservableObject {
|
|||
@Published var lastSearchSuggestions: [SearchResult] = []
|
||||
@Published var avatarListModel: [ContactAvatarModel] = []
|
||||
|
||||
private var friendListSuscription: AnyCancellable?
|
||||
|
||||
private init() {
|
||||
fetchContacts()
|
||||
}
|
||||
|
|
@ -137,6 +140,15 @@ final class ContactsManager: ObservableObject {
|
|||
}
|
||||
}
|
||||
|
||||
self.linphoneFriendList?.updateSubscriptions()
|
||||
self.friendList?.updateSubscriptions()
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
MagicSearchSingleton.shared.searchForContacts(sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
}
|
||||
}
|
||||
|
|
@ -179,10 +191,8 @@ final class ContactsManager: ObservableObject {
|
|||
if resultFriend != nil {
|
||||
if linphoneFriend && existingFriend == nil {
|
||||
_ = self.linphoneFriendList?.addFriend(linphoneFriend: resultFriend!)
|
||||
self.linphoneFriendList?.updateSubscriptions()
|
||||
} else if existingFriend == nil {
|
||||
_ = self.friendList?.addLocalFriend(linphoneFriend: resultFriend!)
|
||||
self.friendList?.updateSubscriptions()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue