Fix Read iCloud profile before starting

This commit is contained in:
世界
2024-05-03 17:15:01 +08:00
parent 6a8fb1156f
commit 17eec08615
5 changed files with 25 additions and 15 deletions
+11
View File
@@ -50,6 +50,7 @@ public class ExtensionProfile: ObservableObject {
}
public func start() async throws {
await fetchProfile()
manager.isEnabled = true
if await SharedPreferences.alwaysOn.get() {
manager.isOnDemandEnabled = true
@@ -76,6 +77,16 @@ public class ExtensionProfile: ObservableObject {
try manager.connection.startVPNTunnel()
}
public func fetchProfile() async {
do {
if let profile = try await ProfileManager.get(Int64(SharedPreferences.selectedProfileID.get())) {
if profile.type == .icloud {
_ = try profile.read()
}
}
} catch {}
}
public func stop() async throws {
if manager.isOnDemandEnabled {
manager.isOnDemandEnabled = false