From e53fbaa11dad00238a20d6cb775196580594b7b3 Mon Sep 17 00:00:00 2001 From: valere Date: Fri, 3 Feb 2023 11:50:17 +0100 Subject: [PATCH] Fix false positive empty roomlist --- .../android/sdk/api/session/crypto/CryptoService.kt | 3 ++- .../room/list/home/HomeFilteredRoomsController.kt | 12 ++++++++++++ .../home/room/list/home/HomeRoomListFragment.kt | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/CryptoService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/CryptoService.kt index 0ee3ea499f..6eb7d06e76 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/CryptoService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/CryptoService.kt @@ -90,9 +90,10 @@ interface CryptoService { fun isKeyGossipingEnabled(): Boolean /* - * Tells if the current crypto implementation supports MSC3061 + * Tells if the current crypto implementation supports MSC3061 */ fun supportsShareKeysOnInvite(): Boolean + /** * As per MSC3061. * If true will make it possible to share part of e2ee room history diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeFilteredRoomsController.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeFilteredRoomsController.kt index 52c319089c..95a4cb750f 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeFilteredRoomsController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeFilteredRoomsController.kt @@ -26,6 +26,7 @@ import im.vector.app.features.home.room.list.RoomListListener import im.vector.app.features.home.room.list.RoomSummaryItemFactory import im.vector.app.features.home.room.list.RoomSummaryPlaceHolderItem_ import im.vector.app.features.settings.FontScalePreferences +import org.matrix.android.sdk.api.session.room.ResultBoundaries import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState import org.matrix.android.sdk.api.session.room.model.RoomSummary import javax.inject.Inject @@ -53,6 +54,8 @@ class HomeFilteredRoomsController @Inject constructor( private val shouldUseSingleLine: Boolean + var initialLoadOccurred = false + init { val fontScale = fontScalePreferences.getResolvedFontScaleValue() shouldUseSingleLine = fontScale.scale > FontScalePreferences.SCALE_LARGE @@ -78,6 +81,15 @@ class HomeFilteredRoomsController @Inject constructor( } } + fun boundaryChange(boundary: ResultBoundaries) { + // Sometimes the room stays on empty state, need + val boundaryHasLoadedSomething = boundary.frontLoaded || boundary.zeroItemLoaded + if (initialLoadOccurred != boundaryHasLoadedSomething) { + initialLoadOccurred = boundaryHasLoadedSomething + requestForcedModelBuild() + } + } + fun submitEmptyStateData(state: StateView.State.Empty?) { this.emptyStateData = state } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt index 673f67989c..20e1797127 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt @@ -160,6 +160,11 @@ class HomeRoomListFragment : roomListViewModel.filteredPagedRoomSummariesLive.livePagedList.observe(viewLifecycleOwner) { roomsList -> roomsController.submitRoomsList(roomsList) } + + roomListViewModel.filteredPagedRoomSummariesLive.liveBoundaries.observe(viewLifecycleOwner) { + roomsController.boundaryChange(it) + } + roomListViewModel.onEach(HomeRoomListViewState::emptyState) { emptyState -> roomsController.submitEmptyStateData(emptyState) }