Display Clear Cache suggestion in all cases

This commit is contained in:
Ilya Laktyushin 2019-10-30 06:14:09 +04:00
parent 9c9233396d
commit 24bbcd9662
4 changed files with 27 additions and 17 deletions

View File

@ -3007,10 +3007,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if let strongSelf = self, !actions.options.isEmpty { if let strongSelf = self, !actions.options.isEmpty {
if let banAuthor = actions.banAuthor { if let banAuthor = actions.banAuthor {
strongSelf.presentBanMessageOptions(accountPeerId: strongSelf.context.account.peerId, author: banAuthor, messageIds: messageIds, options: actions.options) strongSelf.presentBanMessageOptions(accountPeerId: strongSelf.context.account.peerId, author: banAuthor, messageIds: messageIds, options: actions.options)
} else {
if actions.options.intersection([.deleteLocally, .deleteGlobally]).isEmpty {
strongSelf.presentClearCacheSuggestion()
} else { } else {
strongSelf.presentDeleteMessageOptions(messageIds: messageIds, options: actions.options, contextController: nil, completion: { _ in }) strongSelf.presentDeleteMessageOptions(messageIds: messageIds, options: actions.options, contextController: nil, completion: { _ in })
} }
} }
}
})) }))
} }
} }
@ -3050,6 +3054,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} else if (messages.first?.flags.isSending ?? false) { } else if (messages.first?.flags.isSending ?? false) {
let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: .forEveryone, deleteAllInGroup: true).start() let _ = deleteMessagesInteractively(postbox: strongSelf.context.account.postbox, messageIds: Array(messageIds), type: .forEveryone, deleteAllInGroup: true).start()
completion(.dismissWithoutContent) completion(.dismissWithoutContent)
} else {
if actions.options.intersection([.deleteLocally, .deleteGlobally]).isEmpty {
strongSelf.presentClearCacheSuggestion()
completion(.default)
} else { } else {
var isScheduled = false var isScheduled = false
for id in messageIds { for id in messageIds {
@ -3062,6 +3070,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
} }
} }
}
})) }))
} }
}, forwardSelectedMessages: { [weak self] in }, forwardSelectedMessages: { [weak self] in
@ -8044,7 +8053,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
let _ = (self.context.account.postbox.loadedPeerWithId(peerId) let _ = (self.context.account.postbox.loadedPeerWithId(peerId)
|> mapToSignal { peer -> Signal<(Peer, UIImage?), NoError> in |> mapToSignal { peer -> Signal<(Peer, UIImage?), NoError> in
let avatarImage = peerAvatarImage(account: self.context.account, peer: peer, authorOfMessage: nil, representation: peer.smallProfileImage, round: false) ?? .single(nil) let avatarImage = peerAvatarImage(account: self.context.account, peer: peer, authorOfMessage: nil, representation: peer.smallProfileImage, round: false) ?? .single(nil)
return avatarImage return avatarImage
|> map { avatarImage in |> map { avatarImage in
return (peer, avatarImage) return (peer, avatarImage)

View File

@ -684,7 +684,11 @@ func contextMenuForChatPresentationIntefaceState(chatPresentationInterfaceState:
}))) })))
} }
if !data.messageActions.options.intersection([.deleteLocally, .deleteGlobally]).isEmpty && !isAction { var clearCacheAsDelete = false
if let peer = message.peers[message.id.peerId] as? TelegramChannel {
clearCacheAsDelete = true
}
if (!data.messageActions.options.intersection([.deleteLocally, .deleteGlobally]).isEmpty || clearCacheAsDelete) && !isAction {
let title = message.flags.isSending ? chatPresentationInterfaceState.strings.Conversation_ContextMenuCancelSending : chatPresentationInterfaceState.strings.Conversation_ContextMenuDelete let title = message.flags.isSending ? chatPresentationInterfaceState.strings.Conversation_ContextMenuCancelSending : chatPresentationInterfaceState.strings.Conversation_ContextMenuDelete
actions.append(.action(ContextMenuActionItem(text: title, textColor: .destructive, icon: { theme in actions.append(.action(ContextMenuActionItem(text: title, textColor: .destructive, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: message.flags.isSending ? "Chat/Context Menu/Clear" : "Chat/Context Menu/Delete"), color: theme.actionSheet.destructiveActionTextColor) return generateTintedImage(image: UIImage(bundleImageName: message.flags.isSending ? "Chat/Context Menu/Clear" : "Chat/Context Menu/Delete"), color: theme.actionSheet.destructiveActionTextColor)

View File

@ -143,26 +143,24 @@ final class ChatMessageSelectionInputPanelNode: ChatInputPanelNode {
self.forwardButton.isEnabled = actions.options.contains(.forward) self.forwardButton.isEnabled = actions.options.contains(.forward)
self.shareButton.isEnabled = false self.shareButton.isEnabled = false
self.deleteButton.isEnabled = !actions.options.intersection([.deleteLocally, .deleteGlobally]).isEmpty self.deleteButton.isEnabled = true
self.shareButton.isEnabled = !actions.options.intersection([.forward]).isEmpty self.shareButton.isEnabled = !actions.options.intersection([.forward]).isEmpty
self.reportButton.isEnabled = !actions.options.intersection([.report]).isEmpty self.reportButton.isEnabled = !actions.options.intersection([.report]).isEmpty
self.deleteButton.isHidden = !self.deleteButton.isEnabled self.deleteButton.isHidden = false
self.reportButton.isHidden = !self.reportButton.isEnabled self.reportButton.isHidden = !self.reportButton.isEnabled
} else { } else {
self.deleteButton.isEnabled = false self.deleteButton.isEnabled = false
self.deleteButton.isHidden = true self.deleteButton.isHidden = false
self.reportButton.isEnabled = false self.reportButton.isEnabled = false
self.reportButton.isHidden = true self.reportButton.isHidden = true
self.forwardButton.isEnabled = false self.forwardButton.isEnabled = false
self.shareButton.isEnabled = false self.shareButton.isEnabled = false
} }
if self.deleteButton.isHidden && self.reportButton.isHidden { if self.reportButton.isHidden {
if let peer = interfaceState.renderedPeer?.peer as? TelegramChannel, case .broadcast = peer.info { if let peer = interfaceState.renderedPeer?.peer as? TelegramChannel, case .broadcast = peer.info {
self.reportButton.isHidden = false self.reportButton.isHidden = false
} else {
self.deleteButton.isHidden = false
} }
} }

View File

@ -103,7 +103,7 @@ class ChatScheduleTimeControllerNode: ViewControllerTracingNode, UIScrollViewDel
self.contentContainerNode.addSubnode(self.cancelButton) self.contentContainerNode.addSubnode(self.cancelButton)
self.contentContainerNode.addSubnode(self.doneButton) self.contentContainerNode.addSubnode(self.doneButton)
if case .scheduledMessages(true) = self.mode { if case .scheduledMessages(true) = self.mode {
self.contentContainerNode.addSubnode(self.onlineButton) //self.contentContainerNode.addSubnode(self.onlineButton)
} }
self.cancelButton.addTarget(self, action: #selector(self.cancelButtonPressed), forControlEvents: .touchUpInside) self.cancelButton.addTarget(self, action: #selector(self.cancelButtonPressed), forControlEvents: .touchUpInside)
@ -316,7 +316,7 @@ class ChatScheduleTimeControllerNode: ViewControllerTracingNode, UIScrollViewDel
var buttonOffset: CGFloat = 0.0 var buttonOffset: CGFloat = 0.0
if case .scheduledMessages(true) = self.mode { if case .scheduledMessages(true) = self.mode {
buttonOffset += 60.0 //buttonOffset += 60.0
} }
let bottomInset: CGFloat = 10.0 + cleanInsets.bottom let bottomInset: CGFloat = 10.0 + cleanInsets.bottom