Use keys of map entries, as they are more reliable(from testing). Extract pollViewModel.pollOptions into a separate variable.

This commit is contained in:
KotlinGeekDev 2024-07-02 09:51:34 +01:00
parent 66317f5593
commit 6efb970794

View File

@ -629,17 +629,21 @@ private fun BottomRowActions(postViewModel: NewPostViewModel) {
@Composable
private fun PollField(postViewModel: NewPostViewModel) {
val optionsList = postViewModel.pollOptions
Column(
modifier = Modifier.fillMaxWidth(),
) {
postViewModel.pollOptions.values.forEachIndexed { index, _ ->
NewPollOption(postViewModel, index)
optionsList.forEach { value ->
NewPollOption(postViewModel, value.key)
}
NewPollVoteValueRange(postViewModel)
Button(
onClick = { postViewModel.pollOptions[postViewModel.pollOptions.size] = "" },
onClick = {
// postViewModel.pollOptions[postViewModel.pollOptions.size] = ""
optionsList[optionsList.size] = ""
},
border =
BorderStroke(
1.dp,