-
Notifications
You must be signed in to change notification settings - Fork 758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Home
always showing all rooms
#6666
Changes from all commits
1ba8d29
e847688
2d8ef99
09d8405
8ef0850
e4640f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixes the room list not taking into account the Show all rooms in Home preference |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SDK - The SpaceFilter is query parameter is no longer nullable, use SpaceFilter.NoFilter instead |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ import im.vector.app.core.di.MavericksAssistedViewModelFactory | |
import im.vector.app.core.di.hiltMavericksViewModelFactory | ||
import im.vector.app.core.platform.StateView | ||
import im.vector.app.core.platform.VectorViewModel | ||
import im.vector.app.features.home.room.list.RoomListViewModel | ||
import im.vector.app.features.settings.VectorPreferences | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
|
@@ -39,6 +38,7 @@ import kotlinx.coroutines.flow.onStart | |
import kotlinx.coroutines.launch | ||
import org.matrix.android.sdk.api.extensions.orFalse | ||
import org.matrix.android.sdk.api.query.SpaceFilter | ||
import org.matrix.android.sdk.api.query.toActiveSpaceOrNoFilter | ||
import org.matrix.android.sdk.api.query.toActiveSpaceOrOrphanRooms | ||
import org.matrix.android.sdk.api.session.Session | ||
import org.matrix.android.sdk.api.session.getRoom | ||
|
@@ -106,13 +106,8 @@ class HomeRoomListViewModel @AssistedInject constructor( | |
} | ||
.onEach { selectedSpaceOption -> | ||
val selectedSpace = selectedSpaceOption.orNull() | ||
val strategy = if (!vectorPreferences.prefSpacesShowAllRoomInHome()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @fedrunov this condition looked inverted and has been updated to match the usages in other screens when {
vectorPreferences.prefSpacesShowAllRoomInHome() -> selectedSpaceId.toActiveSpaceOrNoFilter()
else -> selectedSpaceId.toActiveSpaceOrOrphanRooms()
} |
||
RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL | ||
} else { | ||
RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL | ||
} | ||
filteredPagedRoomSummariesLive.queryParams = filteredPagedRoomSummariesLive.queryParams.copy( | ||
spaceFilter = getSpaceFilter(selectedSpaceId = selectedSpace?.roomId, strategy) | ||
spaceFilter = getSpaceFilter(selectedSpaceId = selectedSpace?.roomId) | ||
) | ||
}.launchIn(viewModelScope) | ||
|
||
|
@@ -121,15 +116,10 @@ class HomeRoomListViewModel @AssistedInject constructor( | |
) | ||
} | ||
|
||
private fun getSpaceFilter(selectedSpaceId: String?, strategy: RoomListViewModel.SpaceFilterStrategy): SpaceFilter? { | ||
return when (strategy) { | ||
RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL -> { | ||
selectedSpaceId?.toActiveSpaceOrOrphanRooms() | ||
} | ||
RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL -> { | ||
selectedSpaceId?.let { SpaceFilter.ActiveSpace(it) } | ||
} | ||
RoomListViewModel.SpaceFilterStrategy.NONE -> null | ||
private fun getSpaceFilter(selectedSpaceId: String?): SpaceFilter { | ||
return when { | ||
vectorPreferences.prefSpacesShowAllRoomInHome() -> selectedSpaceId.toActiveSpaceOrNoFilter() | ||
else -> selectedSpaceId.toActiveSpaceOrOrphanRooms() | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,9 +98,7 @@ class SpaceListViewModel @AssistedInject constructor( | |
session.roomService().getPagedRoomSummariesLive( | ||
roomSummaryQueryParams { | ||
this.memberships = listOf(Membership.JOIN) | ||
this.spaceFilter = SpaceFilter.OrphanRooms.takeIf { | ||
!vectorPreferences.prefSpacesShowAllRoomInHome() | ||
} | ||
this.spaceFilter = roomsInSpaceFilter() | ||
}, sortOrder = RoomSortOrder.NONE | ||
).asFlow() | ||
.sample(300) | ||
|
@@ -115,9 +113,7 @@ class SpaceListViewModel @AssistedInject constructor( | |
val totalCount = session.roomService().getNotificationCountForRooms( | ||
roomSummaryQueryParams { | ||
this.memberships = listOf(Membership.JOIN) | ||
this.spaceFilter = SpaceFilter.OrphanRooms.takeIf { | ||
!vectorPreferences.prefSpacesShowAllRoomInHome() | ||
} | ||
this.spaceFilter = roomsInSpaceFilter() | ||
} | ||
) | ||
val counts = RoomAggregateNotificationCount( | ||
|
@@ -134,6 +130,11 @@ class SpaceListViewModel @AssistedInject constructor( | |
.launchIn(viewModelScope) | ||
} | ||
|
||
private fun roomsInSpaceFilter() = when { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not change it now, but the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, OK, it's to update the notification count. Please ignore me! |
||
vectorPreferences.prefSpacesShowAllRoomInHome() -> SpaceFilter.NoFilter | ||
else -> SpaceFilter.OrphanRooms | ||
} | ||
|
||
override fun handle(action: SpaceListAction) { | ||
when (action) { | ||
is SpaceListAction.SelectSpace -> handleSelectSpace(action) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe mention this API change in a file
6666.sdk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e4640f1