diff --git a/changelog.d/4059.bugfix b/changelog.d/4059.bugfix new file mode 100644 index 0000000000..868359ac89 --- /dev/null +++ b/changelog.d/4059.bugfix @@ -0,0 +1 @@ +Space Invites are not lighting up the drawer menu \ No newline at end of file diff --git a/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt b/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt index f02711690a..cd8670a48d 100644 --- a/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt @@ -38,6 +38,7 @@ import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.room.RoomSortOrder import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams +import org.matrix.android.sdk.api.session.room.spaceSummaryQueryParams import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount import org.matrix.android.sdk.rx.asObservable import java.util.concurrent.TimeUnit @@ -143,6 +144,17 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia roomSummaryQueryParams { this.memberships = listOf(Membership.INVITE) } ).size } + + val spaceInviteCount = if (autoAcceptInvites.hideInvites) { + 0 + } else { + session.getRoomSummaries( + spaceSummaryQueryParams { + this.memberships = listOf(Membership.INVITE) + } + ).size + } + val totalCount = session.getNotificationCountForRooms( roomSummaryQueryParams { this.memberships = listOf(Membership.JOIN) @@ -161,15 +173,18 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia // filter out current selection it.roomId != selectedSpace } + CountInfo( homeCount = counts, otherCount = RoomAggregateNotificationCount( rootCounts.fold(0, { acc, rs -> acc + rs.notificationCount - }) + (counts.notificationCount.takeIf { selectedSpace != null } ?: 0), + }) + (counts.notificationCount.takeIf { selectedSpace != null } ?: 0) + + spaceInviteCount, rootCounts.fold(0, { acc, rs -> acc + rs.highlightCount }) + (counts.highlightCount.takeIf { selectedSpace != null } ?: 0) + + spaceInviteCount ) ) }