mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
• Added logic to handle non-originating accounts • Added explicit SessionPro errors • Moved profile pro decisions into the SessionProManager to consolidate the logic • Resolved a bunch of TODOs • Fixed an issue where a invalid pro key would prevent messages from decoding
51 lines
1.9 KiB
Swift
51 lines
1.9 KiB
Swift
// Copyright © 2025 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import SwiftUI
|
|
import SessionUIKit
|
|
import SessionUtilitiesKit
|
|
|
|
extension SessionProPaymentScreenContent {
|
|
public class ViewModel: ViewModelType {
|
|
public var dataModel: DataModel
|
|
public var dateNow: Date { dependencies.dateNow }
|
|
public var isRefreshing: Bool = false
|
|
public var errorString: String?
|
|
public var isFromBottomSheet: Bool
|
|
|
|
private var dependencies: Dependencies
|
|
|
|
public init(dataModel: DataModel, isFromBottomSheet: Bool, using dependencies: Dependencies) {
|
|
self.dependencies = dependencies
|
|
self.dataModel = dataModel
|
|
self.isFromBottomSheet = isFromBottomSheet
|
|
}
|
|
|
|
@MainActor public func purchase(planInfo: SessionProPlanInfo) async throws {
|
|
try await Task.detached(priority: .userInitiated) { [dependencies] in
|
|
try await dependencies[singleton: .sessionProManager].purchasePro(
|
|
productId: planInfo.id
|
|
)
|
|
}.value
|
|
}
|
|
|
|
@MainActor public func cancelPro(scene: UIWindowScene?) async throws {
|
|
guard let scene else {
|
|
Log.error(.sessionPro, "Failed to being refund request: Unable to get UIWindowScene")
|
|
throw SessionProError.windowSceneRequired
|
|
}
|
|
|
|
try await dependencies[singleton: .sessionProManager].cancelPro(scene: scene)
|
|
}
|
|
|
|
@MainActor public func requestRefund(scene: UIWindowScene?) async throws {
|
|
guard let scene else {
|
|
Log.error(.sessionPro, "Failed to being refund request: Unable to get UIWindowScene")
|
|
throw SessionProError.windowSceneRequired
|
|
}
|
|
|
|
try await dependencies[singleton: .sessionProManager].requestRefund(scene: scene)
|
|
}
|
|
}
|
|
}
|