mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-02 00:17:02 +00:00
Various Fixes
This commit is contained in:
parent
449d2abf1d
commit
800e0865b1
@ -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]
|
let message = messages[0]
|
||||||
var isExpired = false
|
var isExpired = false
|
||||||
for media in message.media {
|
for media in message.media {
|
||||||
@ -739,68 +754,70 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !isExpired {
|
if !isExpired {
|
||||||
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ContextMenuCopy, icon: { theme in
|
if !isPoll {
|
||||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Copy"), color: theme.actionSheet.primaryTextColor)
|
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ContextMenuCopy, icon: { theme in
|
||||||
}, action: { _, f in
|
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Copy"), color: theme.actionSheet.primaryTextColor)
|
||||||
if let diceEmoji = diceEmoji {
|
}, action: { _, f in
|
||||||
UIPasteboard.general.string = diceEmoji
|
if let diceEmoji = diceEmoji {
|
||||||
} else {
|
UIPasteboard.general.string = diceEmoji
|
||||||
let copyTextWithEntities = {
|
} else {
|
||||||
var messageEntities: [MessageTextEntity]?
|
let copyTextWithEntities = {
|
||||||
var restrictedText: String?
|
var messageEntities: [MessageTextEntity]?
|
||||||
for attribute in message.attributes {
|
var restrictedText: String?
|
||||||
if let attribute = attribute as? TextEntitiesMessageAttribute {
|
for attribute in message.attributes {
|
||||||
messageEntities = attribute.entities
|
if let attribute = attribute as? TextEntitiesMessageAttribute {
|
||||||
|
messageEntities = attribute.entities
|
||||||
|
}
|
||||||
|
if let attribute = attribute as? RestrictedContentMessageAttribute {
|
||||||
|
restrictedText = attribute.platformText(platform: "ios", contentSettings: context.currentContentSettings.with { $0 }) ?? ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let attribute = attribute as? RestrictedContentMessageAttribute {
|
|
||||||
restrictedText = attribute.platformText(platform: "ios", contentSettings: context.currentContentSettings.with { $0 }) ?? ""
|
if let restrictedText = restrictedText {
|
||||||
|
storeMessageTextInPasteboard(restrictedText, entities: nil)
|
||||||
|
} else {
|
||||||
|
storeMessageTextInPasteboard(messageText, entities: messageEntities)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Queue.mainQueue().after(0.2, {
|
||||||
|
let content: UndoOverlayContent = .copy(text: chatPresentationInterfaceState.strings.Conversation_MessageCopied)
|
||||||
|
controllerInteraction.displayUndo(content)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
if resourceAvailable {
|
||||||
if let restrictedText = restrictedText {
|
for media in message.media {
|
||||||
storeMessageTextInPasteboard(restrictedText, entities: nil)
|
if let image = media as? TelegramMediaImage, let largest = largestImageRepresentation(image.representations) {
|
||||||
} else {
|
let _ = (context.account.postbox.mediaBox.resourceData(largest.resource, option: .incremental(waitUntilFetchStatus: false))
|
||||||
storeMessageTextInPasteboard(messageText, entities: messageEntities)
|
|> take(1)
|
||||||
}
|
|> deliverOnMainQueue).start(next: { data in
|
||||||
|
if data.complete, let imageData = try? Data(contentsOf: URL(fileURLWithPath: data.path)) {
|
||||||
Queue.mainQueue().after(0.2, {
|
if let image = UIImage(data: imageData) {
|
||||||
let content: UndoOverlayContent = .copy(text: chatPresentationInterfaceState.strings.Conversation_MessageCopied)
|
if !messageText.isEmpty {
|
||||||
controllerInteraction.displayUndo(content)
|
copyTextWithEntities()
|
||||||
})
|
} else {
|
||||||
}
|
UIPasteboard.general.image = image
|
||||||
if resourceAvailable {
|
|
||||||
for media in message.media {
|
Queue.mainQueue().after(0.2, {
|
||||||
if let image = media as? TelegramMediaImage, let largest = largestImageRepresentation(image.representations) {
|
let content: UndoOverlayContent = .copy(text: chatPresentationInterfaceState.strings.Conversation_ImageCopied)
|
||||||
let _ = (context.account.postbox.mediaBox.resourceData(largest.resource, option: .incremental(waitUntilFetchStatus: false))
|
controllerInteraction.displayUndo(content)
|
||||||
|> take(1)
|
})
|
||||||
|> deliverOnMainQueue).start(next: { data in
|
}
|
||||||
if data.complete, let imageData = try? Data(contentsOf: URL(fileURLWithPath: data.path)) {
|
|
||||||
if let image = UIImage(data: imageData) {
|
|
||||||
if !messageText.isEmpty {
|
|
||||||
copyTextWithEntities()
|
|
||||||
} else {
|
} else {
|
||||||
UIPasteboard.general.image = image
|
copyTextWithEntities()
|
||||||
|
|
||||||
Queue.mainQueue().after(0.2, {
|
|
||||||
let content: UndoOverlayContent = .copy(text: chatPresentationInterfaceState.strings.Conversation_ImageCopied)
|
|
||||||
controllerInteraction.displayUndo(content)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
copyTextWithEntities()
|
copyTextWithEntities()
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
copyTextWithEntities()
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
copyTextWithEntities()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
copyTextWithEntities()
|
|
||||||
}
|
}
|
||||||
}
|
f(.default)
|
||||||
f(.default)
|
})))
|
||||||
})))
|
}
|
||||||
|
|
||||||
if canTranslateText(context: context, text: messageText, showTranslate: translationSettings.showTranslate, ignoredLanguages: translationSettings.ignoredLanguages) {
|
if canTranslateText(context: context, text: messageText, showTranslate: translationSettings.showTranslate, ignoredLanguages: translationSettings.ignoredLanguages) {
|
||||||
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ContextMenuTranslate, icon: { theme in
|
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ContextMenuTranslate, icon: { theme in
|
||||||
@ -1067,7 +1084,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let file = media as? TelegramMediaFile, !chatPresentationInterfaceState.copyProtectionEnabled {
|
if let file = media as? TelegramMediaFile, !chatPresentationInterfaceState.copyProtectionEnabled && !message.isCopyProtected() {
|
||||||
if file.isVideo {
|
if file.isVideo {
|
||||||
if file.isAnimated {
|
if file.isAnimated {
|
||||||
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_LinkDialogSave, icon: { theme in
|
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_LinkDialogSave, icon: { theme in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user