Adding knowledge of pending space invites

This commit is contained in:
Maxime NATUREL 2023-02-21 17:57:23 +01:00
parent 0e8a2254f8
commit c36869cd03
2 changed files with 17 additions and 6 deletions

View File

@ -185,7 +185,7 @@ class NewHomeDetailFragment :
}
newHomeDetailViewModel.onEach { viewState ->
refreshUnreadCounterBadge(viewState.spacesNotificationCount)
refreshUnreadCounterBadge(viewState.spacesNotificationCount, viewState.hasPendingSpaceInvites)
}
}
@ -386,11 +386,21 @@ class NewHomeDetailFragment :
}
}
private fun refreshUnreadCounterBadge(roomAggregateNotificationCount: RoomAggregateNotificationCount) {
val badgeState = UnreadCounterBadgeView.State.Count(
count = roomAggregateNotificationCount.notificationCount,
highlighted = roomAggregateNotificationCount.isHighlight,
)
private fun refreshUnreadCounterBadge(
spacesNotificationCount: RoomAggregateNotificationCount,
hasPendingSpaceInvites: Boolean,
) {
val badgeState = if (hasPendingSpaceInvites && spacesNotificationCount.notificationCount == 0) {
UnreadCounterBadgeView.State.Text(
text = "!",
highlighted = true,
)
} else {
UnreadCounterBadgeView.State.Count(
count = spacesNotificationCount.notificationCount,
highlighted = spacesNotificationCount.isHighlight,
)
}
views.spacesUnreadCounterBadge.render(badgeState)
}

View File

@ -21,4 +21,5 @@ import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotification
data class NewHomeDetailViewState(
val spacesNotificationCount: RoomAggregateNotificationCount = RoomAggregateNotificationCount(notificationCount = 0, highlightCount = 0),
val hasPendingSpaceInvites: Boolean = false,
) : MavericksState