File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
Coder-Desktop/Coder-Desktop Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -155,19 +155,28 @@ class AppState: ObservableObject {
155155 }
156156 }
157157
158+ private var refreshTask : Task < String ? , Never > ?
158159 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
163170 }
164- hostnameSuffix = res ?? Self . defaultHostnameSuffix
171+
172+ self . hostnameSuffix = await refreshTask? . value ?? Self . defaultHostnameSuffix
165173 }
166174 }
167175
168176 public func clearSession( ) {
169177 hasSession = false
170178 sessionToken = nil
179+ refreshTask? . cancel ( )
171180 client = nil
172181 reconfigure ( )
173182 }
You can’t perform that action at this time.
0 commit comments