Various fixes

This commit is contained in:
Ilya Laktyushin 2023-10-23 19:51:37 +04:00
parent fcac7312f9
commit 85207874a1
2 changed files with 18 additions and 4 deletions

View File

@ -62,7 +62,9 @@ public func PremiumBoostScreen(
}
let subject: PremiumLimitScreen.Subject = .storiesChannelBoost(peer: peer, isCurrent: isCurrent, level: currentLevel, currentLevelBoosts: currentLevelBoosts, nextLevelBoosts: nextLevelBoosts, link: nil, myBoostCount: myBoostCount)
let nextSubject: PremiumLimitScreen.Subject = .storiesChannelBoost(peer: peer, isCurrent: isCurrent, level: currentLevel, currentLevelBoosts: currentLevelBoosts, nextLevelBoosts: nextLevelBoosts, link: nil, myBoostCount: myBoostCount + 1)
let nextSubject = Promise<PremiumLimitScreen.Subject>()
nextSubject.set(.single(.storiesChannelBoost(peer: peer, isCurrent: isCurrent, level: currentLevel, currentLevelBoosts: currentLevelBoosts, nextLevelBoosts: nextLevelBoosts, link: nil, myBoostCount: myBoostCount + 1)))
var nextCount = Int32(status.boosts + 1)
var updateImpl: (() -> Void)?
@ -86,7 +88,11 @@ public func PremiumBoostScreen(
if let _ = status.nextLevelBoosts {
if let availableBoost = availableBoosts.first {
let _ = context.engine.peers.applyChannelBoost(peerId: peerId, slots: [availableBoost.slot]).startStandalone()
controller?.updateSubject(nextSubject, count: nextCount)
let _ = (nextSubject.get()
|> take(1)
|> deliverOnMainQueue).startStandalone(next: { nextSubject in
controller?.updateSubject(nextSubject, count: nextCount)
})
availableBoosts.removeFirst()
nextCount += 1

View File

@ -52,14 +52,17 @@ public class WebAppCancelButtonNode: ASDisplayNode {
}
private let strings: PresentationStrings
private weak var colorSnapshotView: UIView?
public func updateColor(_ color: UIColor?, transition: ContainedViewLayoutTransition) {
let previousColor = self.color
self.color = color
if case let .animated(duration, curve) = transition, previousColor != color {
if case let .animated(duration, curve) = transition, previousColor != color, !self.animatingStateChange {
if let snapshotView = self.view.snapshotContentTree() {
snapshotView.frame = self.bounds
self.view.addSubview(snapshotView)
self.colorSnapshotView = snapshotView
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: duration, timingFunction: curve.timingFunction, removeOnCompletion: false, completion: { _ in
snapshotView.removeFromSuperview()
@ -125,6 +128,11 @@ public class WebAppCancelButtonNode: ASDisplayNode {
}
self.state = state
if let colorSnapshotView = self.colorSnapshotView {
self.colorSnapshotView = nil
colorSnapshotView.removeFromSuperview()
}
if animated, let snapshotView = self.buttonNode.view.snapshotContentTree() {
self.animatingStateChange = true
snapshotView.layer.sublayerTransform = self.buttonNode.subnodeTransform