Refactoring

This commit is contained in:
Ali
2021-09-23 19:57:25 +03:00
parent 3eead87254
commit 49279a33f0
20 changed files with 387 additions and 239 deletions

View File

@@ -1361,15 +1361,16 @@ private func addContactToExisting(context: AccountContext, parentController: Vie
guard let contactData = contactData else {
return
}
let _ = (context.account.postbox.contactPeersView(accountPeerId: nil, includePresences: false)
|> take(1)
let _ = (context.engine.data.get(
TelegramEngine.EngineData.Item.Contacts.List(includePresences: false)
)
|> deliverOnMainQueue).start(next: { view in
let phones = Set<String>(contactData.basicData.phoneNumbers.map {
return formatPhoneNumber($0.value)
})
var foundPeer: Peer?
var foundPeer: EnginePeer?
for peer in view.peers {
if let user = peer as? TelegramUser, let phone = user.phone {
if case let .user(user) = peer, let phone = user.phone {
let phone = formatPhoneNumber(phone)
if phones.contains(phone) {
foundPeer = peer
@@ -1377,7 +1378,7 @@ private func addContactToExisting(context: AccountContext, parentController: Vie
}
}
}
completion(foundPeer, stableId, contactData)
completion(foundPeer?._asPeer(), stableId, contactData)
})
})
}