From b8eef9b19a0080b37a7b018b45a22abf08d54808 Mon Sep 17 00:00:00 2001 From: Valere Date: Fri, 3 Jun 2022 14:21:03 +0200 Subject: [PATCH 1/4] fix slow paged room list --- .../org/matrix/android/sdk/api/session/room/RoomService.kt | 5 ++++- .../android/sdk/internal/session/room/DefaultRoomService.kt | 5 +++-- .../features/home/room/list/RoomListSectionBuilderGroup.kt | 2 +- .../features/home/room/list/RoomListSectionBuilderSpace.kt | 2 +- .../app/features/home/room/list/RoomSummaryItemFactory.kt | 4 +++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt index 0a495f35524..ea86d04a29c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt @@ -227,11 +227,14 @@ interface RoomService { /** * 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, pagedListConfig: PagedList.Config = defaultPagedListConfig, - sortOrder: RoomSortOrder = RoomSortOrder.ACTIVITY + sortOrder: RoomSortOrder = RoomSortOrder.ACTIVITY, + getFlattenParents: Boolean = false, ): UpdatableLivePageResult /** diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt index 7a7804c3544..63d40911674 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt @@ -139,9 +139,10 @@ internal class DefaultRoomService @Inject constructor( override fun getFilteredPagedRoomSummariesLive( queryParams: RoomSummaryQueryParams, pagedListConfig: PagedList.Config, - sortOrder: RoomSortOrder + sortOrder: RoomSortOrder, + getFlattenedParents: Boolean ): UpdatableLivePageResult { - return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenedParents = true) + return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenedParents) } override fun getRoomCountLive(queryParams: RoomSummaryQueryParams): LiveData { diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderGroup.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderGroup.kt index 70fb6988e85..01fced64891 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderGroup.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderGroup.kt @@ -71,7 +71,7 @@ class RoomListSectionBuilderGroup( }, { qpm -> 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) val itemCountFlow = updatableFilterLivePageResult.livePagedList.asFlow() 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 0e3f61e1865..362c4461156 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 @@ -332,7 +332,7 @@ class RoomListSectionBuilderSpace( }, { queryParams -> 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) val itemCountFlow = updatableFilterLivePageResult.livePagedList.asFlow() diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index 9601ccf9147..0526af367a8 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -207,7 +207,9 @@ class RoomSummaryItemFactory @Inject constructor( private fun getSearchResultSubtitle(roomSummary: RoomSummary): String { 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 return (userId ?: spaceName ?: canonicalAlias).orEmpty() From 43b76f763ecd8d4223ee59c452452d6baefe8f47 Mon Sep 17 00:00:00 2001 From: Valere Date: Fri, 3 Jun 2022 14:46:29 +0200 Subject: [PATCH 2/4] Fix param name --- .../android/sdk/internal/session/room/DefaultRoomService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt index 63d40911674..5e6d052443d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt @@ -140,9 +140,9 @@ internal class DefaultRoomService @Inject constructor( queryParams: RoomSummaryQueryParams, pagedListConfig: PagedList.Config, sortOrder: RoomSortOrder, - getFlattenedParents: Boolean + getFlattenParents: Boolean ): UpdatableLivePageResult { - return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenedParents) + return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenParents) } override fun getRoomCountLive(queryParams: RoomSummaryQueryParams): LiveData { From adf8c5fb9f7e294bb8823a346738270b729ce107 Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 7 Jun 2022 09:39:32 +0200 Subject: [PATCH 3/4] code review --- changelog.d/6233.bugfix | 1 + .../matrix/android/sdk/api/session/room/RoomService.kt | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelog.d/6233.bugfix diff --git a/changelog.d/6233.bugfix b/changelog.d/6233.bugfix new file mode 100644 index 00000000000..0c415e1078a --- /dev/null +++ b/changelog.d/6233.bugfix @@ -0,0 +1 @@ +Fix | performance regression on roomlist + proper display of space parents in explore rooms. diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt index ea86d04a29c..5dfb8961e3c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt @@ -226,8 +226,12 @@ interface RoomService { ): LiveData> /** - * TODO Doc. - * @param getFlattenParents When true, the list of known parent and grand parent summaries will be resolved. + * Get's a live paged list from a filter that can be dynamically updated. + * + * @param queryParams The filter to use + * @param pagedListConfig The paged list configuration (page size, initial load, prefetch distance...) + * @param sortOrder defines how to sort the results + * @param getFlattenParents When true, the list of known parents and grand parents summaries will be resolved. * This can have significant impact on performance, better be used only on manageable list (filtered by displayName, ..). */ fun getFilteredPagedRoomSummariesLive( From 89e528d5527a707c2fbf82c2918cbfc3333e51e5 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 7 Jun 2022 10:10:22 +0200 Subject: [PATCH 4/4] Changes space subtitle in explore rooms from joined string to direct space parent --- .../app/features/home/room/list/RoomSummaryItemFactory.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index 0526af367a8..9b0427792fa 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -207,9 +207,7 @@ class RoomSummaryItemFactory @Inject constructor( private fun getSearchResultSubtitle(roomSummary: RoomSummary): String { val userId = roomSummary.directUserId - val spaceName = roomSummary.flattenParents - .takeIf { it.isNotEmpty() } - ?.joinToString(", ") { it.name } + val spaceName = roomSummary.flattenParents.lastOrNull()?.name val canonicalAlias = roomSummary.canonicalAlias return (userId ?: spaceName ?: canonicalAlias).orEmpty()