mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-28 19:05:49 +00:00
Don't show delete action in shared media context menu when it's not available
This commit is contained in:
parent
295e6917eb
commit
f9f8788e65
@ -133,47 +133,56 @@ public class PeerMediaCollectionController: TelegramBaseController {
|
|||||||
}, sendSticker: nil, setupTemporaryHiddenMedia: { _, _, _ in }, chatAvatarHiddenMedia: { _, _ in }))
|
}, sendSticker: nil, setupTemporaryHiddenMedia: { _, _, _ in }, chatAvatarHiddenMedia: { _, _ in }))
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}, openPeer: { [weak self] id, navigation, _ in
|
}, openPeer: { [weak self] id, navigation, _ in
|
||||||
if let strongSelf = self, let id = id, let navigationController = strongSelf.navigationController as? NavigationController {
|
if let strongSelf = self, let id = id, let navigationController = strongSelf.navigationController as? NavigationController {
|
||||||
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(id)))
|
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(id)))
|
||||||
}
|
}
|
||||||
}, openPeerMention: { _ in
|
}, openPeerMention: { _ in
|
||||||
}, openMessageContextMenu: { [weak self] message, _, _, _, _ in
|
}, openMessageContextMenu: { [weak self] message, _, _, _, _ in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let items = (chatAvailableMessageActionsImpl(postbox: strongSelf.context.account.postbox, accountPeerId: strongSelf.context.account.peerId, messageIds: [message.id])
|
||||||
|
|> deliverOnMainQueue).start(next: { actions in
|
||||||
var messageIds = Set<MessageId>()
|
var messageIds = Set<MessageId>()
|
||||||
messageIds.insert(message.id)
|
messageIds.insert(message.id)
|
||||||
|
|
||||||
if let strongSelf = self, strongSelf.isNodeLoaded {
|
if let strongSelf = self, strongSelf.isNodeLoaded {
|
||||||
if let message = strongSelf.mediaCollectionDisplayNode.messageForGallery(message.id)?.message {
|
if let message = strongSelf.mediaCollectionDisplayNode.messageForGallery(message.id)?.message {
|
||||||
let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme)
|
let actionSheet = ActionSheetController(presentationTheme: strongSelf.presentationData.theme)
|
||||||
actionSheet.setItemGroups([ActionSheetItemGroup(items: [
|
var items: [ActionSheetButtonItem] = []
|
||||||
ActionSheetButtonItem(title: strongSelf.presentationData.strings.SharedMedia_ViewInChat, color: .accent, action: { [weak actionSheet] in
|
|
||||||
actionSheet?.dismissAnimated()
|
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.SharedMedia_ViewInChat, color: .accent, action: { [weak actionSheet] in
|
||||||
if let strongSelf = self, let navigationController = strongSelf.navigationController as? NavigationController {
|
actionSheet?.dismissAnimated()
|
||||||
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(strongSelf.peerId), subject: .message(message.id)))
|
if let strongSelf = self, let navigationController = strongSelf.navigationController as? NavigationController {
|
||||||
}
|
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(strongSelf.peerId), subject: .message(message.id)))
|
||||||
}),
|
}
|
||||||
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_ContextMenuForward, color: .accent, action: { [weak actionSheet] in
|
}))
|
||||||
actionSheet?.dismissAnimated()
|
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_ContextMenuForward, color: .accent, action: { [weak actionSheet] in
|
||||||
if let strongSelf = self {
|
actionSheet?.dismissAnimated()
|
||||||
strongSelf.forwardMessages(messageIds)
|
if let strongSelf = self {
|
||||||
}
|
strongSelf.forwardMessages(messageIds)
|
||||||
}),
|
}
|
||||||
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_ContextMenuDelete, color: .destructive, action: { [weak actionSheet] in
|
}))
|
||||||
actionSheet?.dismissAnimated()
|
if actions.options.contains(.deleteLocally) || actions.options.contains(.deleteGlobally) {
|
||||||
if let strongSelf = self {
|
items.append( ActionSheetButtonItem(title: strongSelf.presentationData.strings.Conversation_ContextMenuDelete, color: .destructive, action: { [weak actionSheet] in
|
||||||
strongSelf.deleteMessages(messageIds)
|
actionSheet?.dismissAnimated()
|
||||||
}
|
if let strongSelf = self {
|
||||||
})
|
strongSelf.deleteMessages(messageIds)
|
||||||
]), ActionSheetItemGroup(items: [
|
}
|
||||||
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
}))
|
||||||
actionSheet?.dismissAnimated()
|
}
|
||||||
|
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
|
||||||
|
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
||||||
|
actionSheet?.dismissAnimated()
|
||||||
})
|
})
|
||||||
])])
|
])])
|
||||||
strongSelf.mediaCollectionDisplayNode.view.endEditing(true)
|
strongSelf.mediaCollectionDisplayNode.view.endEditing(true)
|
||||||
strongSelf.present(actionSheet, in: .window(.root))
|
strongSelf.present(actionSheet, in: .window(.root))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, openMessageContextActions: { [weak self] message, node, rect, gesture in
|
})
|
||||||
|
}, openMessageContextActions: { [weak self] message, node, rect, gesture in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
gesture?.cancel()
|
gesture?.cancel()
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user