Skip to content

Commit cb8396a

Browse files
committed
fix: update the title when settings page is closed
A restart was needed in order for the title bar to be updated. With this patch the main page title is updated as soon as the user leaves the Settings page.
1 parent 3e6de87 commit cb8396a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,25 @@ class CoderRemoteProvider(
5757

5858
private val triggerSshConfig = Channel<Boolean>(Channel.CONFLATED)
5959
private val triggerProviderVisible = Channel<Boolean>(Channel.CONFLATED)
60-
private val settingsPage: CoderSettingsPage = CoderSettingsPage(context, triggerSshConfig)
6160
private val dialogUi = DialogUi(context)
6261

6362
// The REST client, if we are signed in
6463
private var client: CoderRestClient? = null
6564

6665
// On the first load, automatically log in if we can.
6766
private var firstRun = true
67+
6868
private val isInitialized: MutableStateFlow<Boolean> = MutableStateFlow(false)
6969
private val coderHeaderPage = NewEnvironmentPage(context.i18n.pnotr(context.deploymentUrl.toString()))
70+
private val settingsPage: CoderSettingsPage = CoderSettingsPage(context, triggerSshConfig) {
71+
client?.let { restClient ->
72+
if (context.settingsStore.useAppNameAsTitle) {
73+
coderHeaderPage.setTitle(context.i18n.pnotr(restClient.appName))
74+
} else {
75+
coderHeaderPage.setTitle(context.i18n.pnotr(restClient.url.toString()))
76+
}
77+
}
78+
}
7079
private val visibilityState = MutableStateFlow(
7180
ProviderVisibilityState(
7281
applicationVisible = false,

src/main/kotlin/com/coder/toolbox/views/CoderSettingsPage.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ import kotlinx.coroutines.launch
2828
* TODO@JB: There is no scroll, and our settings do not fit. As a consequence,
2929
* I have not been able to test this page.
3030
*/
31-
class CoderSettingsPage(private val context: CoderToolboxContext, triggerSshConfig: Channel<Boolean>) :
31+
class CoderSettingsPage(
32+
private val context: CoderToolboxContext,
33+
triggerSshConfig: Channel<Boolean>,
34+
private val onSettingsClosed: () -> Unit
35+
) :
3236
CoderPage(MutableStateFlow(context.i18n.ptrl("Coder Settings")), false) {
3337
private val settings = context.settingsStore.readOnly()
3438

@@ -232,5 +236,6 @@ class CoderSettingsPage(private val context: CoderToolboxContext, triggerSshConf
232236

233237
override fun afterHide() {
234238
visibilityUpdateJob.cancel()
239+
onSettingsClosed()
235240
}
236241
}

0 commit comments

Comments
 (0)