Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfebf414

Browse files
committed
fix: temporarily disable vpn toggle after toggling off
1 parentddf21a7 commitfebf414

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎Coder Desktop/Coder Desktop/Views/VPNMenu.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ struct VPNMenu<VPN: VPNService, S: Session>: View {
55
@EnvironmentObjectvarsession:S
66
@Environment(\.openSettings)privatevaropenSettings
77

8+
// There appears to be a race between the VPN service reporting itself as disconnected,
9+
// and the system extension process exiting. When the VPN is toggled off and on quickly,
10+
// an error is shown: "The VPN session failed because an internal error occurred".
11+
// This forces the user to wait a few seconds before they can toggle the VPN back on.
12+
@StateprivatevarwaitCleanup=false
13+
privatevarwaitCleanupDuration:Duration=.seconds(4)
14+
815
letinspection=Inspection<Self>()
916

1017
varbody:someView{
@@ -16,7 +23,7 @@ struct VPNMenu<VPN: VPNService, S: Session>: View {
1623
Toggle(isOn:Binding(
1724
get:{ vpn.state==.connected || vpn.state==.connecting},
1825
set:{ isOninTask{
19-
if isOn{await vpn.start()}else{awaitvpn.stop()}
26+
if isOn{await vpn.start()}else{awaitstop()}
2027
}
2128
}
2229
)){
@@ -86,11 +93,21 @@ struct VPNMenu<VPN: VPNService, S: Session>: View {
8693
}
8794

8895
privatevarvpnDisabled:Bool{
96+
waitCleanup ||
8997
!session.hasSession ||
9098
vpn.state==.connecting ||
9199
vpn.state==.disconnecting ||
92100
vpn.state==.failed(.systemExtensionError(.needsUserApproval))
93101
}
102+
103+
privatefunc stop()async{
104+
await vpn.stop()
105+
waitCleanup=true
106+
Task{
107+
tryawaitTask.sleep(for: waitCleanupDuration)
108+
waitCleanup=false
109+
}
110+
}
94111
}
95112

96113
func openSystemExtensionSettings(){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp