mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-22 04:59:34 +01:00
hide system messages related to reactions
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
2986f7c3a5
commit
0b898616a2
@ -2087,7 +2087,7 @@ class ChatController(args: Bundle) :
|
|||||||
if (response.code() == HTTP_CODE_OK) {
|
if (response.code() == HTTP_CODE_OK) {
|
||||||
|
|
||||||
val chatOverall = response.body() as ChatOverall?
|
val chatOverall = response.body() as ChatOverall?
|
||||||
val chatMessageList = setDeletionFlagsAndRemoveInfomessages(chatOverall?.ocs!!.data)
|
val chatMessageList = handleSystemMessages(chatOverall?.ocs!!.data)
|
||||||
|
|
||||||
if (chatMessageList.isNotEmpty() &&
|
if (chatMessageList.isNotEmpty() &&
|
||||||
ChatMessage.SystemMessageType.CLEARED_CHAT == chatMessageList[0].systemMessageType
|
ChatMessage.SystemMessageType.CLEARED_CHAT == chatMessageList[0].systemMessageType
|
||||||
@ -2336,11 +2336,13 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setDeletionFlagsAndRemoveInfomessages(chatMessageList: List<ChatMessage>): List<ChatMessage> {
|
private fun handleSystemMessages(chatMessageList: List<ChatMessage>): List<ChatMessage> {
|
||||||
val chatMessageMap = chatMessageList.map { it.id to it }.toMap().toMutableMap()
|
val chatMessageMap = chatMessageList.map { it.id to it }.toMap().toMutableMap()
|
||||||
val chatMessageIterator = chatMessageMap.iterator()
|
val chatMessageIterator = chatMessageMap.iterator()
|
||||||
while (chatMessageIterator.hasNext()) {
|
while (chatMessageIterator.hasNext()) {
|
||||||
val currentMessage = chatMessageIterator.next()
|
val currentMessage = chatMessageIterator.next()
|
||||||
|
|
||||||
|
// setDeletionFlagsAndRemoveInfomessages
|
||||||
if (isInfoMessageAboutDeletion(currentMessage)) {
|
if (isInfoMessageAboutDeletion(currentMessage)) {
|
||||||
if (!chatMessageMap.containsKey(currentMessage.value.parentMessage.id)) {
|
if (!chatMessageMap.containsKey(currentMessage.value.parentMessage.id)) {
|
||||||
// if chatMessageMap doesnt't contain message to delete (this happens when lookingIntoFuture),
|
// if chatMessageMap doesnt't contain message to delete (this happens when lookingIntoFuture),
|
||||||
@ -2351,6 +2353,11 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
chatMessageIterator.remove()
|
chatMessageIterator.remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete reactions system messages
|
||||||
|
else if (isReactionsMessage(currentMessage)) {
|
||||||
|
chatMessageIterator.remove()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return chatMessageMap.values.toList()
|
return chatMessageMap.values.toList()
|
||||||
}
|
}
|
||||||
@ -2360,6 +2367,12 @@ class ChatController(args: Bundle) :
|
|||||||
.SystemMessageType.MESSAGE_DELETED
|
.SystemMessageType.MESSAGE_DELETED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isReactionsMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean {
|
||||||
|
return currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.REACTION ||
|
||||||
|
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.REACTION_DELETED ||
|
||||||
|
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.REACTION_REVOKED
|
||||||
|
}
|
||||||
|
|
||||||
private fun startACall(isVoiceOnlyCall: Boolean) {
|
private fun startACall(isVoiceOnlyCall: Boolean) {
|
||||||
if (currentConversation?.canStartCall == false && currentConversation?.hasCall == false) {
|
if (currentConversation?.canStartCall == false && currentConversation?.hasCall == false) {
|
||||||
Toast.makeText(context, R.string.startCallForbidden, Toast.LENGTH_LONG).show()
|
Toast.makeText(context, R.string.startCallForbidden, Toast.LENGTH_LONG).show()
|
||||||
|
Loading…
Reference in New Issue
Block a user