mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Refactoring
This commit is contained in:
@@ -964,7 +964,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
strongSelf.archiveChats(peerIds: [peerId])
|
||||
} else {
|
||||
strongSelf.chatListDisplayNode.containerNode.currentItemNode.setCurrentRemovingPeerId(peerId)
|
||||
let _ = updatePeerGroupIdInteractively(postbox: strongSelf.context.account.postbox, peerId: peerId, groupId: group ? Namespaces.PeerGroup.archive : .root).start(completed: {
|
||||
let _ = strongSelf.context.engine.peers.updatePeersGroupIdInteractively(peerIds: [peerId], groupId: group ? .archive : .root).start(completed: {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
@@ -2419,7 +2419,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
override public func toolbarActionSelected(action: ToolbarActionOption) {
|
||||
let peerIds = self.chatListDisplayNode.containerNode.currentItemNode.currentState.selectedPeerIds
|
||||
if case .left = action {
|
||||
let signal: Signal<Void, NoError>
|
||||
let signal: Signal<Never, NoError>
|
||||
var completion: (() -> Void)?
|
||||
let context = self.context
|
||||
if !peerIds.isEmpty {
|
||||
@@ -2432,6 +2432,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
togglePeerUnreadMarkInteractively(transaction: transaction, viewTracker: context.account.viewTracker, peerId: peerId, setToValue: false)
|
||||
}
|
||||
}
|
||||
|> ignoreValues
|
||||
} else {
|
||||
let groupId = self.groupId
|
||||
let filterPredicate: ChatListFilterPredicate?
|
||||
@@ -2440,14 +2441,14 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
} else {
|
||||
filterPredicate = nil
|
||||
}
|
||||
signal = self.context.account.postbox.transaction { transaction -> Void in
|
||||
markAllChatsAsReadInteractively(transaction: transaction, viewTracker: context.account.viewTracker, groupId: groupId, filterPredicate: filterPredicate)
|
||||
if let filterPredicate = filterPredicate {
|
||||
for additionalGroupId in filterPredicate.includeAdditionalPeerGroupIds {
|
||||
markAllChatsAsReadInteractively(transaction: transaction, viewTracker: context.account.viewTracker, groupId: additionalGroupId, filterPredicate: filterPredicate)
|
||||
}
|
||||
var markItems: [(groupId: EngineChatList.Group, filterPredicate: ChatListFilterPredicate?)] = []
|
||||
markItems.append((EngineChatList.Group(groupId), filterPredicate))
|
||||
if let filterPredicate = filterPredicate {
|
||||
for additionalGroupId in filterPredicate.includeAdditionalPeerGroupIds {
|
||||
markItems.append((EngineChatList.Group(additionalGroupId), filterPredicate))
|
||||
}
|
||||
}
|
||||
signal = self.context.engine.messages.markAllChatsAsReadInteractively(items: markItems)
|
||||
}
|
||||
let _ = (signal
|
||||
|> deliverOnMainQueue).start(completed: { [weak self] in
|
||||
@@ -2545,11 +2546,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
} else {
|
||||
if !peerIds.isEmpty {
|
||||
self.chatListDisplayNode.containerNode.currentItemNode.setCurrentRemovingPeerId(peerIds.first!)
|
||||
let _ = (self.context.account.postbox.transaction { transaction -> Void in
|
||||
for peerId in peerIds {
|
||||
updatePeerGroupIdInteractively(transaction: transaction, peerId: peerId, groupId: .root)
|
||||
}
|
||||
}
|
||||
let _ = (self.context.engine.peers.updatePeersGroupIdInteractively(peerIds: Array(peerIds), groupId: .root)
|
||||
|> deliverOnMainQueue).start(completed: { [weak self] in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
@@ -3047,15 +3044,11 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
guard !peerIds.isEmpty else {
|
||||
return
|
||||
}
|
||||
let postbox = self.context.account.postbox
|
||||
let engine = self.context.engine
|
||||
self.chatListDisplayNode.containerNode.currentItemNode.setCurrentRemovingPeerId(peerIds[0])
|
||||
let _ = (ApplicationSpecificNotice.incrementArchiveChatTips(accountManager: self.context.sharedContext.accountManager, count: 1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] previousHintCount in
|
||||
let _ = (postbox.transaction { transaction -> Void in
|
||||
for peerId in peerIds {
|
||||
updatePeerGroupIdInteractively(transaction: transaction, peerId: peerId, groupId: Namespaces.PeerGroup.archive)
|
||||
}
|
||||
}
|
||||
let _ = (engine.peers.updatePeersGroupIdInteractively(peerIds: peerIds, groupId: .archive)
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
@@ -3072,11 +3065,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
}
|
||||
if value == .undo {
|
||||
strongSelf.chatListDisplayNode.containerNode.currentItemNode.setCurrentRemovingPeerId(peerIds[0])
|
||||
let _ = (postbox.transaction { transaction -> Void in
|
||||
for peerId in peerIds {
|
||||
updatePeerGroupIdInteractively(transaction: transaction, peerId: peerId, groupId: .root)
|
||||
}
|
||||
}
|
||||
let _ = (engine.peers.updatePeersGroupIdInteractively(peerIds: peerIds, groupId: .root)
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user