Another improvement for chat message reaction notification: remove previous notification when user changes it's reaction

This commit is contained in:
Sylvain Berfini 2023-09-15 09:55:03 +02:00
parent 7deef26f80
commit 318ab35eab

View file

@ -303,9 +303,14 @@ class NotificationsManager(private val context: Context) {
}
}
val notifiable = createChatReactionNotifiable(chatRoom, reaction.body, address, message)
if (notifiable.messages.isNotEmpty()) {
displayChatNotifiable(chatRoom, notifiable)
val newNotifiable = createChatReactionNotifiable(
chatRoom,
reaction.body,
address,
message
)
if (newNotifiable.messages.isNotEmpty()) {
displayChatNotifiable(chatRoom, newNotifiable)
} else {
Log.e(
"[Notifications Manager] Notifiable is empty but we should have displayed the reaction!"
@ -949,6 +954,18 @@ class NotificationsManager(private val context: Context) {
): Notifiable {
val notifiable = getNotifiableForRoom(room)
// Check for previous reaction notifiable from the same person for the same message
val fromAddr = from.asStringUriOnly()
val found = notifiable.messages.find {
it.isReaction && it.reactionToMessageId == message.messageId && it.reactionFrom == fromAddr
}
if (found != null) {
Log.i(
"[Notifications Manager] Found a previous notifiable for a reaction from the same person to the same message, removing it"
)
notifiable.messages.remove(found)
}
val friend = coreContext.contactsManager.findContactByAddress(from)
val roundPicture = ImageUtils.getRoundBitmapFromUri(context, friend?.getThumbnailUri())
val displayName = friend?.name ?: LinphoneUtils.getDisplayName(from)