Various fixes

This commit is contained in:
Ilya Laktyushin
2023-11-06 19:59:14 +04:00
parent d06609015e
commit 1626ab578a
8 changed files with 36 additions and 29 deletions

View File

@@ -898,13 +898,7 @@ public func createGiveawayController(context: AccountContext, updatedPresentatio
let state = stateValue.with { $0 }
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
updateState { state in
var updatedState = state
updatedState.updating = true
return updatedState
}
switch subject {
case .generic:
guard let products = productsValue.with({ $0 }), !products.isEmpty else {
@@ -935,6 +929,12 @@ public func createGiveawayController(context: AccountContext, updatedPresentatio
return
}
updateState { state in
var updatedState = state
updatedState.updating = true
return updatedState
}
let (currency, amount) = selectedProduct.storeProduct.priceCurrencyAndAmount
let purpose: AppStoreTransactionPurpose
@@ -1033,6 +1033,12 @@ public func createGiveawayController(context: AccountContext, updatedPresentatio
}
})
case let .prepaid(prepaidGiveaway):
updateState { state in
var updatedState = state
updatedState.updating = true
return updatedState
}
let _ = (context.engine.payments.launchPrepaidGiveaway(peerId: peerId, id: prepaidGiveaway.id, additionalPeerIds: state.channels.filter { $0 != peerId }, countries: state.countries, onlyNewSubscribers: state.onlyNewEligible, randomId: Int64.random(in: .min ..< .max), untilDate: state.time)
|> deliverOnMainQueue).startStandalone(completed: {
if let controller, let navigationController = controller.navigationController as? NavigationController {