Remove existing chat message reaction instead of trying to send it again

This commit is contained in:
Sylvain Berfini 2024-07-18 17:21:32 +02:00
parent 1d328f98e3
commit 83df46ca8b

View file

@ -286,9 +286,15 @@ class MessageModel @WorkerThread constructor(
@UiThread
fun sendReaction(emoji: String) {
coreContext.postOnCoreThread {
Log.i("$TAG Sending reaction [$emoji] to message with ID [$id]")
val reaction = chatMessage.createReaction(emoji)
reaction.send()
if (chatMessage.ownReaction?.body == emoji) {
Log.i("$TAG Removing our existing reaction [$emoji] to message with ID [$id]")
val reaction = chatMessage.createReaction("")
reaction.send()
} else {
Log.i("$TAG Sending reaction [$emoji] to message with ID [$id]")
val reaction = chatMessage.createReaction(emoji)
reaction.send()
}
dismissLongPressMenuEvent.postValue(Event(true))
}
}