Various fixes

This commit is contained in:
Ilya Laktyushin
2024-10-07 16:26:17 +04:00
parent 4aefac47ac
commit 0c7f3223c6
14 changed files with 64 additions and 80 deletions

View File

@@ -784,7 +784,6 @@ private func createGiveawayControllerEntries(
entries.append(.prepaid(presentationData.theme, title, text, prepaidGiveaway))
}
var starsPerUser: Int64 = 0
if case .generic = subject, case .starsGiveaway = state.mode, !starsGiveawayOptions.isEmpty {
let selectedOption = starsGiveawayOptions.first(where: { $0.giveawayOption.count == state.stars })!
entries.append(.starsHeader(presentationData.theme, presentationData.strings.BoostGift_Stars_Title.uppercased(), presentationData.strings.BoostGift_Stars_Boosts(selectedOption.giveawayOption.yearlyBoosts).uppercased()))
@@ -795,13 +794,16 @@ private func createGiveawayControllerEntries(
continue
}
let giftTitle: String = presentationData.strings.BoostGift_Stars_Stars(Int32(product.giveawayOption.count))
let winners = product.giveawayOption.winners.first(where: { $0.users == state.winners }) ?? product.giveawayOption.winners.first!
let maxWinners = product.giveawayOption.winners.sorted(by: { $0.users < $1.users }).last?.users ?? 1
let subtitle = presentationData.strings.BoostGift_Stars_PerUser("\(winners.starsPerUser)").string
let starsPerUser: Int64
if let winners = product.giveawayOption.winners.first(where: { $0.users == state.winners }) {
starsPerUser = winners.starsPerUser
} else {
starsPerUser = product.giveawayOption.count / Int64(state.winners)
}
let subtitle = presentationData.strings.BoostGift_Stars_PerUser("\(starsPerUser)").string
let label = product.storeProduct.price
starsPerUser = winners.starsPerUser
let isSelected = product.giveawayOption.count == state.stars
entries.append(.stars(i, presentationData.theme, Int32(product.giveawayOption.count), giftTitle, subtitle, label, isSelected, maxWinners))
@@ -941,7 +943,6 @@ private func createGiveawayControllerEntries(
if state.mode == .starsGiveaway {
let starsString = presentationData.strings.BoostGift_AdditionalPrizesInfoStars(Int32(state.stars))
if state.prizeDescription.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
let _ = starsPerUser
prizeDescriptionInfoText = presentationData.strings.BoostGift_AdditionalPrizesInfoStarsOn(starsString, "").string
} else {
prizeDescriptionInfoText = presentationData.strings.BoostGift_AdditionalPrizesInfoStarsOn(starsString, presentationData.strings.BoostGift_AdditionalPrizesInfoStarsAndOther("\(state.winners)", state.prizeDescription).string).string