mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Add core delegate in contactsManager to get and remove friends from the list
This commit is contained in:
parent
b83ae7fde6
commit
5989887723
1 changed files with 28 additions and 0 deletions
|
|
@ -28,6 +28,8 @@ import Combine
|
|||
|
||||
final class ContactsManager: ObservableObject {
|
||||
|
||||
static let TAG = "[ContactsManager]"
|
||||
|
||||
static let shared = ContactsManager()
|
||||
|
||||
private var coreContext = CoreContext.shared
|
||||
|
|
@ -42,6 +44,7 @@ final class ContactsManager: ObservableObject {
|
|||
@Published var lastSearchSuggestions: [SearchResult] = []
|
||||
@Published var avatarListModel: [ContactAvatarModel] = []
|
||||
|
||||
private var coreDelegate: CoreDelegate?
|
||||
private var friendListDelegate: FriendListDelegate?
|
||||
|
||||
private init() {}
|
||||
|
|
@ -242,6 +245,8 @@ final class ContactsManager: ObservableObject {
|
|||
print("\(#function) - access denied")
|
||||
}
|
||||
}
|
||||
|
||||
self.addCoreDelegate(core: core)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -453,6 +458,29 @@ final class ContactsManager: ObservableObject {
|
|||
completion(self.getFriendWithAddress(address: address))
|
||||
}
|
||||
}
|
||||
|
||||
func addCoreDelegate(core: Core) {
|
||||
self.coreDelegate = CoreDelegateStub(
|
||||
onFriendListCreated: { (_: Core, friendList: FriendList) in
|
||||
Log.info("\(ContactsManager.TAG) Friend list \(friendList.displayName) created")
|
||||
if self.friendListDelegate != nil {
|
||||
friendList.addDelegate(delegate: self.friendListDelegate!)
|
||||
}
|
||||
}, onFriendListRemoved: { (_: Core, friendList: FriendList) in
|
||||
Log.info("\(ContactsManager.TAG) Friend list \(friendList.displayName) removed")
|
||||
if self.friendListDelegate != nil {
|
||||
friendList.removeDelegate(delegate: self.friendListDelegate!)
|
||||
}
|
||||
}, onDefaultAccountChanged: { (_: Core, _: Account?) in
|
||||
Log.info("\(ContactsManager.TAG) Default account changed, update all contacts' model showTrust value")
|
||||
//updateContactsModelDependingOnDefaultAccountMode()
|
||||
}
|
||||
)
|
||||
|
||||
if self.coreDelegate != nil {
|
||||
core.addDelegate(delegate: self.coreDelegate!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct PhoneNumber {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue