mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Update contact management
This commit is contained in:
parent
5603d1fc09
commit
9cfe296c53
@ -108,8 +108,8 @@ func syncContactsOnce(network: Network, postbox: Postbox, accountPeerId: PeerId)
|
||||
return appliedUpdatedPeers
|
||||
}
|
||||
|
||||
public func deleteContactPeerInteractively(account: Account, peerId: PeerId) -> Signal<Void, NoError> {
|
||||
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
|
||||
public func deleteContactPeerInteractively(account: Account, peerId: PeerId) -> Signal<Never, NoError> {
|
||||
return account.postbox.transaction { transaction -> Signal<Never, NoError> in
|
||||
if let peer = transaction.getPeer(peerId), let inputUser = apiInputUser(peer) {
|
||||
return account.network.request(Api.functions.contacts.deleteContacts(id: [inputUser]))
|
||||
|> map(Optional.init)
|
||||
@ -128,6 +128,7 @@ public func deleteContactPeerInteractively(account: Account, peerId: PeerId) ->
|
||||
}
|
||||
}
|
||||
}
|
||||
|> ignoreValues
|
||||
} else {
|
||||
return .complete()
|
||||
}
|
||||
|
@ -104,9 +104,16 @@ func fetchAndUpdateSupplementalCachedPeerData(peerId: PeerId, network: Network,
|
||||
}
|
||||
|
||||
func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network: Network, postbox: Postbox) -> Signal<Void, NoError> {
|
||||
return postbox.loadedPeerWithId(peerId)
|
||||
|> mapToSignal { peer -> Signal<Void, NoError> in
|
||||
if let inputUser = apiInputUser(peer) {
|
||||
return postbox.transaction { transaction -> (Api.InputUser?, Peer?) in
|
||||
if peerId == accountPeerId {
|
||||
return (.inputUserSelf, transaction.getPeer(peerId))
|
||||
} else {
|
||||
let peer = transaction.getPeer(peerId)
|
||||
return (peer.flatMap(apiInputUser), peer)
|
||||
}
|
||||
}
|
||||
|> mapToSignal { inputUser, maybePeer -> Signal<Void, NoError> in
|
||||
if let inputUser = inputUser {
|
||||
return network.request(Api.functions.users.getFullUser(id: inputUser))
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
@ -119,7 +126,7 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
||||
})
|
||||
transaction.updateCurrentPeerNotificationSettings([peerId: TelegramPeerNotificationSettings(apiSettings: userFull.notifySettings)])
|
||||
if let presence = TelegramUserPresence(apiUser: userFull.user) {
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: [peer.id: presence])
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: [telegramUser.id: presence])
|
||||
}
|
||||
}
|
||||
transaction.updatePeerCachedData(peerIds: [peerId], update: { peerId, current in
|
||||
@ -145,7 +152,7 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if let _ = peer as? TelegramGroup {
|
||||
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
return network.request(Api.functions.messages.getFullChat(chatId: peerId.id))
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
@ -221,7 +228,7 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId: PeerId, network
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if let inputChannel = apiInputChannel(peer) {
|
||||
} else if let inputChannel = maybePeer.flatMap(apiInputChannel) {
|
||||
return network.request(Api.functions.channels.getFullChannel(channel: inputChannel))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { error -> Signal<Api.messages.ChatFull?, NoError> in
|
||||
|
Loading…
x
Reference in New Issue
Block a user