Fix iterating items in repositionItems

This commit is contained in:
Douile
2022-08-16 12:25:40 +01:00
parent b1b554d97d
commit 36b5a9eefb
2 changed files with 2 additions and 3 deletions

View File

@@ -493,7 +493,7 @@ class UIViewModel @Inject constructor(
fun updateActionPositions(actions: List<QuickChatAction>) {
viewModelScope.launch(Dispatchers.Main) {
for (position in 0..actions.size) {
for (position in actions.indices) {
quickChatActionRepository.setItemPosition(actions[position].uuid, position)
}
}

View File

@@ -307,15 +307,14 @@ class MessagesFragment : Fragment(), Logging {
model.quickChatActions.asLiveData().observe(viewLifecycleOwner) { actions ->
actions?.let {
// This seems kinda hacky it might be better to replace with a recycler view
binding.quickChatLayout.removeAllViews()
for (action in actions) {
val button = Button(context)
button.setText(action.name)
button.isEnabled = isConnected
if (action.mode == QuickChatAction.Mode.Instant) {
//button.setBackgroundColor(Color.rgb(200, 200, 200))
button.backgroundTintList = ContextCompat.getColorStateList(requireActivity(), R.color.colorMyMsg)
}
button.setOnClickListener {
if (action.mode == QuickChatAction.Mode.Append) {