From c36869cd03c14d00dfc8c025ee63606193545c33 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL <46314705+mnaturel@users.noreply.github.com> Date: Tue, 21 Feb 2023 17:57:23 +0100 Subject: [PATCH] Adding knowledge of pending space invites --- .../features/home/NewHomeDetailFragment.kt | 22 ++++++++++++++----- .../features/home/NewHomeDetailViewState.kt | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt index ff995311e6..51a217c526 100644 --- a/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt @@ -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) } diff --git a/vector/src/main/java/im/vector/app/features/home/NewHomeDetailViewState.kt b/vector/src/main/java/im/vector/app/features/home/NewHomeDetailViewState.kt index 20ad9be4b4..1ff0b86511 100644 --- a/vector/src/main/java/im/vector/app/features/home/NewHomeDetailViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/NewHomeDetailViewState.kt @@ -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