Initial implementation of the PSA API

This commit is contained in:
Ali
2020-04-24 23:18:44 +04:00
parent faf022b9ec
commit c4004a23ee
68 changed files with 4928 additions and 4378 deletions

View File

@@ -562,6 +562,13 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
strongSelf.toggleArchivedFolderHiddenByDefault()
}
self.chatListDisplayNode.containerNode.hidePsa = { [weak self] messageId in
guard let strongSelf = self else {
return
}
strongSelf.hidePsa(messageId)
}
self.chatListDisplayNode.containerNode.deletePeerChat = { [weak self] peerId in
guard let strongSelf = self else {
return
@@ -569,10 +576,10 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
strongSelf.deletePeerChat(peerId: peerId)
}
self.chatListDisplayNode.containerNode.peerSelected = { [weak self] peer, animated, isAd in
self.chatListDisplayNode.containerNode.peerSelected = { [weak self] peer, animated, promoInfo in
if let strongSelf = self {
if let navigationController = strongSelf.navigationController as? NavigationController {
if isAd {
if let promoInfo = promoInfo, case .proxy = promoInfo {
let _ = (ApplicationSpecificNotice.getProxyAdsAcknowledgment(accountManager: strongSelf.context.sharedContext.accountManager)
|> deliverOnMainQueue).start(next: { value in
guard let strongSelf = self else {
@@ -1982,6 +1989,32 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
})
}
func hidePsa(_ id: MessageId) {
let _ = (self.context.account.postbox.transaction { transaction -> PeerId? in
var peerId: PeerId?
for item in transaction.getAdditionalChatListItems() {
if let item = item as? PromoChatListItem {
peerId = item.peerId
}
}
return peerId
}
|> deliverOnMainQueue).start(next: { [weak self] _ in
guard let strongSelf = self else {
return
}
strongSelf.chatListDisplayNode.containerNode.updateState { state in
var state = state
state.hiddenPsaPeerId = id.peerId
state.peerIdWithRevealedOptions = nil
return state
}
let _ = hideAccountPromoInfoChat(account: strongSelf.context.account, peerId: id.peerId).start()
})
}
func deletePeerChat(peerId: PeerId) {
let _ = (self.context.account.postbox.transaction { transaction -> RenderedPeer? in
guard let peer = transaction.getPeer(peerId) else {