Refactor message clearing to use centralized approach

Remove redundant text clearing from TextInput composable methods.
Keep only the centralized clearing in MessageScreen callback for better
maintainability and single responsibility. The key-based rememberSaveable
handles the state management issue, while centralized clearing ensures
text is only cleared after successful message sending.
pull/2208/head
Jeremiah K 2025-06-21 19:48:39 -05:00
rodzic 06b7563356
commit 59d936ba0b
1 zmienionych plików z 2 dodań i 3 usunięć

Wyświetl plik

@ -267,6 +267,8 @@ internal fun MessageScreen(
viewModel.sendMessage(message, contactKey, it.packetId)
replyingTo = null
} ?: viewModel.sendMessage(message, contactKey)
// Clear the text input after sending the message and updating all state
messageInput.value = TextFieldValue("")
}
}
}
@ -468,7 +470,6 @@ private fun TextInput(
val str = message.value.text.trim()
if (str.isNotEmpty()) {
onClick(str)
message.value = TextFieldValue("")
}
true // Consume the event
} else {
@ -486,7 +487,6 @@ private fun TextInput(
val str = message.value.text.trim()
if (str.isNotEmpty()) {
onClick(str)
message.value = TextFieldValue("")
}
}
),
@ -498,7 +498,6 @@ private fun TextInput(
val str = message.value.text.trim()
if (str.isNotEmpty()) {
onClick(str)
message.value = TextFieldValue("")
focusManager.clearFocus()
}
},