mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-19 17:51:29 +00:00
Gift resell price suggestion
This commit is contained in:
parent
c4c05851a7
commit
64e772f0b1
@ -1197,7 +1197,7 @@ public protocol SharedAccountContext: AnyObject {
|
|||||||
func makeStarsAmountScreen(context: AccountContext, initialValue: Int64?, completion: @escaping (Int64) -> Void) -> ViewController
|
func makeStarsAmountScreen(context: AccountContext, initialValue: Int64?, completion: @escaping (Int64) -> Void) -> ViewController
|
||||||
func makeStarsWithdrawalScreen(context: AccountContext, stats: StarsRevenueStats, completion: @escaping (Int64) -> Void) -> ViewController
|
func makeStarsWithdrawalScreen(context: AccountContext, stats: StarsRevenueStats, completion: @escaping (Int64) -> Void) -> ViewController
|
||||||
func makeStarsWithdrawalScreen(context: AccountContext, subject: StarsWithdrawalScreenSubject, completion: @escaping (Int64) -> Void) -> ViewController
|
func makeStarsWithdrawalScreen(context: AccountContext, subject: StarsWithdrawalScreenSubject, completion: @escaping (Int64) -> Void) -> ViewController
|
||||||
func makeStarGiftResellScreen(context: AccountContext, update: Bool, completion: @escaping (Int64) -> Void) -> ViewController
|
func makeStarGiftResellScreen(context: AccountContext, gift: StarGift.UniqueGift, update: Bool, completion: @escaping (Int64) -> Void) -> ViewController
|
||||||
func makeStarsGiftScreen(context: AccountContext, message: EngineMessage) -> ViewController
|
func makeStarsGiftScreen(context: AccountContext, message: EngineMessage) -> ViewController
|
||||||
func makeStarsGiveawayBoostScreen(context: AccountContext, peerId: EnginePeer.Id, boost: ChannelBoostersContext.State.Boost) -> ViewController
|
func makeStarsGiveawayBoostScreen(context: AccountContext, peerId: EnginePeer.Id, boost: ChannelBoostersContext.State.Boost) -> ViewController
|
||||||
func makeStarsIntroScreen(context: AccountContext) -> ViewController
|
func makeStarsIntroScreen(context: AccountContext) -> ViewController
|
||||||
|
@ -862,7 +862,7 @@ private final class GiftViewSheetContent: CombinedComponent {
|
|||||||
)
|
)
|
||||||
controller.present(alertController, in: .window(.root))
|
controller.present(alertController, in: .window(.root))
|
||||||
} else {
|
} else {
|
||||||
let resellController = self.context.sharedContext.makeStarGiftResellScreen(context: self.context, update: update, completion: { [weak self, weak controller] price in
|
let resellController = self.context.sharedContext.makeStarGiftResellScreen(context: self.context, gift: gift, update: update, completion: { [weak self, weak controller] price in
|
||||||
guard let self, let controller else {
|
guard let self, let controller else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ private final class SheetContent: CombinedComponent {
|
|||||||
|
|
||||||
minAmount = StarsAmount(value: 1, nanos: 0)
|
minAmount = StarsAmount(value: 1, nanos: 0)
|
||||||
maxAmount = withdrawConfiguration.maxPaidMediaAmount.flatMap { StarsAmount(value: $0, nanos: 0) }
|
maxAmount = withdrawConfiguration.maxPaidMediaAmount.flatMap { StarsAmount(value: $0, nanos: 0) }
|
||||||
case let .starGiftResell(update):
|
case let .starGiftResell(_, update):
|
||||||
titleString = update ? environment.strings.Stars_SellGift_EditTitle : environment.strings.Stars_SellGift_Title
|
titleString = update ? environment.strings.Stars_SellGift_EditTitle : environment.strings.Stars_SellGift_Title
|
||||||
amountTitle = environment.strings.Stars_SellGift_AmountTitle
|
amountTitle = environment.strings.Stars_SellGift_AmountTitle
|
||||||
amountPlaceholder = environment.strings.Stars_SellGift_AmountPlaceholder
|
amountPlaceholder = environment.strings.Stars_SellGift_AmountPlaceholder
|
||||||
@ -487,6 +487,36 @@ private final class SheetContent: CombinedComponent {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if case let .starGiftResell(giftToMatch, update) = self.mode {
|
||||||
|
if update {
|
||||||
|
if let resellStars = giftToMatch.resellStars {
|
||||||
|
self.amount = StarsAmount(value: resellStars, nanos: 0)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let _ = (context.engine.payments.cachedStarGifts()
|
||||||
|
|> filter { $0 != nil }
|
||||||
|
|> take(1)
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] gifts in
|
||||||
|
guard let self, let gifts else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard let matchingGift = gifts.first(where: { gift in
|
||||||
|
if case let .generic(gift) = gift, gift.title == giftToMatch.title {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}) else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if case let .generic(genericGift) = matchingGift, let minResaleStars = genericGift.availability?.minResaleStars {
|
||||||
|
self.amount = StarsAmount(value: minResaleStars, nanos: 0)
|
||||||
|
self.updated()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
@ -592,7 +622,7 @@ public final class StarsWithdrawScreen: ViewControllerComponentContainer {
|
|||||||
case accountWithdraw
|
case accountWithdraw
|
||||||
case paidMedia(Int64?)
|
case paidMedia(Int64?)
|
||||||
case reaction(Int64?)
|
case reaction(Int64?)
|
||||||
case starGiftResell(Bool)
|
case starGiftResell(StarGift.UniqueGift, Bool)
|
||||||
case paidMessages(current: Int64, minValue: Int64, fractionAfterCommission: Int, kind: StarsWithdrawalScreenSubject.PaidMessageKind)
|
case paidMessages(current: Int64, minValue: Int64, fractionAfterCommission: Int, kind: StarsWithdrawalScreenSubject.PaidMessageKind)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3688,8 +3688,8 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
return StarsWithdrawScreen(context: context, mode: mode, completion: completion)
|
return StarsWithdrawScreen(context: context, mode: mode, completion: completion)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func makeStarGiftResellScreen(context: AccountContext, update: Bool, completion: @escaping (Int64) -> Void) -> ViewController {
|
public func makeStarGiftResellScreen(context: AccountContext, gift: StarGift.UniqueGift, update: Bool, completion: @escaping (Int64) -> Void) -> ViewController {
|
||||||
return StarsWithdrawScreen(context: context, mode: .starGiftResell(update), completion: completion)
|
return StarsWithdrawScreen(context: context, mode: .starGiftResell(gift, update), completion: completion)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func makeStarsGiftScreen(context: AccountContext, message: EngineMessage) -> ViewController {
|
public func makeStarsGiftScreen(context: AccountContext, message: EngineMessage) -> ViewController {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user