Skip to content

Commit

Permalink
Save settings at the last step
Browse files Browse the repository at this point in the history
  • Loading branch information
Taewan-P committed May 22, 2024
1 parent 3c4bcef commit ad5fc4f
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class SetupActivity : ComponentActivity() {
setupViewModel.updateCheckedState(it)
},
onNextButtonClicked = {
setupViewModel.saveCheckedState()
proceedToNextStep(navController)
}
)
Expand All @@ -100,7 +99,6 @@ class SetupActivity : ComponentActivity() {
setupViewModel.updateToken(platform, "")
},
onNextButtonClicked = {
setupViewModel.saveTokenState()
proceedToNextStep(navController)
}
)
Expand All @@ -116,7 +114,6 @@ class SetupActivity : ComponentActivity() {
setupViewModel.updateModel(ApiType.OPENAI, model)
},
onNextButtonClicked = {
setupViewModel.saveModelState()
proceedToNextStep(navController)
}
)
Expand All @@ -132,7 +129,6 @@ class SetupActivity : ComponentActivity() {
setupViewModel.updateModel(ApiType.ANTHROPIC, model)
},
onNextButtonClicked = {
setupViewModel.saveModelState()
proceedToNextStep(navController)
}
)
Expand All @@ -148,15 +144,17 @@ class SetupActivity : ComponentActivity() {
setupViewModel.updateModel(ApiType.GOOGLE, model)
},
onNextButtonClicked = {
setupViewModel.saveModelState()
proceedToNextStep(navController)
}
)
}
composable(route = SetupStep.SETUP_COMPLETE.name) {
SetupCompleteScreen(
modifier = Modifier.fillMaxSize(),
onNextButtonClicked = { proceedToNextStep(navController) }
onNextButtonClicked = {
saveSettings()
proceedToNextStep(navController)
}
)
}
}
Expand Down Expand Up @@ -213,6 +211,12 @@ class SetupActivity : ComponentActivity() {
return model
}

private fun saveSettings() {
setupViewModel.saveCheckedState()
setupViewModel.saveTokenState()
setupViewModel.saveModelState()
}

private fun proceedToNextStep(navController: NavHostController) {
Log.d("status", setupViewModel.platformState.value.toString())
val nextStep = nextSetupRoute(navController.currentDestination?.route, setupViewModel.platformState.value)
Expand Down

0 comments on commit ad5fc4f

Please sign in to comment.