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

@ -54,7 +54,13 @@ public func chatListItemStrings(strings: PresentationStrings, nameDisplayOrder:
peer = chatPeer.chatMainPeer peer = chatPeer.chatMainPeer
} }
messageText = messages[0].text messageText = ""
for message in messages {
if !message.text.isEmpty {
messageText = message.text
break
}
}
var textIsReady = false var textIsReady = false
if messages.count > 1 { if messages.count > 1 {

View File

@ -39,14 +39,25 @@ public func unarchiveAutomaticallyArchivedPeer(account: Account, peerId: PeerId)
let _ = (account.postbox.transaction { transaction -> Void in let _ = (account.postbox.transaction { transaction -> Void in
updatePeerGroupIdInteractively(transaction: transaction, peerId: peerId, groupId: .root) updatePeerGroupIdInteractively(transaction: transaction, peerId: peerId, groupId: .root)
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in 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 return current
} }
var statusSettings = currentStatusSettings
statusSettings.flags.remove(.canBlock)
statusSettings.flags.remove(.canReport)
statusSettings.flags.remove(.autoArchived)
return currentData.withUpdatedPeerStatusSettings(statusSettings)
}) })
} }
|> deliverOnMainQueue).start() |> deliverOnMainQueue).start()

View File

@ -87,6 +87,9 @@ private func peerButtons(_ state: ChatPresentationInterfaceState) -> [ChatReport
} else if let _ = state.renderedPeer?.chatMainPeer { } else if let _ = state.renderedPeer?.chatMainPeer {
if let contactStatus = state.contactStatus, contactStatus.canReportIrrelevantLocation, let peerStatusSettings = contactStatus.peerStatusSettings, peerStatusSettings.contains(.canReportIrrelevantGeoLocation) { if let contactStatus = state.contactStatus, contactStatus.canReportIrrelevantLocation, let peerStatusSettings = contactStatus.peerStatusSettings, peerStatusSettings.contains(.canReportIrrelevantGeoLocation) {
buttons.append(.reportIrrelevantGeoLocation) buttons.append(.reportIrrelevantGeoLocation)
} else if let contactStatus = state.contactStatus, let peerStatusSettings = contactStatus.peerStatusSettings, peerStatusSettings.contains(.autoArchived) {
buttons.append(.reportUserSpam)
buttons.append(.unarchive)
} else { } else {
buttons.append(.reportSpam) buttons.append(.reportSpam)
} }