mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-07 06:43:43 +00:00
Change addContactInteractively to accept PeerId instead of Peer
This commit is contained in:
parent
cf5ad88720
commit
24c0dd631f
@ -44,9 +44,9 @@ public enum AddContactError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
public func addContactInteractively(account: Account, peer: Peer, firstName: String, lastName: String, phoneNumber: String) -> Signal<Never, AddContactError> {
|
public func addContactInteractively(account: Account, peerId: PeerId, firstName: String, lastName: String, phoneNumber: String) -> Signal<Never, AddContactError> {
|
||||||
return account.postbox.transaction { transaction -> (Api.InputUser, String)? in
|
return account.postbox.transaction { transaction -> (Api.InputUser, String)? in
|
||||||
if let user = transaction.getPeer(peer.id) as? TelegramUser, let inputUser = apiInputUser(user) {
|
if let user = transaction.getPeer(peerId) as? TelegramUser, let inputUser = apiInputUser(user) {
|
||||||
return (inputUser, user.phone == nil ? phoneNumber : "")
|
return (inputUser, user.phone == nil ? phoneNumber : "")
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
@ -80,8 +80,8 @@ public func addContactInteractively(account: Account, peer: Peer, firstName: Str
|
|||||||
return updated
|
return updated
|
||||||
})
|
})
|
||||||
var peerIds = transaction.getContactPeerIds()
|
var peerIds = transaction.getContactPeerIds()
|
||||||
if !peerIds.contains(peer.id) {
|
if !peerIds.contains(peerId) {
|
||||||
peerIds.insert(peer.id)
|
peerIds.insert(peerId)
|
||||||
transaction.replaceContactPeerIds(peerIds)
|
transaction.replaceContactPeerIds(peerIds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user