Support autoarchive for groups and channels

This commit is contained in:
Ali
2020-07-06 16:35:35 +04:00
parent 1137de2781
commit 401e4798fa
3 changed files with 27 additions and 7 deletions

View File

@@ -39,14 +39,25 @@ public func unarchiveAutomaticallyArchivedPeer(account: Account, peerId: PeerId)
let _ = (account.postbox.transaction { transaction -> Void in
updatePeerGroupIdInteractively(transaction: transaction, peerId: peerId, groupId: .root)
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
guard let currentData = current as? CachedUserData, let currentStatusSettings = currentData.peerStatusSettings else {
if let currentData = current as? CachedUserData, let currentStatusSettings = currentData.peerStatusSettings {
var statusSettings = currentStatusSettings
statusSettings.flags.remove(.canBlock)
statusSettings.flags.remove(.canReport)
statusSettings.flags.remove(.autoArchived)
return currentData.withUpdatedPeerStatusSettings(statusSettings)
} else if let currentData = current as? CachedGroupData, let currentStatusSettings = currentData.peerStatusSettings {
var statusSettings = currentStatusSettings
statusSettings.flags.remove(.canReport)
statusSettings.flags.remove(.autoArchived)
return currentData.withUpdatedPeerStatusSettings(statusSettings)
} else if let currentData = current as? CachedChannelData, let currentStatusSettings = currentData.peerStatusSettings {
var statusSettings = currentStatusSettings
statusSettings.flags.remove(.canReport)
statusSettings.flags.remove(.autoArchived)
return currentData.withUpdatedPeerStatusSettings(statusSettings)
}else {
return current
}
var statusSettings = currentStatusSettings
statusSettings.flags.remove(.canBlock)
statusSettings.flags.remove(.canReport)
statusSettings.flags.remove(.autoArchived)
return currentData.withUpdatedPeerStatusSettings(statusSettings)
})
}
|> deliverOnMainQueue).start()