From 00809027c14661b53ec6d0ef384c3d35934e7c48 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 24 May 2022 16:15:09 +0200 Subject: [PATCH] Remove `ActiveSpaceFilter.None` Prefer nullability for API coherency of `RoomSummaryQueryParams` --- .../org/matrix/android/sdk/api/query/ActiveSpaceFilter.kt | 1 - .../android/sdk/api/session/room/RoomSummaryQueryParams.kt | 2 +- .../java/im/vector/app/features/home/HomeDetailViewModel.kt | 4 ++-- .../vector/app/features/home/UnreadMessagesSharedViewModel.kt | 2 +- .../features/home/room/list/RoomListSectionBuilderSpace.kt | 4 ++-- .../java/im/vector/app/features/spaces/SpaceListViewModel.kt | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/ActiveSpaceFilter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/ActiveSpaceFilter.kt index 145c7f8bf4..e6fe72ca74 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/ActiveSpaceFilter.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/ActiveSpaceFilter.kt @@ -21,7 +21,6 @@ package org.matrix.android.sdk.api.query * @see [org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams] */ sealed class ActiveSpaceFilter { - object None : ActiveSpaceFilter() data class ActiveSpace(val currentSpaceId: String?) : ActiveSpaceFilter() data class ExcludeSpace(val spaceId: String) : ActiveSpaceFilter() } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomSummaryQueryParams.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomSummaryQueryParams.kt index 743ea65664..842fe723c4 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomSummaryQueryParams.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomSummaryQueryParams.kt @@ -101,7 +101,7 @@ data class RoomSummaryQueryParams( var roomTagQueryFilter: RoomTagQueryFilter? = null var excludeType: List? = listOf(RoomType.SPACE) var includeType: List? = null - var activeSpaceFilter: ActiveSpaceFilter = ActiveSpaceFilter.None + var activeSpaceFilter: ActiveSpaceFilter? = null var activeGroupId: String? = null fun build() = RoomSummaryQueryParams( diff --git a/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt index a4f1566eff..dd4501d330 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt @@ -241,7 +241,7 @@ class HomeDetailViewModel @AssistedInject constructor( roomSummaryQueryParams { memberships = listOf(Membership.INVITE) roomCategoryFilter = RoomCategoryFilter.ONLY_DM - activeSpaceFilter = activeSpaceRoomId?.let { ActiveSpaceFilter.ActiveSpace(it) } ?: ActiveSpaceFilter.None + activeSpaceFilter = activeSpaceRoomId?.let { ActiveSpaceFilter.ActiveSpace(it) } } ).size @@ -258,7 +258,7 @@ class HomeDetailViewModel @AssistedInject constructor( roomSummaryQueryParams { memberships = listOf(Membership.JOIN) roomCategoryFilter = RoomCategoryFilter.ONLY_DM - activeSpaceFilter = activeSpaceRoomId?.let { ActiveSpaceFilter.ActiveSpace(it) } ?: ActiveSpaceFilter.None + activeSpaceFilter = activeSpaceRoomId?.let { ActiveSpaceFilter.ActiveSpace(it) } } ) 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 c1b3937fee..7874731e3f 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 @@ -153,7 +153,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia this.memberships = listOf(Membership.JOIN) this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf { !vectorPreferences.prefSpacesShowAllRoomInHome() - } ?: ActiveSpaceFilter.None + } } ) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderSpace.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderSpace.kt index 31dc112398..0ce6db0077 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderSpace.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderSpace.kt @@ -385,7 +385,7 @@ class RoomListSectionBuilderSpace( ) } else { filteredPagedRoomSummariesLive.queryParams = roomQueryParams.copy( - activeSpaceFilter = ActiveSpaceFilter.None + activeSpaceFilter = null ) } liveQueryParams.update { filteredPagedRoomSummariesLive.queryParams } @@ -442,7 +442,7 @@ class RoomListSectionBuilderSpace( RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL -> { if (currentSpace == null) { copy( - activeSpaceFilter = ActiveSpaceFilter.None + activeSpaceFilter = null ) } else { copy( diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt index 52b6cc0749..55fdd4a481 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt @@ -112,7 +112,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa this.memberships = listOf(Membership.JOIN) this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf { !vectorPreferences.prefSpacesShowAllRoomInHome() - } ?: ActiveSpaceFilter.None + } }, sortOrder = RoomSortOrder.NONE ).asFlow() .sample(300) @@ -129,7 +129,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa this.memberships = listOf(Membership.JOIN) this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf { !vectorPreferences.prefSpacesShowAllRoomInHome() - } ?: ActiveSpaceFilter.None + } } ) val counts = RoomAggregateNotificationCount(