diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/TemporaryMessageInterface.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/TemporaryMessageInterface.kt index 353aa4471..44dab23af 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/TemporaryMessageInterface.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/TemporaryMessageInterface.kt @@ -1,7 +1,7 @@ /* * Nextcloud Talk - Android Client * - * SPDX-FileCopyrightText: 2024 Your Name + * SPDX-FileCopyrightText: 2024 Julius Linus * SPDX-License-Identifier: GPL-3.0-or-later */ diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/TemporaryMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/TemporaryMessageViewHolder.kt index 1300be713..25a7d7878 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/TemporaryMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/TemporaryMessageViewHolder.kt @@ -1,7 +1,7 @@ /* * Nextcloud Talk - Android Client * - * SPDX-FileCopyrightText: 2024 Your Name + * SPDX-FileCopyrightText: 2024 Julius Linus * SPDX-License-Identifier: GPL-3.0-or-later */ @@ -91,7 +91,7 @@ class TemporaryMessageViewHolder(outgoingView: View, payload: Any) : } // parent message handling - if (!message.isDeleted && message.parentMessageId != null) { + if (message.parentMessageId != null && message.parentMessageId!! > 0) { processParentMessage(message) binding.messageQuote.quotedChatMessageView.visibility = View.VISIBLE } else { @@ -132,6 +132,8 @@ class TemporaryMessageViewHolder(outgoingView: View, payload: Any) : parentChatMessage!!.activeUser = message.activeUser parentChatMessage.imageUrl?.let { binding.messageQuote.quotedMessageImage.visibility = View.VISIBLE + val placeholder = context.resources.getDrawable(R.drawable.ic_mimetype_image) + binding.messageQuote.quotedMessageImage.setImageDrawable(placeholder) binding.messageQuote.quotedMessageImage.load(it) { addHeader( "Authorization", diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index fc044e748..c4849e6be 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -550,6 +550,7 @@ class ChatActivity : temporaryChatMessage.parentMessageId = qMsg.replyTo!!.toLong() val pos = adapter?.getMessagePositionById(qMsg.replyTo.toString()) adapter?.addToStart(temporaryChatMessage, true) + adapter?.notifyDataSetChanged() } } @@ -562,6 +563,7 @@ class ChatActivity : i++ pos = adapter?.getMessagePositionById("-3") } + adapter?.notifyDataSetChanged() Log.d("Julius", "End i: $i") } @@ -653,8 +655,8 @@ class ChatActivity : withCredentials = credentials!!, withUrl = urlForChatting ) + messageInputViewModel.getTempMessagesFromMessageQueue(roomToken) } - messageInputViewModel.getTempMessagesFromMessageQueue(roomToken) } is ChatViewModel.GetCapabilitiesErrorState -> { @@ -3685,8 +3687,8 @@ class ChatActivity : messageInputViewModel.removeFromQueue(roomToken, id) var i = 0 val max = messageInputViewModel.messageQueueSizeFlow.value?.plus(1) - for (item in adapter?.items!!) { // TODO fix weird delay - if (i > max!!) break + for (item in adapter?.items!!) { + if (i > max!! && max < 1) break if (item.item is ChatMessage && (item.item as ChatMessage).isTempMessage && (item.item as ChatMessage).tempMessageId == id diff --git a/app/src/main/java/com/nextcloud/talk/chat/viewmodels/MessageInputViewModel.kt b/app/src/main/java/com/nextcloud/talk/chat/viewmodels/MessageInputViewModel.kt index d52fd9368..3275d1ae2 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/viewmodels/MessageInputViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/viewmodels/MessageInputViewModel.kt @@ -258,7 +258,6 @@ class MessageInputViewModel @Inject constructor( dataStore.saveMessageQueue(roomToken, null) // empties the queue while (queue.size > 0) { val msg = queue.removeFirst() - sleep(DELAY_BETWEEN_QUEUED_MESSAGES) sendChatMessage( roomToken, credentials, @@ -268,6 +267,7 @@ class MessageInputViewModel @Inject constructor( msg.replyTo!!, msg.sendWithoutNotification!! ) + sleep(DELAY_BETWEEN_QUEUED_MESSAGES) } _messageQueueSizeFlow.tryEmit(0) } @@ -316,6 +316,6 @@ class MessageInputViewModel @Inject constructor( companion object { private val TAG = MessageInputViewModel::class.java.simpleName - private const val DELAY_BETWEEN_QUEUED_MESSAGES: Long = 100 + private const val DELAY_BETWEEN_QUEUED_MESSAGES: Long = 1000 } } diff --git a/app/src/main/res/layout/item_temporary_message.xml b/app/src/main/res/layout/item_temporary_message.xml index 191af1ce1..dd8f3ab49 100644 --- a/app/src/main/res/layout/item_temporary_message.xml +++ b/app/src/main/res/layout/item_temporary_message.xml @@ -2,7 +2,7 @@