Fix a case where a space could show one unread, but all chats are read

Change-Id: I8a0cd85ebd994c22914d3e9a3708ce835c5c7a11
This commit is contained in:
SpiritCroc 2021-11-09 10:48:07 +01:00
parent bd6814325b
commit 30fec15c20
2 changed files with 11 additions and 10 deletions

View File

@ -75,14 +75,13 @@ data class RoomSummary(
val flattenParentIds: List<String> = emptyList()
) {
// Keep in sync with RoomSummaryEntity.kt!
val safeUnreadCount: Int
get() {
return if (unreadCount != null && unreadCount > 0) {
unreadCount
} else if (hasUnreadOriginalContentMessages) {
1
} else {
0
return when {
unreadCount != null && unreadCount > 0 -> unreadCount
hasUnreadOriginalContentMessages && roomType != RoomType.SPACE -> 1
else -> 0
}
}

View File

@ -26,6 +26,7 @@ import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.model.RoomJoinRules
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.session.room.model.RoomType
import org.matrix.android.sdk.api.session.room.model.VersioningState
import org.matrix.android.sdk.api.session.room.model.tag.RoomTag
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
@ -125,12 +126,13 @@ internal open class RoomSummaryEntity(
}
*/
// Keep in sync with RoomSummary.kt!
fun safeUnreadCount(): Int {
val safeUnreadCount = unreadCount
return if (safeUnreadCount == null || safeUnreadCount <= 0) {
if (hasUnreadOriginalContentMessages) 1 else 0
} else {
safeUnreadCount
return when {
safeUnreadCount != null && safeUnreadCount > 0 -> safeUnreadCount
hasUnreadOriginalContentMessages && roomType != RoomType.SPACE -> 1
else -> 0
}
}