Various Fixes

This commit is contained in:
Ilya Laktyushin 2022-01-13 22:06:54 +03:00
parent 449d2abf1d
commit 800e0865b1

View File

@ -730,7 +730,22 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
}
}
if (!messageText.isEmpty || resourceAvailable || diceEmoji != nil) && !chatPresentationInterfaceState.copyProtectionEnabled {
var isPoll = false
if messageText.isEmpty {
for media in message.media {
if let poll = media as? TelegramMediaPoll {
isPoll = true
var text = poll.text
for option in poll.options {
text.append("\n\(option.text)")
}
messageText = poll.text
break
}
}
}
if (!messageText.isEmpty || resourceAvailable || diceEmoji != nil) && !chatPresentationInterfaceState.copyProtectionEnabled && !message.isCopyProtected() {
let message = messages[0]
var isExpired = false
for media in message.media {
@ -739,6 +754,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
}
}
if !isExpired {
if !isPoll {
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ContextMenuCopy, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Copy"), color: theme.actionSheet.primaryTextColor)
}, action: { _, f in
@ -801,6 +817,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
}
f(.default)
})))
}
if canTranslateText(context: context, text: messageText, showTranslate: translationSettings.showTranslate, ignoredLanguages: translationSettings.ignoredLanguages) {
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ContextMenuTranslate, icon: { theme in
@ -1067,7 +1084,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
break
}
}
if let file = media as? TelegramMediaFile, !chatPresentationInterfaceState.copyProtectionEnabled {
if let file = media as? TelegramMediaFile, !chatPresentationInterfaceState.copyProtectionEnabled && !message.isCopyProtected() {
if file.isVideo {
if file.isAnimated {
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_LinkDialogSave, icon: { theme in