From c6788d923bd9941b43fda129f0c28855e3044ef5 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Fri, 2 Dec 2022 14:35:53 +0400 Subject: [PATCH] Various fixes --- .../Telegram-iOS/en.lproj/Localizable.strings | 2 ++ submodules/Display/Source/TextNode.swift | 27 +++++++++++++++++++ .../Peers/ChannelAdminEventLogs.swift | 12 +++++---- .../ChatRecentActionsHistoryTransition.swift | 9 ++++++- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 31cb718f0e..68cb922bcb 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -8261,6 +8261,8 @@ Sorry for the inconvenience."; "Channel.AdminLog.TopicRenamedWithRemovedIcon" = "%1$@ renamed topic %2$@ to %3$@ and removed icon"; "Channel.AdminLog.TopicChangedIcon" = "%1$@ changed topic %2$@ icon to %3$@"; "Channel.AdminLog.TopicRemovedIcon" = "%1$@ removed topic %2$@ icon"; +"Channel.AdminLog.TopicUnhidden" = "%1$@ unhid topic %2$@"; +"Channel.AdminLog.TopicHidden" = "%1$@ hid topic %2$@"; "Attachment.Pasteboard" = "Clipboard"; "Attachment.DiscardPasteboardAlertText" = "Discard pasted items?"; diff --git a/submodules/Display/Source/TextNode.swift b/submodules/Display/Source/TextNode.swift index 933a8590c8..f514c9866c 100644 --- a/submodules/Display/Source/TextNode.swift +++ b/submodules/Display/Source/TextNode.swift @@ -1411,10 +1411,14 @@ open class TextNode: ASDisplayNode { context.setAllowsFontSubpixelQuantization(true) context.setShouldSubpixelQuantizeFonts(true) + var blendMode: CGBlendMode = .normal + var clearRects: [CGRect] = [] if let layout = parameters as? TextNodeLayout { if !isRasterizing || layout.backgroundColor != nil { context.setBlendMode(.copy) + blendMode = .copy + context.setFillColor((layout.backgroundColor ?? UIColor.clear).cgColor) context.fill(bounds) } @@ -1426,6 +1430,8 @@ open class TextNode: ASDisplayNode { if let (textStrokeColor, textStrokeWidth) = layout.textStroke { context.setBlendMode(.normal) + blendMode = .normal + context.setLineCap(.round) context.setLineJoin(.round) context.setStrokeColor(textStrokeColor.cgColor) @@ -1487,7 +1493,28 @@ open class TextNode: ASDisplayNode { if attributes["Attribute__EmbeddedItem"] != nil { continue } + + var fixCoupleEmoji = false + if glyphCount == 2, let font = attributes["NSFont"] as? UIFont, font.fontName.contains("ColorEmoji"), let string = layout.attributedString { + let range = CTRunGetStringRange(run) + let substring = string.attributedSubstring(from: NSMakeRange(range.location, range.length)).string + + let heart = Unicode.Scalar(0x2764)! + let man = Unicode.Scalar(0x1F468)! + let woman = Unicode.Scalar(0x1F469)! + + if substring.unicodeScalars.contains(heart) && (substring.unicodeScalars.contains(man) || substring.unicodeScalars.contains(woman)) { + fixCoupleEmoji = true + } + } + + if fixCoupleEmoji { + context.setBlendMode(.normal) + } CTRunDraw(run, context, CFRangeMake(0, glyphCount)) + if fixCoupleEmoji { + context.setBlendMode(blendMode) + } } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift index 3969bbc49b..9213f93729 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift @@ -35,10 +35,12 @@ public enum AdminLogEventAction { public struct ForumTopicInfo { public var info: EngineMessageHistoryThread.Info public var isClosed: Bool + public var isHidden: Bool - public init(info: EngineMessageHistoryThread.Info, isClosed: Bool) { + public init(info: EngineMessageHistoryThread.Info, isClosed: Bool, isHidden: Bool) { self.info = info self.isClosed = isClosed + self.isHidden = isHidden } } @@ -302,17 +304,17 @@ func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: PeerId, m let prevInfo: AdminLogEventAction.ForumTopicInfo switch prevTopic { case let .forumTopic(flags, _, _, title, iconColor, iconEmojiId, _, _, _, _, _, _, _, _, _): - prevInfo = AdminLogEventAction.ForumTopicInfo(info: EngineMessageHistoryThread.Info(title: title, icon: iconEmojiId, iconColor: iconColor), isClosed: (flags & (1 << 2)) != 0) + prevInfo = AdminLogEventAction.ForumTopicInfo(info: EngineMessageHistoryThread.Info(title: title, icon: iconEmojiId, iconColor: iconColor), isClosed: (flags & (1 << 2)) != 0, isHidden: (flags & (1 << 6)) != 0) case .forumTopicDeleted: - prevInfo = AdminLogEventAction.ForumTopicInfo(info: EngineMessageHistoryThread.Info(title: "", icon: nil, iconColor: 0), isClosed: false) + prevInfo = AdminLogEventAction.ForumTopicInfo(info: EngineMessageHistoryThread.Info(title: "", icon: nil, iconColor: 0), isClosed: false, isHidden: false) } let newInfo: AdminLogEventAction.ForumTopicInfo switch newTopic { case let .forumTopic(flags, _, _, title, iconColor, iconEmojiId, _, _, _, _, _, _, _, _, _): - newInfo = AdminLogEventAction.ForumTopicInfo(info: EngineMessageHistoryThread.Info(title: title, icon: iconEmojiId, iconColor: iconColor), isClosed: (flags & (1 << 2)) != 0) + newInfo = AdminLogEventAction.ForumTopicInfo(info: EngineMessageHistoryThread.Info(title: title, icon: iconEmojiId, iconColor: iconColor), isClosed: (flags & (1 << 2)) != 0, isHidden: (flags & (1 << 6)) != 0) case .forumTopicDeleted: - newInfo = AdminLogEventAction.ForumTopicInfo(info: EngineMessageHistoryThread.Info(title: "", icon: nil, iconColor: 0), isClosed: false) + newInfo = AdminLogEventAction.ForumTopicInfo(info: EngineMessageHistoryThread.Info(title: "", icon: nil, iconColor: 0), isClosed: false, isHidden: false) } action = .editTopic(prevInfo: prevInfo, newInfo: newInfo) diff --git a/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift b/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift index ecaa5f3354..288b6ddd8d 100644 --- a/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift +++ b/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift @@ -1714,7 +1714,14 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { "Channel.AdminLog.TopicRemovedIcon" = "%1$@ removed topic %2$@ icon";*/ let authorTitle: String = author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "" - if prevInfo.isClosed != newInfo.isClosed { + if prevInfo.isHidden != newInfo.isHidden { + appendAttributedText(text: newInfo.isHidden ? self.presentationData.strings.Channel_AdminLog_TopicHidden(authorTitle, newInfo.info.title) : self.presentationData.strings.Channel_AdminLog_TopicUnhidden(authorTitle, newInfo.info.title), generateEntities: { index in + if index == 0, let author = author { + return [.TextMention(peerId: author.id)] + } + return [] + }, to: &text, entities: &entities) + } else if prevInfo.isClosed != newInfo.isClosed { appendAttributedText(text: newInfo.isClosed ? self.presentationData.strings.Channel_AdminLog_TopicClosed(authorTitle, newInfo.info.title) : self.presentationData.strings.Channel_AdminLog_TopicReopened(authorTitle, newInfo.info.title), generateEntities: { index in if index == 0, let author = author { return [.TextMention(peerId: author.id)]