From 278f3ca420d7dd577d28815e25c99f866b07b352 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Tue, 7 Apr 2026 16:47:08 +0200 Subject: [PATCH] Various improvements --- .../Sources/SearchBarPlaceholderNode.swift | 20 ++++++++++++++----- .../Sources/ChatHistoryViewForLocation.swift | 20 +++++++++++++++++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/submodules/SearchBarNode/Sources/SearchBarPlaceholderNode.swift b/submodules/SearchBarNode/Sources/SearchBarPlaceholderNode.swift index 2e8250db45..31bed130c4 100644 --- a/submodules/SearchBarNode/Sources/SearchBarPlaceholderNode.swift +++ b/submodules/SearchBarNode/Sources/SearchBarPlaceholderNode.swift @@ -54,6 +54,7 @@ public final class SearchBarPlaceholderContentView: UIView { let fieldStyle: SearchBarStyle let plainBackgroundView: UIImageView + let glassBackgroundContainerView: GlassBackgroundContainerView? let glassBackgroundView: GlassBackgroundView? private var fillBackgroundColor: UIColor private var foregroundColor: UIColor @@ -82,8 +83,10 @@ public final class SearchBarPlaceholderContentView: UIView { switch fieldStyle { case .legacy, .modern: + self.glassBackgroundContainerView = nil self.glassBackgroundView = nil case .inlineNavigation, .glass: + self.glassBackgroundContainerView = GlassBackgroundContainerView() self.glassBackgroundView = GlassBackgroundView() } @@ -111,8 +114,9 @@ public final class SearchBarPlaceholderContentView: UIView { self.plainBackgroundView.addSubview(self.plainIconNode.view) self.plainBackgroundView.addSubview(self.plainLabelNode.view) - if let glassBackgroundView = self.glassBackgroundView { - self.addSubview(glassBackgroundView) + if let glassBackgroundContainerView = self.glassBackgroundContainerView, let glassBackgroundView = self.glassBackgroundView { + self.addSubview(glassBackgroundContainerView) + glassBackgroundContainerView.contentView.addSubview(glassBackgroundView) glassBackgroundView.contentView.addSubview(self.iconNode.view) glassBackgroundView.contentView.addSubview(self.labelNode.view) @@ -300,9 +304,14 @@ public final class SearchBarPlaceholderContentView: UIView { transition.updateFrame(view: self.plainBackgroundView, frame: CGRect(origin: CGPoint(), size: CGSize(width: params.constrainedSize.width, height: height))) } - if let glassBackgroundView = self.glassBackgroundView { - transition.updatePosition(layer: glassBackgroundView.layer, position: backgroundFrame.center) + if let glassBackgroundContainerView = self.glassBackgroundContainerView, let glassBackgroundView = self.glassBackgroundView { + + transition.updatePosition(layer: glassBackgroundContainerView.layer, position: backgroundFrame.center) + transition.updateBounds(layer: glassBackgroundContainerView.layer, bounds: CGRect(origin: CGPoint(), size: backgroundFrame.size)) + + transition.updatePosition(layer: glassBackgroundView.layer, position: CGRect(origin: CGPoint(), size: backgroundFrame.size).center) transition.updateBounds(layer: glassBackgroundView.layer, bounds: CGRect(origin: CGPoint(), size: backgroundFrame.size)) + var backgroundAlpha: CGFloat = 1.0 if backgroundFrame.height < 16.0 { backgroundAlpha = max(0.0, min(1.0, backgroundFrame.height / 16.0)) @@ -310,9 +319,10 @@ public final class SearchBarPlaceholderContentView: UIView { if !params.isActive { backgroundAlpha = 0.0 } - ComponentTransition(transition).setAlpha(view: glassBackgroundView, alpha: backgroundAlpha) + ComponentTransition(transition).setAlpha(view: glassBackgroundContainerView, alpha: backgroundAlpha) let isDark = params.backgroundColor.hsb.b < 0.5 if params.isActive { + glassBackgroundContainerView.update(size: backgroundFrame.size, isDark: isDark, transition: ComponentTransition(transition)) glassBackgroundView.update(size: backgroundFrame.size, cornerRadius: backgroundFrame.height * 0.5, isDark: isDark, tintColor: .init(kind: params.preferClearGlass ? .clear : .panel), isInteractive: true, transition: ComponentTransition(transition)) } diff --git a/submodules/TelegramUI/Sources/ChatHistoryViewForLocation.swift b/submodules/TelegramUI/Sources/ChatHistoryViewForLocation.swift index 959b23e6bc..059a2934cc 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryViewForLocation.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryViewForLocation.swift @@ -445,6 +445,22 @@ func fetchAndPreloadReplyThreadInfo(context: AccountContext, subject: ReplyThrea } if preload { + var channelMessage: Signal = .single(Void()) + if case .channelPost = subject, let channelMessageId = replyThreadMessage.channelMessageId { + channelMessage = context.engine.messages.getMessagesLoadIfNecessary([channelMessageId], strategy: .cloud(skipLocal: false)) + |> mapToSignal { result -> Signal in + switch result { + case .progress: + return .never() + case .result: + return .single(Void()) + } + } + |> `catch` { _ -> Signal in + return .single(Void()) + } + } + let preloadSignal = preloadedChatHistoryViewForLocation( input, context: context, @@ -455,8 +471,8 @@ func fetchAndPreloadReplyThreadInfo(context: AccountContext, subject: ReplyThrea tag: nil, additionalData: [] ) - return preloadSignal - |> map { historyView -> Bool? in + return combineLatest(preloadSignal, channelMessage) + |> map { historyView, _ -> Bool? in switch historyView { case .Loading: return nil