mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-15 18:59:12 +03:00
Fix counting unread chats in spaces
Change-Id: Ibd39e18e92b28105d6b4289eb5ecaf7caeca7574
This commit is contained in:
parent
eed534060f
commit
d6b05925a9
4 changed files with 25 additions and 3 deletions
|
@ -70,6 +70,17 @@ data class RoomSummary(
|
|||
val flattenParentIds: List<String> = emptyList()
|
||||
) {
|
||||
|
||||
val safeUnreadCount: Int
|
||||
get() {
|
||||
return if (unreadCount != null && unreadCount > 0) {
|
||||
unreadCount
|
||||
} else if (hasUnreadOriginalContentMessages) {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
val isVersioned: Boolean
|
||||
get() = versioningState != VersioningState.NONE
|
||||
|
||||
|
@ -120,6 +131,14 @@ data class RoomSummary(
|
|||
}
|
||||
}
|
||||
|
||||
fun scUnreadCount(preferenceProvider: RoomSummaryPreferenceProvider?): Int {
|
||||
return if (preferenceProvider?.shouldShowUnimportantCounterBadge() == true) {
|
||||
safeUnreadCount
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fun scNotificationCountWithManualUnread(): Int {
|
||||
return when {
|
||||
notificationCount > 0 -> {
|
||||
|
|
|
@ -61,6 +61,7 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa
|
|||
otherMemberIds = roomSummaryEntity.otherMemberIds.toList(),
|
||||
highlightCount = roomSummaryEntity.highlightCount,
|
||||
notificationCount = roomSummaryEntity.notificationCount,
|
||||
unreadCount = roomSummaryEntity.unreadCount,
|
||||
hasUnreadMessages = roomSummaryEntity.hasUnreadMessages,
|
||||
hasUnreadContentMessages = roomSummaryEntity.hasUnreadContentMessages,
|
||||
hasUnreadOriginalContentMessages = roomSummaryEntity.hasUnreadOriginalContentMessages,
|
||||
|
|
|
@ -386,7 +386,7 @@ internal class RoomSummaryUpdater @Inject constructor(
|
|||
.findAll().forEach {
|
||||
highlightCount += it.highlightCount
|
||||
notificationCount += it.notificationCount
|
||||
unreadCount += if (it.hasUnreadOriginalContentMessages) 1 else 0
|
||||
unreadCount += it.unreadCount
|
||||
markedUnreadCount += if (it.markedUnread) 1 else 0
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import im.vector.app.core.ui.list.genericItemHeader
|
|||
import im.vector.app.features.grouplist.groupSummaryItem
|
||||
import im.vector.app.features.grouplist.homeSpaceSummaryItem
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.ScSdkPreferences
|
||||
import im.vector.app.features.home.room.list.UnreadCounterBadgeView
|
||||
import im.vector.app.group
|
||||
import im.vector.app.space
|
||||
|
@ -39,6 +40,7 @@ import org.matrix.android.sdk.api.util.toMatrixItem
|
|||
import javax.inject.Inject
|
||||
|
||||
class SpaceSummaryController @Inject constructor(
|
||||
private val scSdkPreferences: ScSdkPreferences,
|
||||
private val avatarRenderer: AvatarRenderer,
|
||||
private val colorProvider: ColorProvider,
|
||||
private val stringProvider: StringProvider) : EpoxyController() {
|
||||
|
@ -162,7 +164,7 @@ class SpaceSummaryController @Inject constructor(
|
|||
UnreadCounterBadgeView.State(
|
||||
groupSummary.notificationCount,
|
||||
groupSummary.highlightCount > 0,
|
||||
groupSummary.unreadCount ?: 0,
|
||||
groupSummary.scUnreadCount(scSdkPreferences),
|
||||
groupSummary.markedUnread
|
||||
)
|
||||
)
|
||||
|
@ -210,7 +212,7 @@ class SpaceSummaryController @Inject constructor(
|
|||
UnreadCounterBadgeView.State(
|
||||
childSummary.notificationCount,
|
||||
childSummary.highlightCount > 0,
|
||||
childSummary.unreadCount ?: 0,
|
||||
childSummary.scUnreadCount(scSdkPreferences),
|
||||
childSummary.markedUnread
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue