mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
Follow up to #2518. Also fixed the `CustomerInfo` `Picker`, which wasn't working on iOS due to its design.
31 lines
710 B
Swift
31 lines
710 B
Swift
//
|
|
// ProxyViewModel.swift
|
|
// PurchaseTester
|
|
//
|
|
// Created by Nacho Soto on 5/19/23.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
@MainActor
|
|
final class ProxyViewModel: NSObject, ObservableObject {
|
|
|
|
@Published var proxyStatus: ProxyStatus?
|
|
|
|
override init() {}
|
|
|
|
func refreshStatus(proxyURL: URL) async {
|
|
self.proxyStatus = await ProxyManager.fetchProxyStatus(proxyURL: proxyURL)
|
|
}
|
|
|
|
func changeMode(to newMode: ProxyStatus.Mode, proxyURL: URL) async {
|
|
do {
|
|
try await ProxyManager.changeMode(proxyURL: proxyURL, to: newMode)
|
|
self.proxyStatus = .enabled(newMode)
|
|
} catch {
|
|
print("Failed changing mode: \(error.localizedDescription)")
|
|
}
|
|
}
|
|
|
|
}
|