Various fixes

This commit is contained in:
Ilya Laktyushin 2024-06-27 03:28:53 +04:00
parent 331cb1edc6
commit e23c7f2e2b
4 changed files with 16 additions and 2 deletions

View File

@ -638,6 +638,7 @@ final class MediaPickerGridItemNode: GridItemNode {
self.updateHiddenMedia()
}
private var currentPrice: Int64?
private var didSetupSpoiler = false
private func updateHasSpoiler(_ hasSpoiler: Bool, price: Int64?, isSingle: Bool) {
var animated = true
@ -645,7 +646,8 @@ final class MediaPickerGridItemNode: GridItemNode {
animated = false
self.didSetupSpoiler = true
}
self.currentPrice = isSingle ? price : nil
if hasSpoiler || price != nil {
if self.spoilerNode == nil {
let spoilerNode = SpoilerOverlayNode(enableAnimations: self.enableAnimations)
@ -724,6 +726,11 @@ final class MediaPickerGridItemNode: GridItemNode {
spoilerNode.update(size: self.bounds.size, transition: .immediate)
}
if let priceNode = self.priceNode, self.bounds.width > 0.0 {
priceNode.frame = self.bounds
priceNode.update(size: self.bounds.size, price: self.currentPrice, small: true, transition: .immediate)
}
let statusSize = CGSize(width: 40.0, height: 40.0)
if let statusNode = self.statusNode {
statusNode.view.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((self.bounds.width - statusSize.width) / 2.0), y: floorToScreenPixels((self.bounds.height - statusSize.height) / 2.0)), size: statusSize)

View File

@ -2369,6 +2369,8 @@ public func channelStatsController(context: AccountContext, updatedPresentationD
withdrawalDisposable.set((context.engine.peers.checkStarsRevenueWithdrawalAvailability()
|> deliverOnMainQueue).start(error: { error in
switch error {
case .serverProvided:
return
case .requestPassword:
let _ = (starsContext.state
|> take(1)

View File

@ -234,6 +234,7 @@ public enum RequestStarsRevenueWithdrawalError : Equatable {
case limitExceeded
case requestPassword
case invalidPassword
case serverProvided(text: String)
}
func _internal_checkStarsRevenueWithdrawalAvailability(account: Account) -> Signal<Never, RequestStarsRevenueWithdrawalError> {
@ -292,7 +293,9 @@ func _internal_requestStarsRevenueWithdrawalUrl(account: Account, peerId: PeerId
|> mapToSignal { password -> Signal<String, RequestStarsRevenueWithdrawalError> in
return account.network.request(Api.functions.payments.getStarsRevenueWithdrawalUrl(peer: inputPeer, stars: amount, password: password), automaticFloodWait: false)
|> mapError { error -> RequestStarsRevenueWithdrawalError in
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
if error.errorCode == 406 {
return .serverProvided(text: error.errorDescription)
} else if error.errorDescription.hasPrefix("FLOOD_WAIT") {
return .limitExceeded
} else if error.errorDescription == "PASSWORD_HASH_INVALID" {
return .invalidPassword

View File

@ -679,6 +679,8 @@ public final class StarsStatisticsScreen: ViewControllerComponentContainer {
return
}
switch error {
case .serverProvided:
return
case .requestPassword:
let _ = (revenueContext.state
|> take(1)