fixed some bugs

Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
rapterjet2004 2024-10-01 09:54:23 -05:00 committed by Marcel Hibbe
parent 399fa7eb70
commit 0d9c5bfcb9
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
5 changed files with 13 additions and 9 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Nextcloud Talk - Android Client * Nextcloud Talk - Android Client
* *
* SPDX-FileCopyrightText: 2024 Your Name <your@email.com> * SPDX-FileCopyrightText: 2024 Julius Linus <juliuslinus1@gmail.com>
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */

View File

@ -1,7 +1,7 @@
/* /*
* Nextcloud Talk - Android Client * Nextcloud Talk - Android Client
* *
* SPDX-FileCopyrightText: 2024 Your Name <your@email.com> * SPDX-FileCopyrightText: 2024 Julius Linus <juliuslinus1@gmail.com>
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
@ -91,7 +91,7 @@ class TemporaryMessageViewHolder(outgoingView: View, payload: Any) :
} }
// parent message handling // parent message handling
if (!message.isDeleted && message.parentMessageId != null) { if (message.parentMessageId != null && message.parentMessageId!! > 0) {
processParentMessage(message) processParentMessage(message)
binding.messageQuote.quotedChatMessageView.visibility = View.VISIBLE binding.messageQuote.quotedChatMessageView.visibility = View.VISIBLE
} else { } else {
@ -132,6 +132,8 @@ class TemporaryMessageViewHolder(outgoingView: View, payload: Any) :
parentChatMessage!!.activeUser = message.activeUser parentChatMessage!!.activeUser = message.activeUser
parentChatMessage.imageUrl?.let { parentChatMessage.imageUrl?.let {
binding.messageQuote.quotedMessageImage.visibility = View.VISIBLE 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) { binding.messageQuote.quotedMessageImage.load(it) {
addHeader( addHeader(
"Authorization", "Authorization",

View File

@ -550,6 +550,7 @@ class ChatActivity :
temporaryChatMessage.parentMessageId = qMsg.replyTo!!.toLong() temporaryChatMessage.parentMessageId = qMsg.replyTo!!.toLong()
val pos = adapter?.getMessagePositionById(qMsg.replyTo.toString()) val pos = adapter?.getMessagePositionById(qMsg.replyTo.toString())
adapter?.addToStart(temporaryChatMessage, true) adapter?.addToStart(temporaryChatMessage, true)
adapter?.notifyDataSetChanged()
} }
} }
@ -562,6 +563,7 @@ class ChatActivity :
i++ i++
pos = adapter?.getMessagePositionById("-3") pos = adapter?.getMessagePositionById("-3")
} }
adapter?.notifyDataSetChanged()
Log.d("Julius", "End i: $i") Log.d("Julius", "End i: $i")
} }
@ -668,8 +670,8 @@ class ChatActivity :
TAG, TAG,
"currentConversation was null in observer ChatViewModel.GetCapabilitiesInitialLoadState" "currentConversation was null in observer ChatViewModel.GetCapabilitiesInitialLoadState"
) )
messageInputViewModel.getTempMessagesFromMessageQueue(roomToken)
} }
messageInputViewModel.getTempMessagesFromMessageQueue(roomToken)
} }
is ChatViewModel.GetCapabilitiesErrorState -> { is ChatViewModel.GetCapabilitiesErrorState -> {
@ -3677,8 +3679,8 @@ class ChatActivity :
messageInputViewModel.removeFromQueue(roomToken, id) messageInputViewModel.removeFromQueue(roomToken, id)
var i = 0 var i = 0
val max = messageInputViewModel.messageQueueSizeFlow.value?.plus(1) val max = messageInputViewModel.messageQueueSizeFlow.value?.plus(1)
for (item in adapter?.items!!) { // TODO fix weird delay for (item in adapter?.items!!) {
if (i > max!!) break if (i > max!! && max < 1) break
if (item.item is ChatMessage && if (item.item is ChatMessage &&
(item.item as ChatMessage).isTempMessage && (item.item as ChatMessage).isTempMessage &&
(item.item as ChatMessage).tempMessageId == id (item.item as ChatMessage).tempMessageId == id

View File

@ -258,7 +258,6 @@ class MessageInputViewModel @Inject constructor(
dataStore.saveMessageQueue(roomToken, null) // empties the queue dataStore.saveMessageQueue(roomToken, null) // empties the queue
while (queue.size > 0) { while (queue.size > 0) {
val msg = queue.removeFirst() val msg = queue.removeFirst()
sleep(DELAY_BETWEEN_QUEUED_MESSAGES)
sendChatMessage( sendChatMessage(
roomToken, roomToken,
credentials, credentials,
@ -268,6 +267,7 @@ class MessageInputViewModel @Inject constructor(
msg.replyTo!!, msg.replyTo!!,
msg.sendWithoutNotification!! msg.sendWithoutNotification!!
) )
sleep(DELAY_BETWEEN_QUEUED_MESSAGES)
} }
_messageQueueSizeFlow.tryEmit(0) _messageQueueSizeFlow.tryEmit(0)
} }
@ -316,6 +316,6 @@ class MessageInputViewModel @Inject constructor(
companion object { companion object {
private val TAG = MessageInputViewModel::class.java.simpleName 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
} }
} }

View File

@ -2,7 +2,7 @@
<!-- <!--
~ Nextcloud Talk - Android Client ~ Nextcloud Talk - Android Client
~ ~
~ SPDX-FileCopyrightText: 2023 Julius Linus <juliuslinus1@gmail.com> ~ SPDX-FileCopyrightText: 2024 Julius Linus <juliuslinus1@gmail.com>
~ SPDX-License-Identifier: GPL-3.0-or-later ~ SPDX-License-Identifier: GPL-3.0-or-later
--> -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"