Various improvements

This commit is contained in:
Ali 2023-10-26 13:57:17 +04:00
parent 44e737d837
commit f11a98e489
3 changed files with 13 additions and 29 deletions

View File

@ -1677,7 +1677,7 @@ public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate {
chatPeerId: nil, chatPeerId: nil,
peekBehavior: nil, peekBehavior: nil,
customLayout: emojiContentLayout, customLayout: emojiContentLayout,
externalBackground: EmojiPagerContentComponent.ExternalBackground( externalBackground: self.backgroundNode.vibrancyEffectView == nil ? nil : EmojiPagerContentComponent.ExternalBackground(
effectContainerView: self.backgroundNode.vibrancyEffectView?.contentView effectContainerView: self.backgroundNode.vibrancyEffectView?.contentView
), ),
externalExpansionView: self.view, externalExpansionView: self.view,

View File

@ -4034,12 +4034,12 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
for attribute in item.message.attributes { for attribute in item.message.attributes {
if let attribute = attribute as? ReplyMessageAttribute { if let attribute = attribute as? ReplyMessageAttribute {
if let threadId = item.message.threadId, makeThreadIdMessageId(peerId: item.message.id.peerId, threadId: threadId) == attribute.messageId, let quotedReply = item.message.attributes.first(where: { $0 is QuotedReplyMessageAttribute }) as? QuotedReplyMessageAttribute { if let threadId = item.message.threadId, makeThreadIdMessageId(peerId: item.message.id.peerId, threadId: threadId) == attribute.messageId, let quotedReply = item.message.attributes.first(where: { $0 is QuotedReplyMessageAttribute }) as? QuotedReplyMessageAttribute {
return .action(InternalBubbleTapAction.Action { return .action(InternalBubbleTapAction.Action({
item.controllerInteraction.attemptedNavigationToPrivateQuote(quotedReply.peerId.flatMap { item.message.peers[$0] }) item.controllerInteraction.attemptedNavigationToPrivateQuote(quotedReply.peerId.flatMap { item.message.peers[$0] })
}) }, contextMenuOnLongPress: true))
} }
return .action(InternalBubbleTapAction.Action { [weak self] in return .action(InternalBubbleTapAction.Action({ [weak self] in
guard let self else { guard let self else {
return return
} }
@ -4048,15 +4048,15 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
progress = replyInfoNode.makeProgress() progress = replyInfoNode.makeProgress()
} }
item.controllerInteraction.navigateToMessage(item.message.id, attribute.messageId, NavigateToMessageParams(timestamp: nil, quote: attribute.quote?.text, progress: progress)) item.controllerInteraction.navigateToMessage(item.message.id, attribute.messageId, NavigateToMessageParams(timestamp: nil, quote: attribute.quote?.text, progress: progress))
}) }, contextMenuOnLongPress: true))
} else if let attribute = attribute as? ReplyStoryAttribute { } else if let attribute = attribute as? ReplyStoryAttribute {
return .action(InternalBubbleTapAction.Action { return .action(InternalBubbleTapAction.Action({
item.controllerInteraction.navigateToStory(item.message, attribute.storyId) item.controllerInteraction.navigateToStory(item.message, attribute.storyId)
}) }, contextMenuOnLongPress: true))
} else if let attribute = attribute as? QuotedReplyMessageAttribute { } else if let attribute = attribute as? QuotedReplyMessageAttribute {
return .action(InternalBubbleTapAction.Action { return .action(InternalBubbleTapAction.Action({
item.controllerInteraction.attemptedNavigationToPrivateQuote(attribute.peerId.flatMap { item.message.peers[$0] }) item.controllerInteraction.attemptedNavigationToPrivateQuote(attribute.peerId.flatMap { item.message.peers[$0] })
}) }, contextMenuOnLongPress: true))
} }
} }
} }
@ -4265,23 +4265,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
return .action(InternalBubbleTapAction.Action {}) return .action(InternalBubbleTapAction.Action {})
} }
if let replyInfoNode = self.replyInfoNode, self.item?.controllerInteraction.tapMessage == nil, replyInfoNode.frame.contains(location) { if let replyInfoNode = self.replyInfoNode, self.item?.controllerInteraction.tapMessage == nil, replyInfoNode.frame.contains(location) {
if let item = self.item { return .openContextMenu(InternalBubbleTapAction.OpenContextMenu(tapMessage: item.content.firstMessage, selectAll: false, subFrame: self.backgroundNode.frame, disableDefaultPressAnimation: true))
for attribute in item.message.attributes {
if let attribute = attribute as? ReplyMessageAttribute {
return .action(InternalBubbleTapAction.Action {
item.controllerInteraction.navigateToMessage(item.message.id, attribute.messageId, NavigateToMessageParams(timestamp: nil, quote: attribute.quote?.text))
})
} else if let attribute = attribute as? ReplyStoryAttribute {
return .action(InternalBubbleTapAction.Action {
item.controllerInteraction.navigateToStory(item.message, attribute.storyId)
})
} else if let attribute = attribute as? QuotedReplyMessageAttribute {
return .action(InternalBubbleTapAction.Action {
item.controllerInteraction.attemptedNavigationToPrivateQuote(attribute.peerId.flatMap { item.message.peers[$0] })
})
}
}
}
} }
var tapMessage: Message? = item.content.firstMessage var tapMessage: Message? = item.content.firstMessage

View File

@ -200,17 +200,17 @@ public func stringWithAppliedEntities(_ text: String, entities: [MessageTextEnti
} }
string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.BotCommand), value: nsString!.substring(with: range), range: range) string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.BotCommand), value: nsString!.substring(with: range), range: range)
case .Pre: case .Pre:
string.addAttribute(NSAttributedString.Key.font, value: fixedFont, range: range) addFontAttributes(range, .monospace)
if nsString == nil { if nsString == nil {
nsString = text as NSString nsString = text as NSString
} }
string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.Pre), value: nsString!.substring(with: range), range: range) string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.Pre), value: nsString!.substring(with: range), range: range)
case .Code: case .Code:
string.addAttribute(NSAttributedString.Key.font, value: fixedFont, range: range) addFontAttributes(range, .monospace)
if nsString == nil { if nsString == nil {
nsString = text as NSString nsString = text as NSString
} }
string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.Pre), value: nsString!.substring(with: range), range: range) string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.Code), value: nsString!.substring(with: range), range: range)
case .BlockQuote: case .BlockQuote:
addFontAttributes(range, .blockQuote) addFontAttributes(range, .blockQuote)