fix slow paged room list

This commit is contained in:
Valere 2022-06-03 14:21:03 +02:00 committed by Benoit Marty
parent ba5828711b
commit d67f86a1e0
5 changed files with 20 additions and 10 deletions

View File

@ -217,10 +217,15 @@ interface RoomService {
/** /**
* TODO Doc. * TODO Doc.
* @param getFlattenParents When true, the list of known parent and grand parent summaries will be resolved.
* This can have significant impact on performance, better be used only on manageable list (filtered by displayName, ..).
*/ */
fun getFilteredPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams, fun getFilteredPagedRoomSummariesLive(
pagedListConfig: PagedList.Config = defaultPagedListConfig, queryParams: RoomSummaryQueryParams,
sortOrder: RoomSortOrder = RoomSortOrder.ACTIVITY): UpdatableLivePageResult pagedListConfig: PagedList.Config = defaultPagedListConfig,
sortOrder: RoomSortOrder = RoomSortOrder.ACTIVITY,
getFlattenParents: Boolean = false,
): UpdatableLivePageResult
/** /**
* Return a LiveData on the number of rooms. * Return a LiveData on the number of rooms.

View File

@ -130,10 +130,13 @@ internal class DefaultRoomService @Inject constructor(
return roomSummaryDataSource.getSortedPagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder) return roomSummaryDataSource.getSortedPagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder)
} }
override fun getFilteredPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams, override fun getFilteredPagedRoomSummariesLive(
pagedListConfig: PagedList.Config, queryParams: RoomSummaryQueryParams,
sortOrder: RoomSortOrder): UpdatableLivePageResult { pagedListConfig: PagedList.Config,
return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenedParents = true) sortOrder: RoomSortOrder,
getFlattenedParents: Boolean
): UpdatableLivePageResult {
return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenedParents)
} }
override fun getRoomCountLive(queryParams: RoomSummaryQueryParams): LiveData<Int> { override fun getRoomCountLive(queryParams: RoomSummaryQueryParams): LiveData<Int> {

View File

@ -71,7 +71,7 @@ class RoomListSectionBuilderGroup(
}, },
{ qpm -> { qpm ->
val name = stringProvider.getString(R.string.bottom_action_rooms) val name = stringProvider.getString(R.string.bottom_action_rooms)
val updatableFilterLivePageResult = session.roomService().getFilteredPagedRoomSummariesLive(qpm) val updatableFilterLivePageResult = session.roomService().getFilteredPagedRoomSummariesLive(qpm, getFlattenParents = true)
onUpdatable(updatableFilterLivePageResult) onUpdatable(updatableFilterLivePageResult)
val itemCountFlow = updatableFilterLivePageResult.livePagedList.asFlow() val itemCountFlow = updatableFilterLivePageResult.livePagedList.asFlow()

View File

@ -326,7 +326,7 @@ class RoomListSectionBuilderSpace(
}, },
{ queryParams -> { queryParams ->
val name = stringProvider.getString(R.string.bottom_action_rooms) val name = stringProvider.getString(R.string.bottom_action_rooms)
val updatableFilterLivePageResult = session.roomService().getFilteredPagedRoomSummariesLive(queryParams) val updatableFilterLivePageResult = session.roomService().getFilteredPagedRoomSummariesLive(queryParams, getFlattenParents = true)
onUpdatable(updatableFilterLivePageResult) onUpdatable(updatableFilterLivePageResult)
val itemCountFlow = updatableFilterLivePageResult.livePagedList.asFlow() val itemCountFlow = updatableFilterLivePageResult.livePagedList.asFlow()

View File

@ -199,7 +199,9 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
private fun getSearchResultSubtitle(roomSummary: RoomSummary): String { private fun getSearchResultSubtitle(roomSummary: RoomSummary): String {
val userId = roomSummary.directUserId val userId = roomSummary.directUserId
val spaceName = roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name val spaceName = roomSummary.flattenParents
.takeIf { it.isNotEmpty() }
?.joinToString(", ") { it.name }
val canonicalAlias = roomSummary.canonicalAlias val canonicalAlias = roomSummary.canonicalAlias
return (userId ?: spaceName ?: canonicalAlias).orEmpty() return (userId ?: spaceName ?: canonicalAlias).orEmpty()