Fix always on
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import Libbox
|
||||
import Library
|
||||
import NetworkExtension
|
||||
import SwiftUI
|
||||
@@ -81,16 +80,7 @@ public struct StartStopButton: View {
|
||||
try await profile.start()
|
||||
await environments.logClient.connect()
|
||||
} else {
|
||||
var err: Error?
|
||||
do {
|
||||
try LibboxNewStandaloneCommandClient()!.serviceClose()
|
||||
} catch {
|
||||
err = error
|
||||
}
|
||||
await profile.stop()
|
||||
if let err {
|
||||
throw err
|
||||
}
|
||||
try await profile.stop()
|
||||
}
|
||||
} catch {
|
||||
await MainActor.run {
|
||||
|
||||
@@ -38,7 +38,7 @@ struct StartServiceIntent: AppIntent {
|
||||
}
|
||||
try LibboxNewStandaloneCommandClient()!.serviceReload()
|
||||
} else if extensionProfile.status.isConnected {
|
||||
extensionProfile.stop()
|
||||
try await extensionProfile.stop()
|
||||
try await Task.sleep(nanoseconds: UInt64(100 * Double(NSEC_PER_MSEC)))
|
||||
try await extensionProfile.start()
|
||||
} else {
|
||||
@@ -65,7 +65,7 @@ struct RestartServiceIntent: AppIntent {
|
||||
if extensionProfile.status == .connected {
|
||||
try LibboxNewStandaloneCommandClient()!.serviceReload()
|
||||
} else if extensionProfile.status.isConnected {
|
||||
extensionProfile.stop()
|
||||
try await extensionProfile.stop()
|
||||
try await Task.sleep(nanoseconds: UInt64(100 * Double(NSEC_PER_MSEC)))
|
||||
try await extensionProfile.start()
|
||||
} else {
|
||||
@@ -89,7 +89,7 @@ struct StopServiceIntent: AppIntent {
|
||||
guard let extensionProfile = try await (ExtensionProfile.load()) else {
|
||||
return .result()
|
||||
}
|
||||
extensionProfile.stop()
|
||||
try await extensionProfile.stop()
|
||||
return .result()
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ struct ToggleServiceIntent: AppIntent {
|
||||
return .result(value: false)
|
||||
}
|
||||
if extensionProfile.status.isConnected {
|
||||
extensionProfile.stop()
|
||||
try await extensionProfile.stop()
|
||||
return .result(value: false)
|
||||
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Foundation
|
||||
import Libbox
|
||||
import NetworkExtension
|
||||
|
||||
public class ExtensionProfile: ObservableObject {
|
||||
@@ -75,8 +76,14 @@ public class ExtensionProfile: ObservableObject {
|
||||
try manager.connection.startVPNTunnel()
|
||||
}
|
||||
|
||||
public func stop() {
|
||||
public func stop() async throws {
|
||||
if manager.isOnDemandEnabled {
|
||||
manager.isOnDemandEnabled = false
|
||||
try await manager.saveToPreferences()
|
||||
}
|
||||
do {
|
||||
try LibboxNewStandaloneCommandClient()!.serviceClose()
|
||||
} catch {}
|
||||
manager.connection.stopVPNTunnel()
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ public struct MenuView: View {
|
||||
if isEnabled {
|
||||
try await profile.start()
|
||||
} else {
|
||||
profile.stop()
|
||||
try await profile.stop()
|
||||
}
|
||||
} catch {
|
||||
alert = Alert(error)
|
||||
|
||||
Reference in New Issue
Block a user