From 558db061f594b709e10a9766ae3cdfccbf8dbed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Wed, 31 Aug 2022 18:31:12 +0200 Subject: [PATCH] Fix marking message as read (#1960) * Fix marking message as read * Update sdk * Update sdk * Fix tests * Use many recipients strings instead of first recipient --- app/build.gradle | 2 +- .../wulkanowy/data/repositories/MessageRepository.kt | 9 ++++++--- .../wulkanowy/data/repositories/MessageRepositoryTest.kt | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 759199ca..ab8add50 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -186,7 +186,7 @@ ext { } dependencies { - implementation "io.github.wulkanowy:sdk:1.7.2" + implementation "com.github.wulkanowy:sdk:006a238bda" coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8' 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 5a43da4e..e7428762 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 @@ -64,7 +64,10 @@ class MessageRepository @Inject constructor( }, query = { messagesDb.loadAll(mailbox.globalKey, folder.id) }, fetch = { - sdk.init(student).getMessages(Folder.valueOf(folder.name)).mapToEntities(mailbox) + sdk.init(student).getMessages( + folder = Folder.valueOf(folder.name), + mailboxKey = mailbox.globalKey, + ).mapToEntities(mailbox) }, saveFetchResult = { old, new -> messagesDb.deleteAll(old uniqueSubtract new) @@ -89,7 +92,7 @@ class MessageRepository @Inject constructor( }, query = { messagesDb.loadMessageWithAttachment(message.messageGlobalKey) }, fetch = { - sdk.init(student).getMessageDetails(it!!.message.messageGlobalKey) + sdk.init(student).getMessageDetails(it!!.message.messageGlobalKey, markAsRead) }, saveFetchResult = { old, new -> checkNotNull(old) { "Fetched message no longer exist!" } @@ -98,7 +101,7 @@ class MessageRepository @Inject constructor( id = message.id unread = !markAsRead sender = new.sender - recipients = new.recipients.firstOrNull() ?: "Wielu adresoatów" + recipients = new.recipients.singleOrNull() ?: "Wielu adresatów" content = content.ifBlank { new.content } }) ) diff --git a/app/src/test/java/io/github/wulkanowy/data/repositories/MessageRepositoryTest.kt b/app/src/test/java/io/github/wulkanowy/data/repositories/MessageRepositoryTest.kt index 24306bfe..4efc9c60 100644 --- a/app/src/test/java/io/github/wulkanowy/data/repositories/MessageRepositoryTest.kt +++ b/app/src/test/java/io/github/wulkanowy/data/repositories/MessageRepositoryTest.kt @@ -141,7 +141,7 @@ class MessageRepositoryTest { messageDb.loadMessageWithAttachment("v4") } returnsMany listOf(flowOf(mWa), flowOf(mWaWithContent)) coEvery { - sdk.getMessageDetails("v4") + sdk.getMessageDetails("v4", any()) } returns mockk { every { sender } returns "" every { recipients } returns listOf("")