mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Various fixes
This commit is contained in:
parent
0b2f7bbe61
commit
7cd159bda4
2 changed files with 32 additions and 9 deletions
|
|
@ -2331,6 +2331,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||
if item.controllerInteraction.summarizedMessageIds.contains(item.message.id) {
|
||||
for attribute in item.message.attributes {
|
||||
if let attribute = attribute as? SummarizationMessageAttribute, attribute.summaryForLang(translateToLanguage) != nil {
|
||||
initialDisplayHeader = true
|
||||
isSummarized = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -647,8 +647,13 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
|
|||
if let restrictedText = restrictedText {
|
||||
storeMessageTextInPasteboard(restrictedText, entities: nil)
|
||||
} else {
|
||||
if let translationState = chatPresentationInterfaceState.translationState, translationState.isEnabled,
|
||||
let translation = message.attributes.first(where: { ($0 as? TranslationMessageAttribute)?.toLang == translationState.toLang }) as? TranslationMessageAttribute, !translation.text.isEmpty {
|
||||
var translateToLang: String?
|
||||
if let translationState = chatPresentationInterfaceState.translationState, translationState.isEnabled {
|
||||
translateToLang = translationState.toLang
|
||||
}
|
||||
if controllerInteraction.summarizedMessageIds.contains(message.id), let attribute = message.attributes.first(where: { $0 is SummarizationMessageAttribute }) as? SummarizationMessageAttribute, let summary = attribute.summaryForLang(translateToLang) {
|
||||
storeMessageTextInPasteboard(summary.text, entities: summary.entities)
|
||||
} else if let translateToLang, let translation = message.attributes.first(where: { ($0 as? TranslationMessageAttribute)?.toLang == translateToLang }) as? TranslationMessageAttribute, !translation.text.isEmpty {
|
||||
storeMessageTextInPasteboard(translation.text, entities: translation.entities)
|
||||
} else {
|
||||
storeMessageTextInPasteboard(message.text, entities: messageEntities)
|
||||
|
|
@ -1282,11 +1287,16 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
|
|||
if let restrictedText = restrictedText {
|
||||
storeMessageTextInPasteboard(restrictedText, entities: nil)
|
||||
} else {
|
||||
if let translationState = chatPresentationInterfaceState.translationState, translationState.isEnabled,
|
||||
let translation = message.attributes.first(where: { ($0 as? TranslationMessageAttribute)?.toLang == translationState.toLang }) as? TranslationMessageAttribute, !translation.text.isEmpty {
|
||||
var translateToLang: String?
|
||||
if let translationState = chatPresentationInterfaceState.translationState, translationState.isEnabled {
|
||||
translateToLang = translationState.toLang
|
||||
}
|
||||
if controllerInteraction.summarizedMessageIds.contains(message.id), let attribute = message.attributes.first(where: { $0 is SummarizationMessageAttribute }) as? SummarizationMessageAttribute, let summary = attribute.summaryForLang(translateToLang) {
|
||||
storeMessageTextInPasteboard(summary.text, entities: summary.entities)
|
||||
} else if let translateToLang, let translation = message.attributes.first(where: { ($0 as? TranslationMessageAttribute)?.toLang == translateToLang }) as? TranslationMessageAttribute, !translation.text.isEmpty {
|
||||
storeMessageTextInPasteboard(translation.text, entities: translation.entities)
|
||||
} else {
|
||||
storeMessageTextInPasteboard(messageText, entities: messageEntities)
|
||||
storeMessageTextInPasteboard(message.text, entities: messageEntities)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1355,10 +1365,17 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
|
|||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Message"), color: theme.actionSheet.primaryTextColor)
|
||||
}, action: { _, f in
|
||||
var text = messageText
|
||||
if let translationState = chatPresentationInterfaceState.translationState, translationState.isEnabled,
|
||||
let translation = message.attributes.first(where: { ($0 as? TranslationMessageAttribute)?.toLang == translationState.toLang }) as? TranslationMessageAttribute, !translation.text.isEmpty {
|
||||
|
||||
var translateToLang: String?
|
||||
if let translationState = chatPresentationInterfaceState.translationState, translationState.isEnabled {
|
||||
translateToLang = translationState.toLang
|
||||
}
|
||||
if controllerInteraction.summarizedMessageIds.contains(message.id), let attribute = message.attributes.first(where: { $0 is SummarizationMessageAttribute }) as? SummarizationMessageAttribute, let summary = attribute.summaryForLang(translateToLang) {
|
||||
text = summary.text
|
||||
} else if let translateToLang, let translation = message.attributes.first(where: { ($0 as? TranslationMessageAttribute)?.toLang == translateToLang }) as? TranslationMessageAttribute, !translation.text.isEmpty {
|
||||
text = translation.text
|
||||
}
|
||||
|
||||
controllerInteraction.performTextSelectionAction(message, !isCopyProtected, NSAttributedString(string: text), .speak)
|
||||
f(.default)
|
||||
})))
|
||||
|
|
@ -2162,8 +2179,13 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
|
|||
if let restrictedText = restrictedText {
|
||||
storeMessageTextInPasteboard(restrictedText, entities: nil)
|
||||
} else {
|
||||
if let translationState = chatPresentationInterfaceState.translationState, translationState.isEnabled,
|
||||
let translation = message.attributes.first(where: { ($0 as? TranslationMessageAttribute)?.toLang == translationState.toLang }) as? TranslationMessageAttribute, !translation.text.isEmpty {
|
||||
var translateToLang: String?
|
||||
if let translationState = chatPresentationInterfaceState.translationState, translationState.isEnabled {
|
||||
translateToLang = translationState.toLang
|
||||
}
|
||||
if controllerInteraction.summarizedMessageIds.contains(message.id), let attribute = message.attributes.first(where: { $0 is SummarizationMessageAttribute }) as? SummarizationMessageAttribute, let summary = attribute.summaryForLang(translateToLang) {
|
||||
storeMessageTextInPasteboard(summary.text, entities: summary.entities)
|
||||
} else if let translateToLang, let translation = message.attributes.first(where: { ($0 as? TranslationMessageAttribute)?.toLang == translateToLang }) as? TranslationMessageAttribute, !translation.text.isEmpty {
|
||||
storeMessageTextInPasteboard(translation.text, entities: translation.entities)
|
||||
} else {
|
||||
storeMessageTextInPasteboard(message.text, entities: messageEntities)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue