forked from github/wulkanowy-mirror
Fix unread status in sent messages (#2048)
This commit is contained in:
parent
4d49e956b8
commit
db4f172fb8
@ -186,7 +186,7 @@ ext {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "io.github.wulkanowy:sdk:2840d9d6d0"
|
||||
implementation "io.github.wulkanowy:sdk:701016eda2"
|
||||
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8'
|
||||
|
||||
|
2421
app/schemas/io.github.wulkanowy.data.db.AppDatabase/52.json
Normal file
2421
app/schemas/io.github.wulkanowy.data.db.AppDatabase/52.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -47,6 +47,7 @@ import javax.inject.Singleton
|
||||
AutoMigration(from = 44, to = 45),
|
||||
AutoMigration(from = 46, to = 47),
|
||||
AutoMigration(from = 47, to = 48),
|
||||
AutoMigration(from = 51, to = 52),
|
||||
],
|
||||
version = AppDatabase.VERSION_SCHEMA,
|
||||
exportSchema = true
|
||||
@ -55,7 +56,7 @@ import javax.inject.Singleton
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
companion object {
|
||||
const val VERSION_SCHEMA = 51
|
||||
const val VERSION_SCHEMA = 52
|
||||
|
||||
fun getMigrations(sharedPrefProvider: SharedPrefProvider, appInfo: AppInfo) = arrayOf(
|
||||
Migration2(),
|
||||
|
@ -29,6 +29,12 @@ data class Message(
|
||||
|
||||
var unread: Boolean,
|
||||
|
||||
@ColumnInfo(name = "read_by")
|
||||
val readBy: Int?,
|
||||
|
||||
@ColumnInfo(name = "unread_by")
|
||||
val unreadBy: Int?,
|
||||
|
||||
@ColumnInfo(name = "has_attachments")
|
||||
val hasAttachments: Boolean
|
||||
) : Serializable {
|
||||
|
@ -16,7 +16,9 @@ fun List<SdkMessage>.mapToEntities(mailbox: Mailbox) = map {
|
||||
date = it.dateZoned.toInstant(),
|
||||
folderId = it.folderId,
|
||||
unread = it.unread,
|
||||
hasAttachments = it.hasAttachments
|
||||
unreadBy = it.unreadBy,
|
||||
readBy = it.readBy,
|
||||
hasAttachments = it.hasAttachments,
|
||||
).apply {
|
||||
content = it.content.orEmpty()
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ private fun generateMessage(sender: String, subject: String) = Message(
|
||||
date = Instant.now(),
|
||||
folderId = 0,
|
||||
unread = true,
|
||||
readBy = 2,
|
||||
unreadBy = 2,
|
||||
hasAttachments = false,
|
||||
messageGlobalKey = "",
|
||||
correspondents = sender,
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.github.wulkanowy.ui.modules.message.preview
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -74,15 +73,20 @@ class MessagePreviewAdapter @Inject constructor() :
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun bindMessage(holder: MessageViewHolder, message: Message) {
|
||||
val context = holder.binding.root.context
|
||||
val recipientCount = (message.unreadBy ?: 0) + (message.readBy ?: 0)
|
||||
val isReceived = message.unreadBy == null
|
||||
|
||||
val readTextValue = when {
|
||||
!message.unread -> R.string.all_yes
|
||||
else -> R.string.all_no
|
||||
val readText = when {
|
||||
recipientCount > 1 -> {
|
||||
context.getString(R.string.message_read_by, message.readBy, recipientCount)
|
||||
}
|
||||
message.readBy == 1 || (isReceived && !message.unread) -> {
|
||||
context.getString(R.string.message_read, context.getString(R.string.all_yes))
|
||||
}
|
||||
else -> context.getString(R.string.message_read, context.getString(R.string.all_no))
|
||||
}
|
||||
val readText = context.getString(R.string.message_read, context.getString(readTextValue))
|
||||
|
||||
with(holder.binding) {
|
||||
messagePreviewSubject.text = message.subject.ifBlank {
|
||||
|
@ -304,6 +304,7 @@
|
||||
<string name="message_chip_only_unread">Only unread</string>
|
||||
<string name="message_chip_only_with_attachments">Only with attachments</string>
|
||||
<string name="message_read">Read: %s</string>
|
||||
<string name="message_read_by">Read by: %1$d of %2$d people</string>
|
||||
<plurals name="message_number_item">
|
||||
<item quantity="one">%1$d message</item>
|
||||
<item quantity="other">%1$d messages</item>
|
||||
|
@ -193,7 +193,9 @@ class MessageRepositoryTest {
|
||||
date = Instant.EPOCH,
|
||||
folderId = 1,
|
||||
unread = unread,
|
||||
hasAttachments = false
|
||||
readBy = 1,
|
||||
unreadBy = 1,
|
||||
hasAttachments = false,
|
||||
).apply {
|
||||
this.content = content
|
||||
}
|
||||
@ -209,6 +211,8 @@ class MessageRepositoryTest {
|
||||
dateZoned = Instant.EPOCH.atZone(ZoneOffset.UTC),
|
||||
folderId = 1,
|
||||
unread = true,
|
||||
readBy = 1,
|
||||
unreadBy = 1,
|
||||
hasAttachments = false,
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user