Skip to content

Commit

Permalink
fix: custom service settings sync
Browse files Browse the repository at this point in the history
  • Loading branch information
carlrobertoh committed Apr 20, 2024
1 parent 6e6a499 commit 39679d9
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ 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
chatCompletionSettings.headers = state.headers
url = null
body = mutableMapOf()
headers = mutableMapOf()
}
})
} else {
super.loadState(state)
}
}
}
Expand Down

0 comments on commit 39679d9

Please sign in to comment.