refactor(apple): Downgrade error for repeated sysex enabling (#7816)

If the user again clicks `Enable System Extension` without having
actually enabled it in system settings, this error will be reported. We
don't necessarily need to act on it.
This commit is contained in:
Jamil
2025-01-21 21:32:10 -08:00
committed by GitHub
parent d898884ddb
commit 0dcb14d9a2

View File

@@ -8,6 +8,10 @@
import SwiftUI
import Combine
#if os(macOS)
import SystemExtensions
#endif
@MainActor
final class GrantVPNViewModel: ObservableObject {
@Published var isInstalled: Bool = false
@@ -33,13 +37,19 @@ final class GrantVPNViewModel: ObservableObject {
do {
try await store.installSystemExtension()
// The window has a tendency to go to the background after installing
// the system extension
NSApp.activate(ignoringOtherApps: true)
} catch {
Log.error(error)
if let error = error as? OSSystemExtensionError,
case OSSystemExtensionError.requestSuperseded = error { // Code 12
// This will happen if the user repeatedly clicks the `Enable` button
// before actually enabling it in system settings.
Log.info("\(#function): Request superseded: \(error)")
} else {
Log.error(error)
}
}
}
}