kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
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
rodzic
06b7563356
commit
59d936ba0b
|
@ -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()
|
||||
}
|
||||
},
|
||||
|
|
Ładowanie…
Reference in New Issue