Skip to content

Commit 2c7824b

Browse files
committed
refactor: abstract logic for better readability
1 parent 1fbfdf6 commit 2c7824b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt

+7-6
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,7 @@ class CoderRemoteProvider(
262262
// start initialization with the new settings
263263
this@CoderRemoteProvider.client = restClient
264264
coderHeaderPage = NewEnvironmentPage(context, context.i18n.pnotr(restClient.url.toString()))
265-
environments.update {
266-
LoadableState.Loading
267-
}
265+
environments.showLoadingMessage()
268266
pollJob = poll(restClient, cli)
269267
}
270268
}
@@ -329,11 +327,14 @@ class CoderRemoteProvider(
329327
context.secrets.rememberMe = true
330328
this.client = client
331329
pollJob?.cancel()
330+
environments.showLoadingMessage()
331+
pollJob = poll(client, cli)
332+
goToEnvironmentsPage()
333+
}
332334

333-
environments.update {
335+
private fun MutableStateFlow<LoadableState<List<RemoteProviderEnvironment>>>.showLoadingMessage() {
336+
this.update {
334337
LoadableState.Loading
335338
}
336-
pollJob = poll(client, cli)
337-
goToEnvironmentsPage()
338339
}
339340
}

0 commit comments

Comments
 (0)