Remove ActiveSpaceFilter.None

Prefer nullability for API coherency of `RoomSummaryQueryParams`
This commit is contained in:
Benoit Marty 2022-05-24 16:15:09 +02:00 committed by Benoit Marty
parent 289f27b738
commit 00809027c1
6 changed files with 8 additions and 9 deletions

View file

@ -21,7 +21,6 @@ package org.matrix.android.sdk.api.query
* @see [org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams] * @see [org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams]
*/ */
sealed class ActiveSpaceFilter { sealed class ActiveSpaceFilter {
object None : ActiveSpaceFilter()
data class ActiveSpace(val currentSpaceId: String?) : ActiveSpaceFilter() data class ActiveSpace(val currentSpaceId: String?) : ActiveSpaceFilter()
data class ExcludeSpace(val spaceId: String) : ActiveSpaceFilter() data class ExcludeSpace(val spaceId: String) : ActiveSpaceFilter()
} }

View file

@ -101,7 +101,7 @@ data class RoomSummaryQueryParams(
var roomTagQueryFilter: RoomTagQueryFilter? = null var roomTagQueryFilter: RoomTagQueryFilter? = null
var excludeType: List<String?>? = listOf(RoomType.SPACE) var excludeType: List<String?>? = listOf(RoomType.SPACE)
var includeType: List<String?>? = null var includeType: List<String?>? = null
var activeSpaceFilter: ActiveSpaceFilter = ActiveSpaceFilter.None var activeSpaceFilter: ActiveSpaceFilter? = null
var activeGroupId: String? = null var activeGroupId: String? = null
fun build() = RoomSummaryQueryParams( fun build() = RoomSummaryQueryParams(

View file

@ -241,7 +241,7 @@ class HomeDetailViewModel @AssistedInject constructor(
roomSummaryQueryParams { roomSummaryQueryParams {
memberships = listOf(Membership.INVITE) memberships = listOf(Membership.INVITE)
roomCategoryFilter = RoomCategoryFilter.ONLY_DM roomCategoryFilter = RoomCategoryFilter.ONLY_DM
activeSpaceFilter = activeSpaceRoomId?.let { ActiveSpaceFilter.ActiveSpace(it) } ?: ActiveSpaceFilter.None activeSpaceFilter = activeSpaceRoomId?.let { ActiveSpaceFilter.ActiveSpace(it) }
} }
).size ).size
@ -258,7 +258,7 @@ class HomeDetailViewModel @AssistedInject constructor(
roomSummaryQueryParams { roomSummaryQueryParams {
memberships = listOf(Membership.JOIN) memberships = listOf(Membership.JOIN)
roomCategoryFilter = RoomCategoryFilter.ONLY_DM roomCategoryFilter = RoomCategoryFilter.ONLY_DM
activeSpaceFilter = activeSpaceRoomId?.let { ActiveSpaceFilter.ActiveSpace(it) } ?: ActiveSpaceFilter.None activeSpaceFilter = activeSpaceRoomId?.let { ActiveSpaceFilter.ActiveSpace(it) }
} }
) )

View file

@ -153,7 +153,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
this.memberships = listOf(Membership.JOIN) this.memberships = listOf(Membership.JOIN)
this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf { this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf {
!vectorPreferences.prefSpacesShowAllRoomInHome() !vectorPreferences.prefSpacesShowAllRoomInHome()
} ?: ActiveSpaceFilter.None }
} }
) )

View file

@ -385,7 +385,7 @@ class RoomListSectionBuilderSpace(
) )
} else { } else {
filteredPagedRoomSummariesLive.queryParams = roomQueryParams.copy( filteredPagedRoomSummariesLive.queryParams = roomQueryParams.copy(
activeSpaceFilter = ActiveSpaceFilter.None activeSpaceFilter = null
) )
} }
liveQueryParams.update { filteredPagedRoomSummariesLive.queryParams } liveQueryParams.update { filteredPagedRoomSummariesLive.queryParams }
@ -442,7 +442,7 @@ class RoomListSectionBuilderSpace(
RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL -> { RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL -> {
if (currentSpace == null) { if (currentSpace == null) {
copy( copy(
activeSpaceFilter = ActiveSpaceFilter.None activeSpaceFilter = null
) )
} else { } else {
copy( copy(

View file

@ -112,7 +112,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa
this.memberships = listOf(Membership.JOIN) this.memberships = listOf(Membership.JOIN)
this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf { this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf {
!vectorPreferences.prefSpacesShowAllRoomInHome() !vectorPreferences.prefSpacesShowAllRoomInHome()
} ?: ActiveSpaceFilter.None }
}, sortOrder = RoomSortOrder.NONE }, sortOrder = RoomSortOrder.NONE
).asFlow() ).asFlow()
.sample(300) .sample(300)
@ -129,7 +129,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa
this.memberships = listOf(Membership.JOIN) this.memberships = listOf(Membership.JOIN)
this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf { this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf {
!vectorPreferences.prefSpacesShowAllRoomInHome() !vectorPreferences.prefSpacesShowAllRoomInHome()
} ?: ActiveSpaceFilter.None }
} }
) )
val counts = RoomAggregateNotificationCount( val counts = RoomAggregateNotificationCount(