Various fixes

This commit is contained in:
Ilya Laktyushin 2023-02-25 23:53:21 +04:00
parent a4a45806dc
commit 8a20ee072d
5 changed files with 38 additions and 21 deletions

View File

@ -353,7 +353,10 @@ final class ChatMessageAttachedContentNode: ASDisplayNode {
let textFixedFont = Font.regular(fontSize) let textFixedFont = Font.regular(fontSize)
let textBlockQuoteFont = Font.regular(fontSize) let textBlockQuoteFont = Font.regular(fontSize)
let incoming = message.effectivelyIncoming(context.account.peerId) var incoming = message.effectivelyIncoming(context.account.peerId)
if case .forwardedMessages = associatedData.subject {
incoming = false
}
var horizontalInsets = UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 10.0) var horizontalInsets = UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 10.0)
if displayLine { if displayLine {
@ -517,7 +520,7 @@ final class ChatMessageAttachedContentNode: ASDisplayNode {
} }
if !skipStandardStatus { if !skipStandardStatus {
if message.effectivelyIncoming(context.account.peerId) { if incoming {
if isImage { if isImage {
imageStatusType = .ImageIncoming imageStatusType = .ImageIncoming
} else { } else {
@ -609,7 +612,7 @@ final class ChatMessageAttachedContentNode: ASDisplayNode {
let automaticDownload = shouldDownloadMediaAutomatically(settings: automaticDownloadSettings, peerType: associatedData.automaticDownloadPeerType, networkType: associatedData.automaticDownloadNetworkType, authorPeerId: message.author?.id, contactsPeerIds: associatedData.contactsPeerIds, media: file) let automaticDownload = shouldDownloadMediaAutomatically(settings: automaticDownloadSettings, peerType: associatedData.automaticDownloadPeerType, networkType: associatedData.automaticDownloadNetworkType, authorPeerId: message.author?.id, contactsPeerIds: associatedData.contactsPeerIds, media: file)
let statusType: ChatMessageDateAndStatusType let statusType: ChatMessageDateAndStatusType
if message.effectivelyIncoming(context.account.peerId) { if incoming {
statusType = .BubbleIncoming statusType = .BubbleIncoming
} else { } else {
if message.flags.contains(.Failed) { if message.flags.contains(.Failed) {
@ -633,7 +636,7 @@ final class ChatMessageAttachedContentNode: ASDisplayNode {
forcedIsEdited: false, forcedIsEdited: false,
file: file, file: file,
automaticDownload: automaticDownload, automaticDownload: automaticDownload,
incoming: message.effectivelyIncoming(context.account.peerId), incoming: incoming,
isRecentActions: false, isRecentActions: false,
forcedResourceStatus: associatedData.forcedResourceStatus, forcedResourceStatus: associatedData.forcedResourceStatus,
dateAndStatusType: statusType, dateAndStatusType: statusType,

View File

@ -88,10 +88,15 @@ class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
var selectedContact: TelegramMediaContact? var selectedContact: TelegramMediaContact?
for media in item.message.media { for media in item.message.media {
if let media = media as? TelegramMediaContact { if let media = media as? TelegramMediaContact {
selectedContact = media selectedContact = media;
} }
} }
var incoming = item.message.effectivelyIncoming(item.context.account.peerId)
if case .forwardedMessages = item.associatedData.subject {
incoming = false
}
var titleString: NSAttributedString? var titleString: NSAttributedString?
var textString: NSAttributedString? var textString: NSAttributedString?
var updatedContactInfo: String? var updatedContactInfo: String?
@ -149,8 +154,8 @@ class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
updatedContactInfo = info updatedContactInfo = info
titleString = NSAttributedString(string: displayName, font: titleFont, textColor: item.message.effectivelyIncoming(item.context.account.peerId) ? item.presentationData.theme.theme.chat.message.incoming.accentTextColor : item.presentationData.theme.theme.chat.message.outgoing.accentTextColor) titleString = NSAttributedString(string: displayName, font: titleFont, textColor: incoming ? item.presentationData.theme.theme.chat.message.incoming.accentTextColor : item.presentationData.theme.theme.chat.message.outgoing.accentTextColor)
textString = NSAttributedString(string: info, font: textFont, textColor: item.message.effectivelyIncoming(item.context.account.peerId) ? item.presentationData.theme.theme.chat.message.incoming.primaryTextColor : item.presentationData.theme.theme.chat.message.outgoing.primaryTextColor) textString = NSAttributedString(string: info, font: textFont, textColor: incoming ? item.presentationData.theme.theme.chat.message.incoming.primaryTextColor : item.presentationData.theme.theme.chat.message.outgoing.primaryTextColor)
} else { } else {
updatedContactInfo = nil updatedContactInfo = nil
} }
@ -193,7 +198,7 @@ class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
let statusType: ChatMessageDateAndStatusType? let statusType: ChatMessageDateAndStatusType?
switch position { switch position {
case .linear(_, .None), .linear(_, .Neighbour(true, _, _)): case .linear(_, .None), .linear(_, .Neighbour(true, _, _)):
if item.message.effectivelyIncoming(item.context.account.peerId) { if incoming {
statusType = .BubbleIncoming statusType = .BubbleIncoming
} else { } else {
if item.message.flags.contains(.Failed) { if item.message.flags.contains(.Failed) {
@ -242,7 +247,7 @@ class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
let titleColor: UIColor let titleColor: UIColor
let titleHighlightedColor: UIColor let titleHighlightedColor: UIColor
let avatarPlaceholderColor: UIColor let avatarPlaceholderColor: UIColor
if item.message.effectivelyIncoming(item.context.account.peerId) { if incoming {
buttonImage = PresentationResourcesChat.chatMessageAttachedContentButtonIncoming(item.presentationData.theme.theme)! buttonImage = PresentationResourcesChat.chatMessageAttachedContentButtonIncoming(item.presentationData.theme.theme)!
buttonHighlightedImage = PresentationResourcesChat.chatMessageAttachedContentHighlightedButtonIncoming(item.presentationData.theme.theme)! buttonHighlightedImage = PresentationResourcesChat.chatMessageAttachedContentHighlightedButtonIncoming(item.presentationData.theme.theme)!
titleColor = item.presentationData.theme.theme.chat.message.incoming.accentTextColor titleColor = item.presentationData.theme.theme.chat.message.incoming.accentTextColor

View File

@ -102,7 +102,10 @@ class ChatMessageFileBubbleContentNode: ChatMessageBubbleContentNode {
} }
} }
let incoming = item.message.effectivelyIncoming(item.context.account.peerId) var incoming = item.message.effectivelyIncoming(item.context.account.peerId)
if case .forwardedMessages = item.associatedData.subject {
incoming = false
}
let statusType: ChatMessageDateAndStatusType? let statusType: ChatMessageDateAndStatusType?
switch preparePosition { switch preparePosition {
case .linear(_, .None), .linear(_, .Neighbour(true, _, _)): case .linear(_, .None), .linear(_, .Neighbour(true, _, _)):
@ -135,7 +138,7 @@ class ChatMessageFileBubbleContentNode: ChatMessageBubbleContentNode {
forcedIsEdited: item.isItemEdited, forcedIsEdited: item.isItemEdited,
file: selectedFile!, file: selectedFile!,
automaticDownload: automaticDownload, automaticDownload: automaticDownload,
incoming: item.message.effectivelyIncoming(item.context.account.peerId), incoming: incoming,
isRecentActions: item.associatedData.isRecentActions, isRecentActions: item.associatedData.isRecentActions,
forcedResourceStatus: item.associatedData.forcedResourceStatus, forcedResourceStatus: item.associatedData.forcedResourceStatus,
dateAndStatusType: statusType, dateAndStatusType: statusType,

View File

@ -88,6 +88,11 @@ class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode {
} }
} }
var incoming = item.message.effectivelyIncoming(item.context.account.peerId)
if case .forwardedMessages = item.associatedData.subject {
incoming = false
}
let bubbleInsets: UIEdgeInsets let bubbleInsets: UIEdgeInsets
if case .color = item.presentationData.theme.wallpaper { if case .color = item.presentationData.theme.wallpaper {
bubbleInsets = UIEdgeInsets() bubbleInsets = UIEdgeInsets()
@ -106,12 +111,12 @@ class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode {
imageSize = CGSize(width: fitWidth, height: floor(fitWidth * 0.5)) imageSize = CGSize(width: fitWidth, height: floor(fitWidth * 0.5))
if let venue = selectedMedia.venue { if let venue = selectedMedia.venue {
titleString = NSAttributedString(string: venue.title, font: titleFont, textColor: item.message.effectivelyIncoming(item.context.account.peerId) ? item.presentationData.theme.theme.chat.message.incoming.primaryTextColor : item.presentationData.theme.theme.chat.message.outgoing.primaryTextColor) titleString = NSAttributedString(string: venue.title, font: titleFont, textColor: incoming ? item.presentationData.theme.theme.chat.message.incoming.primaryTextColor : item.presentationData.theme.theme.chat.message.outgoing.primaryTextColor)
if let address = venue.address, !address.isEmpty { if let address = venue.address, !address.isEmpty {
textString = NSAttributedString(string: address, font: textFont, textColor: item.message.effectivelyIncoming(item.context.account.peerId) ? item.presentationData.theme.theme.chat.message.incoming.secondaryTextColor : item.presentationData.theme.theme.chat.message.outgoing.secondaryTextColor) textString = NSAttributedString(string: address, font: textFont, textColor: incoming ? item.presentationData.theme.theme.chat.message.incoming.secondaryTextColor : item.presentationData.theme.theme.chat.message.outgoing.secondaryTextColor)
} }
} else { } else {
textString = NSAttributedString(string: " ", font: textFont, textColor: item.message.effectivelyIncoming(item.context.account.peerId) ? item.presentationData.theme.theme.chat.message.incoming.secondaryTextColor : item.presentationData.theme.theme.chat.message.outgoing.secondaryTextColor) textString = NSAttributedString(string: " ", font: textFont, textColor: incoming ? item.presentationData.theme.theme.chat.message.incoming.secondaryTextColor : item.presentationData.theme.theme.chat.message.outgoing.secondaryTextColor)
} }
} else { } else {
let fitWidth: CGFloat = min(constrainedSize.width, layoutConstants.image.maxDimensions.width) let fitWidth: CGFloat = min(constrainedSize.width, layoutConstants.image.maxDimensions.width)
@ -120,7 +125,7 @@ class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode {
} }
if selectedMedia.liveBroadcastingTimeout != nil { if selectedMedia.liveBroadcastingTimeout != nil {
titleString = NSAttributedString(string: item.presentationData.strings.Message_LiveLocation, font: liveTitleFont, textColor: item.message.effectivelyIncoming(item.context.account.peerId) ? item.presentationData.theme.theme.chat.message.incoming.primaryTextColor : item.presentationData.theme.theme.chat.message.outgoing.primaryTextColor) titleString = NSAttributedString(string: item.presentationData.strings.Message_LiveLocation, font: liveTitleFont, textColor: incoming ? item.presentationData.theme.theme.chat.message.incoming.primaryTextColor : item.presentationData.theme.theme.chat.message.outgoing.primaryTextColor)
} }
} else { } else {
imageSize = CGSize(width: 75.0, height: 75.0) imageSize = CGSize(width: 75.0, height: 75.0)
@ -211,7 +216,7 @@ class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode {
switch position { switch position {
case .linear(_, .None), .linear(_, .Neighbour(true, _, _)): case .linear(_, .None), .linear(_, .Neighbour(true, _, _)):
if selectedMedia?.venue != nil || activeLiveBroadcastingTimeout != nil { if selectedMedia?.venue != nil || activeLiveBroadcastingTimeout != nil {
if item.message.effectivelyIncoming(item.context.account.peerId) { if incoming {
statusType = .BubbleIncoming statusType = .BubbleIncoming
} else { } else {
if item.message.flags.contains(.Failed) { if item.message.flags.contains(.Failed) {
@ -223,7 +228,7 @@ class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode {
} }
} }
} else { } else {
if item.message.effectivelyIncoming(item.context.account.peerId) { if incoming {
statusType = .ImageIncoming statusType = .ImageIncoming
} else { } else {
if item.message.flags.contains(.Failed) { if item.message.flags.contains(.Failed) {
@ -283,7 +288,7 @@ class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode {
} }
return (contentWidth, { boundingWidth in return (contentWidth, { boundingWidth in
let arguments = TransformImageArguments(corners: imageCorners, imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets(), emptyColor: item.message.effectivelyIncoming(item.context.account.peerId) ? item.presentationData.theme.theme.chat.message.incoming.mediaPlaceholderColor : item.presentationData.theme.theme.chat.message.outgoing.mediaPlaceholderColor) let arguments = TransformImageArguments(corners: imageCorners, imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: UIEdgeInsets(), emptyColor: incoming ? item.presentationData.theme.theme.chat.message.incoming.mediaPlaceholderColor : item.presentationData.theme.theme.chat.message.outgoing.mediaPlaceholderColor)
let imageLayoutSize = CGSize(width: imageSize.width + bubbleInsets.left + bubbleInsets.right, height: imageSize.height + bubbleInsets.top + bubbleInsets.bottom) let imageLayoutSize = CGSize(width: imageSize.width + bubbleInsets.left + bubbleInsets.right, height: imageSize.height + bubbleInsets.top + bubbleInsets.bottom)
@ -379,8 +384,8 @@ class ChatMessageMapBubbleContentNode: ChatMessageBubbleContentNode {
let timerSize = CGSize(width: 28.0, height: 28.0) let timerSize = CGSize(width: 28.0, height: 28.0)
strongSelf.liveTimerNode?.frame = CGRect(origin: CGPoint(x: floor(imageFrame.maxX - 10.0 - timerSize.width), y: floor(imageFrame.maxY + 11.0)), size: timerSize) strongSelf.liveTimerNode?.frame = CGRect(origin: CGPoint(x: floor(imageFrame.maxX - 10.0 - timerSize.width), y: floor(imageFrame.maxY + 11.0)), size: timerSize)
let timerForegroundColor: UIColor = item.message.effectivelyIncoming(item.context.account.peerId) ? item.presentationData.theme.theme.chat.message.incoming.accentControlColor : item.presentationData.theme.theme.chat.message.outgoing.accentControlColor let timerForegroundColor: UIColor = incoming ? item.presentationData.theme.theme.chat.message.incoming.accentControlColor : item.presentationData.theme.theme.chat.message.outgoing.accentControlColor
let timerTextColor: UIColor = item.message.effectivelyIncoming(item.context.account.peerId) ? item.presentationData.theme.theme.chat.message.incoming.secondaryTextColor : item.presentationData.theme.theme.chat.message.outgoing.secondaryTextColor let timerTextColor: UIColor = incoming ? item.presentationData.theme.theme.chat.message.incoming.secondaryTextColor : item.presentationData.theme.theme.chat.message.outgoing.secondaryTextColor
strongSelf.liveTimerNode?.update(backgroundColor: timerForegroundColor.withAlphaComponent(0.4), foregroundColor: timerForegroundColor, textColor: timerTextColor, beginTimestamp: Double(item.message.timestamp), timeout: Double(activeLiveBroadcastingTimeout), strings: item.presentationData.strings) strongSelf.liveTimerNode?.update(backgroundColor: timerForegroundColor.withAlphaComponent(0.4), foregroundColor: timerForegroundColor, textColor: timerTextColor, beginTimestamp: Double(item.message.timestamp), timeout: Double(activeLiveBroadcastingTimeout), strings: item.presentationData.strings)
if strongSelf.liveTextNode == nil { if strongSelf.liveTextNode == nil {

View File

@ -962,7 +962,8 @@ public func resolveUrlImpl(context: AccountContext, peerId: PeerId?, url: String
for scheme in schemes { for scheme in schemes {
let basePrefix = scheme + basePath + "/" let basePrefix = scheme + basePath + "/"
var url = url var url = url
if (url.lowercased().hasPrefix(scheme) && (url.lowercased().hasSuffix(".\(basePath)") || url.lowercased().contains(".\(basePath)/"))) { let lowercasedUrl = url.lowercased()
if (lowercasedUrl.hasPrefix(scheme) && (lowercasedUrl.hasSuffix(".\(basePath)") || lowercasedUrl.contains(".\(basePath)/") || lowercasedUrl.contains(".\(basePath)?"))) {
url = basePrefix + String(url[scheme.endIndex...]).replacingOccurrences(of: ".\(basePath)/", with: "").replacingOccurrences(of: ".\(basePath)", with: "") url = basePrefix + String(url[scheme.endIndex...]).replacingOccurrences(of: ".\(basePath)/", with: "").replacingOccurrences(of: ".\(basePath)", with: "")
} }
if url.lowercased().hasPrefix(basePrefix) { if url.lowercased().hasPrefix(basePrefix) {