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
This commit is contained in:
Mikołaj Pich 2022-08-31 18:31:12 +02:00 committed by GitHub
parent 190f40ede8
commit 558db061f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -186,7 +186,7 @@ ext {
} }
dependencies { 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' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8'

View File

@ -64,7 +64,10 @@ class MessageRepository @Inject constructor(
}, },
query = { messagesDb.loadAll(mailbox.globalKey, folder.id) }, query = { messagesDb.loadAll(mailbox.globalKey, folder.id) },
fetch = { 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 -> saveFetchResult = { old, new ->
messagesDb.deleteAll(old uniqueSubtract new) messagesDb.deleteAll(old uniqueSubtract new)
@ -89,7 +92,7 @@ class MessageRepository @Inject constructor(
}, },
query = { messagesDb.loadMessageWithAttachment(message.messageGlobalKey) }, query = { messagesDb.loadMessageWithAttachment(message.messageGlobalKey) },
fetch = { fetch = {
sdk.init(student).getMessageDetails(it!!.message.messageGlobalKey) sdk.init(student).getMessageDetails(it!!.message.messageGlobalKey, markAsRead)
}, },
saveFetchResult = { old, new -> saveFetchResult = { old, new ->
checkNotNull(old) { "Fetched message no longer exist!" } checkNotNull(old) { "Fetched message no longer exist!" }
@ -98,7 +101,7 @@ class MessageRepository @Inject constructor(
id = message.id id = message.id
unread = !markAsRead unread = !markAsRead
sender = new.sender sender = new.sender
recipients = new.recipients.firstOrNull() ?: "Wielu adresoatów" recipients = new.recipients.singleOrNull() ?: "Wielu adresatów"
content = content.ifBlank { new.content } content = content.ifBlank { new.content }
}) })
) )

View File

@ -141,7 +141,7 @@ class MessageRepositoryTest {
messageDb.loadMessageWithAttachment("v4") messageDb.loadMessageWithAttachment("v4")
} returnsMany listOf(flowOf(mWa), flowOf(mWaWithContent)) } returnsMany listOf(flowOf(mWa), flowOf(mWaWithContent))
coEvery { coEvery {
sdk.getMessageDetails("v4") sdk.getMessageDetails("v4", any())
} returns mockk { } returns mockk {
every { sender } returns "" every { sender } returns ""
every { recipients } returns listOf("") every { recipients } returns listOf("")