From 3716f59e7d9052c5324d033405ca47a3dca81e00 Mon Sep 17 00:00:00 2001 From: isaac <> Date: Mon, 20 Apr 2026 18:55:27 +0200 Subject: [PATCH] Cleanup --- .../Sources/ChatMessageItemImpl.swift | 5 ++- .../ChatMessageTextBubbleContentNode.swift | 16 ++++--- .../Sources/InteractiveTextComponent.swift | 45 +++++-------------- 3 files changed, 25 insertions(+), 41 deletions(-) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift index a49e4bc5f4..08e1cc4b43 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift @@ -278,12 +278,13 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible } public var pinToEdgeWithInset: Bool { - switch self.content { + return false + /*switch self.content { case let .message(message, _, _, _, _): return !message.effectivelyIncoming(self.context.account.peerId) case let .group(messages): return !messages[0].0.effectivelyIncoming(self.context.account.peerId) - } + }*/ } public init(presentationData: ChatPresentationData, context: AccountContext, chatLocation: ChatLocation, associatedData: ChatMessageItemAssociatedData, controllerInteraction: ChatControllerInteraction, content: ChatMessageItemContent, disableDate: Bool = false, additionalContent: ChatMessageItemAdditionalContent? = nil) { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift index b4669a1c00..a03fc2eba8 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift @@ -1098,7 +1098,7 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode { ) if self.textRevealLink == nil, self.textRevealAnimationState != nil { self.textRevealLink = SharedDisplayLinkDriver.shared.add { [weak self] _ in - guard let self else { + guard let self, let item = self.item else { return } guard let textRevealAnimationState = self.textRevealAnimationState else { @@ -1112,7 +1112,7 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode { self.textNode.textNode.updateRevealCharacterCount(count: nil, animated: false) - if let statusNode = self.statusNode { + if let statusNode = self.statusNode, !item.message.attributes.contains(where: { $0 is TypingDraftMessageAttribute }) { ContainedViewLayoutTransition.animated(duration: 0.2, curve: .easeInOut).updateAlpha(node: statusNode, alpha: 1.0) } @@ -1145,17 +1145,23 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode { override public func animateInsertion(_ currentTimestamp: Double, duration: Double) { self.textNode.textNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) - self.statusNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) + if let statusNode = self.statusNode, statusNode.alpha != 0.0 { + statusNode.layer.animateAlpha(from: 0.0, to: statusNode.alpha, duration: 0.2) + } } override public func animateAdded(_ currentTimestamp: Double, duration: Double) { self.textNode.textNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) - self.statusNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) + if let statusNode = self.statusNode, statusNode.alpha != 0.0 { + statusNode.layer.animateAlpha(from: 0.0, to: statusNode.alpha, duration: 0.2) + } } override public func animateRemoved(_ currentTimestamp: Double, duration: Double) { self.textNode.textNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false) - self.statusNode?.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false) + if let statusNode = self.statusNode, statusNode.alpha != 0.0 { + statusNode.layer.animateAlpha(from: statusNode.alpha, to: 0.0, duration: 0.2, removeOnCompletion: false) + } } override public func tapActionAtPoint(_ point: CGPoint, gesture: TapLongTapOrDoubleTapGesture, isEstimating: Bool) -> ChatMessageBubbleContentTapAction { diff --git a/submodules/TelegramUI/Components/InteractiveTextComponent/Sources/InteractiveTextComponent.swift b/submodules/TelegramUI/Components/InteractiveTextComponent/Sources/InteractiveTextComponent.swift index b83ddbbc6c..d5378abeb1 100644 --- a/submodules/TelegramUI/Components/InteractiveTextComponent/Sources/InteractiveTextComponent.swift +++ b/submodules/TelegramUI/Components/InteractiveTextComponent/Sources/InteractiveTextComponent.swift @@ -2985,40 +2985,17 @@ final class TextContentItemLayer: SimpleLayer { self.addSublayer(snippetLayer) self.animatingSnippetLayers.append(snippetLayer) - if !"".isEmpty { - //ComponentTransition(animation: .curve(duration: 0.3, curve: .easeInOut)).animateBlur(layer: snippetLayer, fromRadius: 10.0, toRadius: 0.0) - - snippetLayer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) - snippetLayer.animateScale(from: 0.1, to: 1.0, duration: 0.2, completion: { [weak self, weak snippetLayer] _ in - guard let self, let snippetLayer else { - return - } - snippetLayer.removeFromSuperlayer() - self.animatingSnippetLayers.removeAll(where: { $0 === snippetLayer }) - self.updateRevealMask(animateNewSegments: false) - }) - } else if "".isEmpty { - ComponentTransition(animation: .curve(duration: 0.22, curve: .easeInOut)).animateBlur(layer: snippetLayer, fromRadius: 3.0, toRadius: 0.0) - snippetLayer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) - snippetLayer.animatePosition(from: CGPoint(x: 0.0, y: 6.0), to: CGPoint(), duration: 0.2, additive: true) - snippetLayer.animateScale(from: 0.5, to: 1.0, duration: 0.2, completion: { [weak self, weak snippetLayer] _ in - guard let self, let snippetLayer else { - return - } - snippetLayer.removeFromSuperlayer() - self.animatingSnippetLayers.removeAll(where: { $0 === snippetLayer }) - self.updateRevealMask(animateNewSegments: false) - }) - } else { - snippetLayer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2, completion: { [weak self, weak snippetLayer] _ in - guard let self, let snippetLayer else { - return - } - snippetLayer.removeFromSuperlayer() - self.animatingSnippetLayers.removeAll(where: { $0 === snippetLayer }) - self.updateRevealMask(animateNewSegments: false) - }) - } + ComponentTransition(animation: .curve(duration: 0.22, curve: .easeInOut)).animateBlur(layer: snippetLayer, fromRadius: 2.0, toRadius: 0.0) + snippetLayer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) + snippetLayer.animatePosition(from: CGPoint(x: 0.0, y: 6.0), to: CGPoint(), duration: 0.2, additive: true) + snippetLayer.animateScale(from: 0.5, to: 1.0, duration: 0.2, completion: { [weak self, weak snippetLayer] _ in + guard let self, let snippetLayer else { + return + } + snippetLayer.removeFromSuperlayer() + self.animatingSnippetLayers.removeAll(where: { $0 === snippetLayer }) + self.updateRevealMask(animateNewSegments: false) + }) } globalCharIndex += lineCharCount }