fix: Ensure initial status length calculation includes the content warning (#821)

Previous code set `doOnTextChanged` listener for the content warning
*after* the initial value had been set. This meant the initial content
warning text was not included when calculating the status' initial
length.

Fix that by setting the listener before the text is set.

Fixes #815
This commit is contained in:
Nik Clayton 2024-07-14 22:59:26 +02:00 committed by GitHub
parent 00a2cd32d3
commit 311e45168e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -396,12 +396,12 @@ class ComposeActivity :
} }
private fun setupContentWarningField(startingContentWarning: String?) { private fun setupContentWarningField(startingContentWarning: String?) {
if (startingContentWarning != null) {
binding.composeContentWarningField.setText(startingContentWarning)
}
binding.composeContentWarningField.doOnTextChanged { newContentWarning, _, _, _ -> binding.composeContentWarningField.doOnTextChanged { newContentWarning, _, _, _ ->
viewModel.onContentWarningChanged(newContentWarning?.toString() ?: "") viewModel.onContentWarningChanged(newContentWarning?.toString() ?: "")
} }
if (startingContentWarning != null) {
binding.composeContentWarningField.setText(startingContentWarning)
}
} }
private fun setupComposeField( private fun setupComposeField(