fix slow paged room list
This commit is contained in:
parent
0ef67b6b64
commit
b8eef9b19a
|
@ -227,11 +227,14 @@ 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(
|
fun getFilteredPagedRoomSummariesLive(
|
||||||
queryParams: RoomSummaryQueryParams,
|
queryParams: RoomSummaryQueryParams,
|
||||||
pagedListConfig: PagedList.Config = defaultPagedListConfig,
|
pagedListConfig: PagedList.Config = defaultPagedListConfig,
|
||||||
sortOrder: RoomSortOrder = RoomSortOrder.ACTIVITY
|
sortOrder: RoomSortOrder = RoomSortOrder.ACTIVITY,
|
||||||
|
getFlattenParents: Boolean = false,
|
||||||
): UpdatableLivePageResult
|
): UpdatableLivePageResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -139,9 +139,10 @@ internal class DefaultRoomService @Inject constructor(
|
||||||
override fun getFilteredPagedRoomSummariesLive(
|
override fun getFilteredPagedRoomSummariesLive(
|
||||||
queryParams: RoomSummaryQueryParams,
|
queryParams: RoomSummaryQueryParams,
|
||||||
pagedListConfig: PagedList.Config,
|
pagedListConfig: PagedList.Config,
|
||||||
sortOrder: RoomSortOrder
|
sortOrder: RoomSortOrder,
|
||||||
|
getFlattenedParents: Boolean
|
||||||
): UpdatableLivePageResult {
|
): UpdatableLivePageResult {
|
||||||
return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenedParents = true)
|
return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenedParents)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getRoomCountLive(queryParams: RoomSummaryQueryParams): LiveData<Int> {
|
override fun getRoomCountLive(queryParams: RoomSummaryQueryParams): LiveData<Int> {
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -332,7 +332,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()
|
||||||
|
|
|
@ -207,7 +207,9 @@ class RoomSummaryItemFactory @Inject constructor(
|
||||||
|
|
||||||
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()
|
||||||
|
|
Loading…
Reference in New Issue