From 8c1afbaa66f24c0b61c92d09c459e40108e079a2 Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 28 Apr 2021 12:54:19 +0200 Subject: [PATCH] Fix / empty space pannel on new accounts --- .../features/spaces/SpaceSummaryController.kt | 37 ++++++------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceSummaryController.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceSummaryController.kt index a26f28a1c4..4b78a999bb 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceSummaryController.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceSummaryController.kt @@ -102,10 +102,6 @@ class SpaceSummaryController @Inject constructor( rootSpaces: List?, expandedStates: Map, homeCount: RoomAggregateNotificationCount) { - if (summaries.isNullOrEmpty()) { - return - } - genericItemHeader { id("spaces") text(stringProvider.getString(R.string.spaces_header)) @@ -115,24 +111,16 @@ class SpaceSummaryController @Inject constructor( // show invites on top - summaries.filter { it.membership == Membership.INVITE } - .let { invites -> - if (invites.isNotEmpty()) { -// genericItemHeader { -// id("invites") -// text(stringProvider.getString(R.string.spaces_invited_header)) -// } - invites.forEach { - spaceSummaryItem { - avatarRenderer(avatarRenderer) - id(it.roomId) - matrixItem(it.toMatrixItem()) - countState(UnreadCounterBadgeView.State(1, true)) - selected(false) - description(stringProvider.getString(R.string.you_are_invited)) - listener { callback?.onSpaceInviteSelected(it) } - } - } + summaries?.filter { it.membership == Membership.INVITE } + ?.forEach { + spaceSummaryItem { + avatarRenderer(avatarRenderer) + id(it.roomId) + matrixItem(it.toMatrixItem()) + countState(UnreadCounterBadgeView.State(1, true)) + selected(false) + description(stringProvider.getString(R.string.you_are_invited)) + listener { callback?.onSpaceInviteSelected(it) } } } @@ -149,7 +137,7 @@ class SpaceSummaryController @Inject constructor( val isSelected = selected is RoomGroupingMethod.BySpace && groupSummary.roomId == selected.space()?.roomId // does it have children? val subSpaces = groupSummary.spaceChildren?.filter { childInfo -> - summaries.indexOfFirst { it.roomId == childInfo.childRoomId } != -1 + summaries?.indexOfFirst { it.roomId == childInfo.childRoomId } != -1 } val hasChildren = (subSpaces?.size ?: 0) > 0 val expanded = expandedStates[groupSummary.roomId] == true @@ -175,7 +163,7 @@ class SpaceSummaryController @Inject constructor( if (hasChildren && expanded) { // it's expanded subSpaces?.forEach { child -> - summaries.firstOrNull { it.roomId == child.childRoomId }?.let { childSum -> + summaries?.firstOrNull { it.roomId == child.childRoomId }?.let { childSum -> val isChildSelected = selected is RoomGroupingMethod.BySpace && childSum.roomId == selected.space()?.roomId spaceSummaryItem { avatarRenderer(avatarRenderer) @@ -197,7 +185,6 @@ class SpaceSummaryController @Inject constructor( } } -// Temporary item to create a new Space (will move with final design) spaceAddItem { id("create") listener { callback?.onAddSpaceSelected() }