fix: custom service settings sync

This commit is contained in:
Carl-Robert Linnupuu 2024-04-21 01:39:26 +03:00
parent 6e6a499105
commit 39679d9ee9

View file

@ -14,9 +14,9 @@ class CustomServiceSettings :
SimplePersistentStateComponent<CustomServiceState>(CustomServiceState()) {
override fun loadState(state: CustomServiceState) {
this.state.run {
// Migrate old settings
if (state.url != null || state.body.isNotEmpty() || state.headers.isNotEmpty()) {
if (state.url != null || state.body.isNotEmpty() || state.headers.isNotEmpty()) {
super.loadState(this.state.apply {
// Migrate old settings
template = state.template
chatCompletionSettings.url = state.url
chatCompletionSettings.body = state.body
@ -24,7 +24,9 @@ class CustomServiceSettings :
url = null
body = mutableMapOf()
headers = mutableMapOf()
}
})
} else {
super.loadState(state)
}
}
}