File tree 1 file changed +14
-5
lines changed
Coder-Desktop/Coder-Desktop
1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -155,19 +155,28 @@ class AppState: ObservableObject {
155
155
}
156
156
}
157
157
158
+ private var refreshTask : Task < String ? , Never > ?
158
159
public func refreshDeploymentConfig( ) async {
159
- if hasSession {
160
- let res = try ? await retry ( floor: . milliseconds( 100 ) , ceil: . seconds( 10 ) ) {
161
- let config = try await client!. agentConnectionInfoGeneric ( )
162
- return config. hostname_suffix
160
+ // Client is non-nil if there's a sesssion
161
+ if hasSession, let client {
162
+ refreshTask? . cancel ( )
163
+
164
+ refreshTask = Task {
165
+ let res = try ? await retry ( floor: . milliseconds( 100 ) , ceil: . seconds( 10 ) ) {
166
+ let config = try await client. agentConnectionInfoGeneric ( )
167
+ return config. hostname_suffix
168
+ }
169
+ return res
163
170
}
164
- hostnameSuffix = res ?? Self . defaultHostnameSuffix
171
+
172
+ self . hostnameSuffix = await refreshTask? . value ?? Self . defaultHostnameSuffix
165
173
}
166
174
}
167
175
168
176
public func clearSession( ) {
169
177
hasSession = false
170
178
sessionToken = nil
179
+ refreshTask? . cancel ( )
171
180
client = nil
172
181
reconfigure ( )
173
182
}
You can’t perform that action at this time.
0 commit comments