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 backportbot[bot]
parent 3ae4e49e06
commit 2a4910e194
5 changed files with 13 additions and 9 deletions

View file

@ -1,7 +1,7 @@
/*
* 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
*/

View file

@ -1,7 +1,7 @@
/*
* 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
*/
@ -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",

View file

@ -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

View file

@ -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
}
}

View file

@ -2,7 +2,7 @@
<!--
~ 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
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"