Skip to content

Commit

Permalink
Merge pull request #14 from Taewan-P/fix/system-prompt-state-mismatch
Browse files Browse the repository at this point in the history
Fix system prompt state mismatch when dialog is canceled
  • Loading branch information
Taewan-P authored Jul 4, 2024
2 parents 5475eb4 + 5da1e32 commit 7b6e04a
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ fun SystemPromptDialog(
if (dialogState.isSystemPromptDialogOpen) {
SystemPromptDialog(
prompt = systemPrompt,
onTextChange = { settingViewModel.updateSystemPrompt(apiType, it) },
onDismissRequest = settingViewModel::closeSystemPromptDialog
) {
settingViewModel.updateSystemPrompt(apiType, it)
settingViewModel.savePlatformSettings()
settingViewModel.closeSystemPromptDialog()
}
Expand Down Expand Up @@ -384,11 +384,11 @@ private fun TopPDialog(
@Composable
private fun SystemPromptDialog(
prompt: String,
onTextChange: (text: String) -> Unit,
onDismissRequest: () -> Unit,
onConfirmRequest: () -> Unit
onConfirmRequest: (text: String) -> Unit
) {
val configuration = LocalConfiguration.current
var textFieldPrompt by remember { mutableStateOf(prompt) }

AlertDialog(
properties = DialogProperties(usePlatformDefaultWidth = false),
Expand All @@ -403,8 +403,8 @@ private fun SystemPromptDialog(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp, vertical = 16.dp),
value = prompt,
onValueChange = onTextChange,
value = textFieldPrompt,
onValueChange = { textFieldPrompt = it },
label = {
Text(stringResource(R.string.system_prompt))
}
Expand All @@ -414,8 +414,8 @@ private fun SystemPromptDialog(
onDismissRequest = onDismissRequest,
confirmButton = {
TextButton(
enabled = prompt.isNotBlank(),
onClick = { onConfirmRequest() }
enabled = textFieldPrompt.isNotBlank(),
onClick = { onConfirmRequest(textFieldPrompt) }
) {
Text(stringResource(R.string.confirm))
}
Expand Down

0 comments on commit 7b6e04a

Please sign in to comment.