diff --git a/submodules/SemanticStatusNode/Sources/SemanticStatusNode.swift b/submodules/SemanticStatusNode/Sources/SemanticStatusNode.swift index c3a505ce66..ce357aee97 100644 --- a/submodules/SemanticStatusNode/Sources/SemanticStatusNode.swift +++ b/submodules/SemanticStatusNode/Sources/SemanticStatusNode.swift @@ -777,6 +777,16 @@ public final class SemanticStatusNode: ASControlNode { private var disposable: Disposable? private var backgroundNodeImage: UIImage? + private let hasLayoutPromise = ValuePromise(false, ignoreRepeated: true) + + public override func layout() { + super.layout() + + if !self.bounds.width.isZero { + self.hasLayoutPromise.set(true) + } + } + public init(backgroundNodeColor: UIColor, foregroundNodeColor: UIColor, image: Signal<(TransformImageArguments) -> DrawingContext?, NoError>? = nil, overlayForegroundNodeColor: UIColor? = nil, cutout: CGRect? = nil) { self.state = .none self.stateContext = self.state.context(current: nil) @@ -789,9 +799,8 @@ public final class SemanticStatusNode: ASControlNode { if let image = image { let start = CACurrentMediaTime() - self.disposable = (image - |> deliverOnMainQueue).start(next: { [weak self] transform in - guard let strongSelf = self else { + self.disposable = combineLatest(queue: Queue.mainQueue(), image, self.hasLayoutPromise.get()).start(next: { [weak self] transform, ready in + guard let strongSelf = self, ready else { return } let context = transform(TransformImageArguments(corners: ImageCorners(radius: strongSelf.bounds.width / 2.0), imageSize: strongSelf.bounds.size, boundingSize: strongSelf.bounds.size, intrinsicInsets: UIEdgeInsets()))