From 077e1b6896267edf8530b86fd2ca11e79724d048 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Wed, 12 May 2021 16:16:20 +0200 Subject: [PATCH] Fix compile after merge Change-Id: I499115f40f75f07cdd0e42dafa2b17695d27e9b5 --- .../home/UnreadMessagesSharedViewModel.kt | 4 +- .../room/list/SpaceRoomListSectionBuilder.kt | 60 ++++++++++++------- .../features/spaces/SpaceSummaryController.kt | 4 +- .../features/spaces/SpacesListViewModel.kt | 4 +- .../features/spaces/SubSpaceSummaryItem.kt | 2 +- 5 files changed, 47 insertions(+), 27 deletions(-) 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 dc90efef6a..ba7f319f77 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 @@ -150,7 +150,9 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia val counts = RoomAggregateNotificationCount( totalCount.notificationCount + inviteCount, - totalCount.highlightCount + inviteCount + totalCount.highlightCount + inviteCount, + totalCount.unreadCount, + totalCount.markedUnreadCount ) val rootCounts = session.spaceService().getRootSpaceSummaries() .filter { diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/SpaceRoomListSectionBuilder.kt b/vector/src/main/java/im/vector/app/features/home/room/list/SpaceRoomListSectionBuilder.kt index 30cb130577..3bda21abf8 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/SpaceRoomListSectionBuilder.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/SpaceRoomListSectionBuilder.kt @@ -142,10 +142,12 @@ class SpaceRoomListSectionBuilder( private fun buildUnifiedSections(sections: MutableList, activeSpaceAwareQueries: MutableList) { addSection( - sections, activeSpaceAwareQueries, - R.string.invitations_header, - true, - RoomListViewModel.SpaceFilterStrategy.NONE + sections = sections, + activeSpaceUpdaters = activeSpaceAwareQueries, + nameRes = R.string.invitations_header, + notifyOfLocalEcho = true, + spaceFilterStrategy = RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL, + countRoomAsNotif = true ) { it.memberships = listOf(Membership.INVITE) } @@ -155,40 +157,52 @@ class SpaceRoomListSectionBuilder( activeSpaceAwareQueries, R.string.bottom_action_favourites, false, - RoomListViewModel.SpaceFilterStrategy.NOT_IF_ALL + RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL ) { it.memberships = listOf(Membership.JOIN) it.roomTagQueryFilter = RoomTagQueryFilter(true, null, null) } addSection( - sections, - activeSpaceAwareQueries, - R.string.normal_priority_header, - false, - RoomListViewModel.SpaceFilterStrategy.NORMAL + sections = sections, + activeSpaceUpdaters = activeSpaceAwareQueries, + nameRes = R.string.bottom_action_rooms, + notifyOfLocalEcho = false, + spaceFilterStrategy = if (onlyOrphansInHome) { + RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL + } else { + RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL + } ) { it.memberships = listOf(Membership.JOIN) it.roomTagQueryFilter = RoomTagQueryFilter(false, false, false) } addSection( - sections, - activeSpaceAwareQueries, - R.string.low_priority_header, - false, - RoomListViewModel.SpaceFilterStrategy.NORMAL + sections = sections, + activeSpaceUpdaters = activeSpaceAwareQueries, + nameRes = R.string.low_priority_header, + notifyOfLocalEcho = false, + spaceFilterStrategy = if (onlyOrphansInHome) { + RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL + } else { + RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL + } ) { it.memberships = listOf(Membership.JOIN) it.roomTagQueryFilter = RoomTagQueryFilter(null, true, null) } addSection( - sections, - activeSpaceAwareQueries, - R.string.system_alerts_header, - false, - RoomListViewModel.SpaceFilterStrategy.NORMAL + sections = sections, + activeSpaceUpdaters = activeSpaceAwareQueries, + nameRes = R.string.system_alerts_header, + notifyOfLocalEcho = false, + spaceFilterStrategy = if (onlyOrphansInHome) { + RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL + } else { + RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL + } ) { it.memberships = listOf(Membership.JOIN) it.roomTagQueryFilter = RoomTagQueryFilter(null, null, true) @@ -205,7 +219,7 @@ class SpaceRoomListSectionBuilder( } else { liveData(context = viewModelScope.coroutineContext + Dispatchers.IO) { val spaceSum = tryOrNull { session.spaceService().querySpaceChildren(selectedSpace.roomId, suggestedOnly = true) } - val value = spaceSum?.second ?: emptyList() + val value = spaceSum?.second.orEmpty().distinctBy { it.childRoomId } // i need to check if it's already joined. val filtered = value.filter { session.getRoomSummary(it.childRoomId)?.membership?.isActive() != true @@ -393,7 +407,7 @@ class SpaceRoomListSectionBuilder( activeSpaceAwareQueries, R.string.low_priority_header, false, - RoomListViewModel.SpaceFilterStrategy.NOT_IF_ALL + RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL ) { it.memberships = listOf(Membership.JOIN) it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM @@ -464,7 +478,7 @@ class SpaceRoomListSectionBuilder( ?.notificationCount ?.postValue( if (countRoomAsNotif) { - RoomAggregateNotificationCount(it.size, it.size) + RoomAggregateNotificationCount(it.size, it.size, 0, 0) } else { session.getNotificationCountForRooms( roomQueryParams.process(spaceFilterStrategy, appStateHandler.safeActiveSpaceId()), diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceSummaryController.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceSummaryController.kt index aa815ea24c..cb2381f8d2 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceSummaryController.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceSummaryController.kt @@ -209,7 +209,9 @@ class SpaceSummaryController @Inject constructor( countState( UnreadCounterBadgeView.State( childSummary.notificationCount, - childSummary.highlightCount > 0 + childSummary.highlightCount > 0, + childSummary.unreadCount ?: 0, + childSummary.markedUnread ) ) } diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpacesListViewModel.kt b/vector/src/main/java/im/vector/app/features/spaces/SpacesListViewModel.kt index 27611e2ebf..d96b6f7d81 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpacesListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpacesListViewModel.kt @@ -136,7 +136,9 @@ class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: Sp ) val counts = RoomAggregateNotificationCount( totalCount.notificationCount + inviteCount, - totalCount.highlightCount + inviteCount + totalCount.highlightCount + inviteCount, + totalCount.unreadCount, + if (totalCount.markedUnread) 1 else 0 ) setState { copy( diff --git a/vector/src/main/java/im/vector/app/features/spaces/SubSpaceSummaryItem.kt b/vector/src/main/java/im/vector/app/features/spaces/SubSpaceSummaryItem.kt index db58353e5c..bd6bee068d 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SubSpaceSummaryItem.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SubSpaceSummaryItem.kt @@ -45,7 +45,7 @@ abstract class SubSpaceSummaryItem : VectorEpoxyModel