From 83974b6550877195d48bbe22bc5b9b263767de2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Sun, 1 Jan 2023 20:21:28 +0100 Subject: [PATCH] Fix NPE when trying to remove a message from mailbox that doesn't match any student (#2090) --- .../io/github/wulkanowy/data/repositories/MessageRepository.kt | 2 +- .../ui/modules/message/preview/MessagePreviewPresenter.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/MessageRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/MessageRepository.kt index f95b8dbe..6dfc3ab7 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/MessageRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/MessageRepository.kt @@ -178,7 +178,7 @@ class MessageRepository @Inject constructor( ).first() } - suspend fun deleteMessage(student: Student, mailbox: Mailbox, message: Message) { + suspend fun deleteMessage(student: Student, mailbox: Mailbox?, message: Message) { deleteMessages(student, mailbox, listOf(message)) } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/message/preview/MessagePreviewPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/message/preview/MessagePreviewPresenter.kt index fd75f6f3..56f23b6f 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/message/preview/MessagePreviewPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/message/preview/MessagePreviewPresenter.kt @@ -186,7 +186,7 @@ class MessagePreviewPresenter @Inject constructor( runCatching { val student = studentRepository.getCurrentStudent(decryptPass = true) val mailbox = messageRepository.getMailboxByStudent(student) - messageRepository.deleteMessage(student, mailbox!!, message!!) + messageRepository.deleteMessage(student, mailbox, message!!) } .onFailure { retryCallback = { onMessageDelete() }