From d4f4e1076162b8f631d686e4d430b3d91ce60ff5 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 6 Jul 2022 14:25:24 +0200 Subject: [PATCH 1/2] Fix invoice image loading --- .../Sources/BotCheckoutHeaderItem.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutHeaderItem.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutHeaderItem.swift index 38bbe6315c..48847922ce 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutHeaderItem.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutHeaderItem.swift @@ -8,6 +8,7 @@ import TelegramPresentationData import ItemListUI import PresentationDataUtils import PhotoResources +import Postbox class BotCheckoutHeaderItem: ListViewItem, ItemListItem { let account: Account @@ -77,6 +78,8 @@ class BotCheckoutHeaderItemNode: ListViewItemNode { private var item: BotCheckoutHeaderItem? + private let fetchDisposable = MetaDisposable() + init() { self.backgroundNode = ASDisplayNode() self.backgroundNode.isLayerBacked = true @@ -119,6 +122,10 @@ class BotCheckoutHeaderItemNode: ListViewItemNode { self.addSubnode(self.botNameNode) } + deinit { + self.fetchDisposable.dispose() + } + func asyncLayout() -> (_ item: BotCheckoutHeaderItem, _ params: ListViewItemLayoutParams, _ neighbors: ItemListNeighbors) -> (ListViewItemNodeLayout, () -> Void) { let makeTitleLayout = TextNode.asyncLayout(self.titleNode) let makeTextLayout = TextNode.asyncLayout(self.textNode) @@ -159,12 +166,14 @@ class BotCheckoutHeaderItemNode: ListViewItemNode { var imageApply: (() -> Void)? var updatedImageSignal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>? + var updatedFetchSignal: Signal? if let photo = item.invoice.photo, let dimensions = photo.dimensions { let arguments = TransformImageArguments(corners: ImageCorners(radius: 4.0), imageSize: dimensions.cgSize.aspectFilled(imageSize), boundingSize: imageSize, intrinsicInsets: UIEdgeInsets(), emptyColor: item.theme.list.mediaPlaceholderColor) imageApply = makeImageLayout(arguments) maxTextWidth = max(1.0, maxTextWidth - imageSize.width - imageTextSpacing) if imageUpdated { updatedImageSignal = chatWebFileImage(account: item.account, file: photo) + updatedFetchSignal = fetchedMediaResource(mediaBox: item.account.postbox.mediaBox, reference: .standalone(resource: photo.resource)) } } @@ -206,6 +215,9 @@ class BotCheckoutHeaderItemNode: ListViewItemNode { if let updatedImageSignal = updatedImageSignal { strongSelf.imageNode.setSignal(updatedImageSignal) } + if let updatedFetchSignal = updatedFetchSignal { + strongSelf.fetchDisposable.set(updatedFetchSignal.start()) + } strongSelf.imageNode.isHidden = false } else { strongSelf.imageNode.isHidden = true From 2377d3e08c581e0cf0c98b7697a19bb3e788b772 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 6 Jul 2022 14:25:48 +0200 Subject: [PATCH 2/2] Fix button interactions --- submodules/ComponentFlow/Source/Host/ComponentHostView.swift | 5 ++++- .../Sources/AudioTranscriptionButtonComponent.swift | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/submodules/ComponentFlow/Source/Host/ComponentHostView.swift b/submodules/ComponentFlow/Source/Host/ComponentHostView.swift index 0e27198b92..e5407341f4 100644 --- a/submodules/ComponentFlow/Source/Host/ComponentHostView.swift +++ b/submodules/ComponentFlow/Source/Host/ComponentHostView.swift @@ -109,8 +109,11 @@ public final class ComponentHostView: UIView { if self.alpha.isZero { return nil } + if !self.isUserInteractionEnabled { + return nil + } for view in self.subviews.reversed() { - if let result = view.hitTest(self.convert(point, to: view), with: event), result.isUserInteractionEnabled { + if view.isUserInteractionEnabled, view.alpha != 0.0, let result = view.hitTest(self.convert(point, to: view), with: event) { return result } } diff --git a/submodules/TelegramUI/Components/AudioTranscriptionButtonComponent/Sources/AudioTranscriptionButtonComponent.swift b/submodules/TelegramUI/Components/AudioTranscriptionButtonComponent/Sources/AudioTranscriptionButtonComponent.swift index 800d67a95d..9965a8ca92 100644 --- a/submodules/TelegramUI/Components/AudioTranscriptionButtonComponent/Sources/AudioTranscriptionButtonComponent.swift +++ b/submodules/TelegramUI/Components/AudioTranscriptionButtonComponent/Sources/AudioTranscriptionButtonComponent.swift @@ -48,7 +48,6 @@ public final class AudioTranscriptionButtonComponent: Component { override init(frame: CGRect) { self.backgroundLayer = SimpleLayer() self.animationView = ComponentHostView() - self.animationView.isUserInteractionEnabled = false super.init(frame: frame) @@ -56,6 +55,8 @@ public final class AudioTranscriptionButtonComponent: Component { self.backgroundLayer.cornerRadius = 10.0 self.layer.addSublayer(self.backgroundLayer) + self.animationView.isUserInteractionEnabled = false + self.addSubview(self.animationView) self.addTarget(self, action: #selector(self.pressed), for: .touchUpInside)