mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Frozen account improvements
This commit is contained in:
parent
ef3eb05d69
commit
5e79ec4b32
@ -3936,13 +3936,13 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
}
|
||||
|
||||
if resetCurrentEntry {
|
||||
strongSelf.selectTab(id: selectedEntryId)
|
||||
strongSelf.selectTab(id: selectedEntryId, switchToChatsIfNeeded: false)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
private func selectTab(id: ChatListFilterTabEntryId) {
|
||||
if self.parent == nil {
|
||||
private func selectTab(id: ChatListFilterTabEntryId, switchToChatsIfNeeded: Bool = true) {
|
||||
if self.parent == nil, switchToChatsIfNeeded {
|
||||
if let navigationController = self.context.sharedContext.mainWindow?.viewController as? NavigationController {
|
||||
for controller in navigationController.viewControllers {
|
||||
if let controller = controller as? TabBarController {
|
||||
@ -6308,6 +6308,9 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
}
|
||||
|
||||
var isStoryPostingAvailable: Bool {
|
||||
guard !self.context.isFrozen else {
|
||||
return false
|
||||
}
|
||||
switch self.storyPostingAvailability {
|
||||
case .enabled:
|
||||
return true
|
||||
|
@ -139,6 +139,7 @@ private func hashForStickerPackInfos(_ infos: [StickerPackCollectionInfo]) -> In
|
||||
private enum SynchronizeInstalledStickerPacksError {
|
||||
case restart
|
||||
case done
|
||||
case frozen
|
||||
}
|
||||
|
||||
private func fetchStickerPack(network: Network, info: StickerPackCollectionInfo) -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> {
|
||||
@ -484,7 +485,7 @@ private func continueSynchronizeInstalledStickerPacks(transaction: Transaction,
|
||||
}
|
||||
|> mapToSignal { result -> Signal<Void, SynchronizeInstalledStickerPacksError> in
|
||||
guard let result else {
|
||||
return .complete()
|
||||
return .fail(.frozen)
|
||||
}
|
||||
return postbox.transaction { transaction -> Signal<Void, SynchronizeInstalledStickerPacksError> in
|
||||
let checkLocalCollectionInfos = transaction.getItemCollectionsInfos(namespace: collectionNamespace).map { $0.1 as! StickerPackCollectionInfo }
|
||||
@ -717,6 +718,8 @@ private func continueSynchronizeInstalledStickerPacks(transaction: Transaction,
|
||||
return ((sequence
|
||||
|> `catch` { error -> Signal<Void, SynchronizeInstalledStickerPacksError> in
|
||||
switch error {
|
||||
case .frozen:
|
||||
return .fail(.frozen)
|
||||
case .done:
|
||||
return .fail(.done)
|
||||
case .restart:
|
||||
|
@ -172,10 +172,14 @@ private func requestStarsRevenueStats(postbox: Postbox, network: Network, peerId
|
||||
}
|
||||
|
||||
return network.request(Api.functions.payments.getStarsRevenueStats(flags: flags, peer: inputPeer))
|
||||
|> retryRequestIfNotFrozen
|
||||
|> map { result -> StarsRevenueStats? in
|
||||
guard let result else {
|
||||
return nil
|
||||
}
|
||||
return StarsRevenueStats(apiStarsRevenueStats: result, peerId: peerId)
|
||||
}
|
||||
|> retryRequest
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,9 +445,12 @@ private func _internal_requestStarsSubscriptions(account: Account, peerId: Engin
|
||||
flags |= (1 << 0)
|
||||
}
|
||||
return account.network.request(Api.functions.payments.getStarsSubscriptions(flags: flags, peer: inputPeer, offset: offset))
|
||||
|> retryRequest
|
||||
|> retryRequestIfNotFrozen
|
||||
|> castError(RequestStarsSubscriptionsError.self)
|
||||
|> mapToSignal { result -> Signal<InternalStarsStatus, RequestStarsSubscriptionsError> in
|
||||
guard let result else {
|
||||
return .single(InternalStarsStatus(balance: .zero, subscriptionsMissingBalance: nil, subscriptions: [], nextSubscriptionsOffset: nil, transactions: [], nextTransactionsOffset: nil))
|
||||
}
|
||||
return account.postbox.transaction { transaction -> InternalStarsStatus in
|
||||
switch result {
|
||||
case let .starsStatus(_, balance, subscriptions, subscriptionsNextOffset, subscriptionsMissingBalance, _, _, chats, users):
|
||||
|
@ -548,8 +548,11 @@ func _internal_adminedPublicChannels(account: Account, scope: AdminedPublicChann
|
||||
let accountPeerId = account.peerId
|
||||
|
||||
return account.network.request(Api.functions.channels.getAdminedPublicChannels(flags: flags))
|
||||
|> retryRequest
|
||||
|> retryRequestIfNotFrozen
|
||||
|> mapToSignal { result -> Signal<[TelegramAdminedPublicChannel], NoError> in
|
||||
guard let result else {
|
||||
return .single([])
|
||||
}
|
||||
return account.postbox.transaction { transaction -> [TelegramAdminedPublicChannel] in
|
||||
let chats: [Api.Chat]
|
||||
var subscriberCounts: [PeerId: Int] = [:]
|
||||
@ -675,8 +678,11 @@ func _internal_channelsForPublicReaction(account: Account, useLocalCache: Bool)
|
||||
}
|
||||
|> mapToSignal { cachedPeers in
|
||||
let remote: Signal<[Peer], NoError> = account.network.request(Api.functions.channels.getAdminedPublicChannels(flags: 0))
|
||||
|> retryRequest
|
||||
|> retryRequestIfNotFrozen
|
||||
|> mapToSignal { result -> Signal<[Peer], NoError> in
|
||||
guard let result else {
|
||||
return .single([])
|
||||
}
|
||||
return account.postbox.transaction { transaction -> [Peer] in
|
||||
let chats: [Api.Chat]
|
||||
let parsedPeers: AccumulatedPeers
|
||||
|
@ -84,35 +84,38 @@ func _internal_channelMembers(postbox: Postbox, network: Network, accountPeerId:
|
||||
}
|
||||
}
|
||||
return network.request(Api.functions.channels.getParticipants(channel: inputChannel, filter: apiFilter, offset: offset, limit: limit, hash: hash))
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<[RenderedChannelParticipant]?, NoError> in
|
||||
return postbox.transaction { transaction -> [RenderedChannelParticipant]? in
|
||||
var items: [RenderedChannelParticipant] = []
|
||||
switch result {
|
||||
case let .channelParticipants(_, participants, chats, users):
|
||||
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
var peers: [PeerId: Peer] = [:]
|
||||
for id in parsedPeers.allIds {
|
||||
if let peer = transaction.getPeer(id) {
|
||||
peers[peer.id] = peer
|
||||
}
|
||||
|> retryRequestIfNotFrozen
|
||||
|> mapToSignal { result -> Signal<[RenderedChannelParticipant]?, NoError> in
|
||||
guard let result else {
|
||||
return .single(nil)
|
||||
}
|
||||
return postbox.transaction { transaction -> [RenderedChannelParticipant]? in
|
||||
var items: [RenderedChannelParticipant] = []
|
||||
switch result {
|
||||
case let .channelParticipants(_, participants, chats, users):
|
||||
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
var peers: [PeerId: Peer] = [:]
|
||||
for id in parsedPeers.allIds {
|
||||
if let peer = transaction.getPeer(id) {
|
||||
peers[peer.id] = peer
|
||||
}
|
||||
|
||||
for participant in CachedChannelParticipants(apiParticipants: participants).participants {
|
||||
if let peer = parsedPeers.get(participant.peerId) {
|
||||
var renderedPresences: [PeerId: PeerPresence] = [:]
|
||||
if let presence = transaction.getPeerPresence(peerId: participant.peerId) {
|
||||
renderedPresences[participant.peerId] = presence
|
||||
}
|
||||
items.append(RenderedChannelParticipant(participant: participant, peer: peer, peers: peers, presences: renderedPresences))
|
||||
}
|
||||
|
||||
for participant in CachedChannelParticipants(apiParticipants: participants).participants {
|
||||
if let peer = parsedPeers.get(participant.peerId) {
|
||||
var renderedPresences: [PeerId: PeerPresence] = [:]
|
||||
if let presence = transaction.getPeerPresence(peerId: participant.peerId) {
|
||||
renderedPresences[participant.peerId] = presence
|
||||
}
|
||||
items.append(RenderedChannelParticipant(participant: participant, peer: peer, peers: peers, presences: renderedPresences))
|
||||
}
|
||||
case .channelParticipantsNotModified:
|
||||
return nil
|
||||
}
|
||||
return items
|
||||
}
|
||||
case .channelParticipantsNotModified:
|
||||
return nil
|
||||
}
|
||||
return items
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return .single([])
|
||||
|
@ -27,8 +27,11 @@ func _internal_notificationExceptionsList(accountPeerId: PeerId, postbox: Postbo
|
||||
}
|
||||
|
||||
return network.request(Api.functions.account.getNotifyExceptions(flags: flags, peer: nil))
|
||||
|> retryRequest
|
||||
|> retryRequestIfNotFrozen
|
||||
|> mapToSignal { result -> Signal<NotificationExceptionsList, NoError> in
|
||||
guard let result else {
|
||||
return .single(NotificationExceptionsList(peers: [:], settings: [:]))
|
||||
}
|
||||
return postbox.transaction { transaction -> NotificationExceptionsList in
|
||||
switch result {
|
||||
case let .updates(updates, users, chats, _, _):
|
||||
|
@ -76,8 +76,11 @@ func fetchAndUpdateSupplementalCachedPeerData(peerId rawPeerId: PeerId, accountP
|
||||
}
|
||||
} else if let inputPeer = apiInputPeer(peer) {
|
||||
return network.request(Api.functions.messages.getPeerSettings(peer: inputPeer))
|
||||
|> retryRequest
|
||||
|> retryRequestIfNotFrozen
|
||||
|> mapToSignal { peerSettings -> Signal<Bool, NoError> in
|
||||
guard let peerSettings else {
|
||||
return .single(false)
|
||||
}
|
||||
return postbox.transaction { transaction -> Bool in
|
||||
let parsedPeers: AccumulatedPeers
|
||||
|
||||
@ -454,8 +457,11 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee
|
||||
}
|
||||
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
return network.request(Api.functions.messages.getFullChat(chatId: peerId.id._internalGetInt64Value()))
|
||||
|> retryRequest
|
||||
|> retryRequestIfNotFrozen
|
||||
|> mapToSignal { result -> Signal<Bool, NoError> in
|
||||
guard let result else {
|
||||
return .single(false)
|
||||
}
|
||||
return postbox.transaction { transaction -> Bool in
|
||||
switch result {
|
||||
case let .chatFull(fullChat, chats, users):
|
||||
|
@ -78,8 +78,11 @@ public final class BlockedPeersContext {
|
||||
}
|
||||
|
||||
self.disposable.set((self.account.network.request(Api.functions.contacts.getBlocked(flags: flags, offset: Int32(self._state.peers.count), limit: limit))
|
||||
|> retryRequest
|
||||
|> retryRequestIfNotFrozen
|
||||
|> mapToSignal { result -> Signal<(peers: [RenderedPeer], canLoadMore: Bool, totalCount: Int?), NoError> in
|
||||
guard let result else {
|
||||
return .single((peers: [], canLoadMore: false, totalCount: 0))
|
||||
}
|
||||
return postbox.transaction { transaction -> (peers: [RenderedPeer], canLoadMore: Bool, totalCount: Int?) in
|
||||
switch result {
|
||||
case let .blocked(blocked, chats, users):
|
||||
|
@ -34,8 +34,11 @@ public final class ChatThemes: Codable, Equatable {
|
||||
func _internal_getChatThemes(accountManager: AccountManager<TelegramAccountManagerTypes>, network: Network, forceUpdate: Bool = false, onlyCached: Bool = false) -> Signal<[TelegramTheme], NoError> {
|
||||
let fetch: ([TelegramTheme]?, Int64?) -> Signal<[TelegramTheme], NoError> = { current, hash in
|
||||
return network.request(Api.functions.account.getChatThemes(hash: hash ?? 0))
|
||||
|> retryRequest
|
||||
|> retryRequestIfNotFrozen
|
||||
|> mapToSignal { result -> Signal<[TelegramTheme], NoError> in
|
||||
guard let result else {
|
||||
return .complete()
|
||||
}
|
||||
switch result {
|
||||
case let .themes(hash, apiThemes):
|
||||
let result = apiThemes.compactMap { TelegramTheme(apiTheme: $0) }
|
||||
|
@ -7,8 +7,11 @@ import TelegramApi
|
||||
public func telegramWallpapers(postbox: Postbox, network: Network, forceUpdate: Bool = false) -> Signal<[TelegramWallpaper], NoError> {
|
||||
let fetch: ([TelegramWallpaper]?, Int64?) -> Signal<[TelegramWallpaper], NoError> = { current, hash in
|
||||
network.request(Api.functions.account.getWallPapers(hash: hash ?? 0))
|
||||
|> retryRequest
|
||||
|> retryRequestIfNotFrozen
|
||||
|> mapToSignal { result -> Signal<([TelegramWallpaper], Int64), NoError> in
|
||||
guard let result else {
|
||||
return .single(([], -1))
|
||||
}
|
||||
switch result {
|
||||
case let .wallPapers(hash, wallpapers):
|
||||
var items: [TelegramWallpaper] = []
|
||||
|
@ -15,7 +15,7 @@ import TelegramPresentationData
|
||||
import TelegramNotices
|
||||
|
||||
extension ChatControllerImpl {
|
||||
func presentAccountFrozenInfoIfNeeded() -> Bool {
|
||||
func presentAccountFrozenInfoIfNeeded(delay: Bool = false) -> Bool {
|
||||
if self.context.isFrozen {
|
||||
let accountFreezeConfiguration = AccountFreezeConfiguration.with(appConfiguration: self.context.currentAppConfiguration.with { $0 })
|
||||
if let freezeAppealUrl = accountFreezeConfiguration.freezeAppealUrl {
|
||||
@ -24,7 +24,16 @@ extension ChatControllerImpl {
|
||||
return false
|
||||
}
|
||||
}
|
||||
self.push(self.context.sharedContext.makeAccountFreezeInfoScreen(context: self.context))
|
||||
let present = {
|
||||
self.push(self.context.sharedContext.makeAccountFreezeInfoScreen(context: self.context))
|
||||
}
|
||||
if delay {
|
||||
Queue.mainQueue().after(0.3) {
|
||||
present()
|
||||
}
|
||||
} else {
|
||||
present()
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
@ -1866,7 +1866,7 @@ extension ChatControllerImpl {
|
||||
return
|
||||
}
|
||||
|
||||
guard !strongSelf.presentAccountFrozenInfoIfNeeded() else {
|
||||
guard !strongSelf.presentAccountFrozenInfoIfNeeded(delay: true) else {
|
||||
completion(.immediate, {})
|
||||
return
|
||||
}
|
||||
@ -2120,7 +2120,7 @@ extension ChatControllerImpl {
|
||||
})
|
||||
}, deleteMessages: { [weak self] messages, contextController, completion in
|
||||
if let strongSelf = self, !messages.isEmpty {
|
||||
guard !strongSelf.presentAccountFrozenInfoIfNeeded() else {
|
||||
guard !strongSelf.presentAccountFrozenInfoIfNeeded(delay: true) else {
|
||||
completion(.default)
|
||||
return
|
||||
}
|
||||
@ -2192,6 +2192,10 @@ extension ChatControllerImpl {
|
||||
}
|
||||
}, forwardMessages: { [weak self] messages in
|
||||
if let strongSelf = self, !messages.isEmpty {
|
||||
guard !strongSelf.presentAccountFrozenInfoIfNeeded(delay: true) else {
|
||||
return
|
||||
}
|
||||
|
||||
strongSelf.commitPurposefulAction()
|
||||
let forwardMessageIds = messages.map { $0.id }.sorted()
|
||||
strongSelf.forwardMessages(messageIds: forwardMessageIds)
|
||||
@ -3229,6 +3233,11 @@ extension ChatControllerImpl {
|
||||
self?.unblockPeer()
|
||||
}, pinMessage: { [weak self] messageId, contextController in
|
||||
if let strongSelf = self, let currentPeerId = strongSelf.chatLocation.peerId {
|
||||
guard !strongSelf.presentAccountFrozenInfoIfNeeded(delay: true) else {
|
||||
contextController?.dismiss(completion: nil)
|
||||
return
|
||||
}
|
||||
|
||||
if let peer = strongSelf.presentationInterfaceState.renderedPeer?.peer {
|
||||
if strongSelf.canManagePin() {
|
||||
let pinAction: (Bool, Bool) -> Void = { notify, forThisPeerOnlyIfPossible in
|
||||
|
@ -132,6 +132,10 @@ extension ChatControllerImpl {
|
||||
case .cancelMessageSelection:
|
||||
self.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
case .clearHistory:
|
||||
guard !self.presentAccountFrozenInfoIfNeeded() else {
|
||||
return
|
||||
}
|
||||
|
||||
if case let .peer(peerId) = self.chatLocation {
|
||||
let beginClear: (InteractiveHistoryClearingType) -> Void = { [weak self] type in
|
||||
self?.beginClearHistory(type: type)
|
||||
|
@ -333,7 +333,7 @@ extension ChatControllerImpl {
|
||||
}
|
||||
|
||||
controller?.dismissWithoutContent()
|
||||
guard !self.presentAccountFrozenInfoIfNeeded() else {
|
||||
guard !self.presentAccountFrozenInfoIfNeeded(delay: true) else {
|
||||
return
|
||||
}
|
||||
self.presentTagPremiumPaywall()
|
||||
@ -344,7 +344,7 @@ extension ChatControllerImpl {
|
||||
return
|
||||
}
|
||||
|
||||
guard !self.presentAccountFrozenInfoIfNeeded() else {
|
||||
guard !self.presentAccountFrozenInfoIfNeeded(delay: true) else {
|
||||
controller?.dismiss(completion: {})
|
||||
return
|
||||
}
|
||||
|
@ -3402,7 +3402,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
guard !self.presentAccountFrozenInfoIfNeeded() else {
|
||||
guard !self.presentAccountFrozenInfoIfNeeded(delay: true) else {
|
||||
return
|
||||
}
|
||||
self.presentScheduleTimePicker(completion: { [weak self] time in
|
||||
@ -3433,7 +3433,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
guard !self.presentAccountFrozenInfoIfNeeded() else {
|
||||
guard !self.presentAccountFrozenInfoIfNeeded(delay: true) else {
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user