Remove chat message notification when deleting chat room

This commit is contained in:
Sylvain Berfini 2020-07-20 17:18:35 +02:00
parent e594c500f6
commit f42b1c6a96
2 changed files with 11 additions and 0 deletions

View file

@ -118,6 +118,7 @@ class ChatRoomsListViewModel : ErrorReportingViewModel() {
chatRoomsToDeleteCount = 1 chatRoomsToDeleteCount = 1
if (chatRoom != null) { if (chatRoom != null) {
coreContext.notificationsManager.dismissChatNotification(chatRoom)
Compatibility.removeChatRoomShortcut(chatRoom) Compatibility.removeChatRoomShortcut(chatRoom)
chatRoom.addListener(chatRoomListener) chatRoom.addListener(chatRoomListener)
coreContext.core.deleteChatRoom(chatRoom) coreContext.core.deleteChatRoom(chatRoom)
@ -131,6 +132,7 @@ class ChatRoomsListViewModel : ErrorReportingViewModel() {
LinphoneUtils.deleteFilesAttachedToEventLog(eventLog) LinphoneUtils.deleteFilesAttachedToEventLog(eventLog)
} }
coreContext.notificationsManager.dismissChatNotification(chatRoom)
Compatibility.removeChatRoomShortcut(chatRoom) Compatibility.removeChatRoomShortcut(chatRoom)
chatRoom.addListener(chatRoomListener) chatRoom.addListener(chatRoomListener)
chatRoom.core.deleteChatRoom(chatRoom) chatRoom.core.deleteChatRoom(chatRoom)

View file

@ -602,6 +602,15 @@ class NotificationsManager(private val context: Context) {
displayChatNotifiable(message.chatRoom, notifiable) displayChatNotifiable(message.chatRoom, notifiable)
} }
fun dismissChatNotification(room: ChatRoom) {
val address = room.peerAddress.asStringUriOnly()
val notifiable: Notifiable? = chatNotificationsMap[address]
if (notifiable != null) {
Log.i("[Notifications Manager] Dismissing notification for chat room $room with id ${notifiable.notificationId}")
cancel(notifiable.notificationId)
}
}
/* Notifications */ /* Notifications */
private fun createMessageNotification( private fun createMessageNotification(