Fix / empty space pannel on new accounts

This commit is contained in:
Valere 2021-04-28 12:54:19 +02:00
parent 32605be6e8
commit 8c1afbaa66
1 changed files with 12 additions and 25 deletions

View File

@ -102,10 +102,6 @@ class SpaceSummaryController @Inject constructor(
rootSpaces: List<RoomSummary>?, rootSpaces: List<RoomSummary>?,
expandedStates: Map<String, Boolean>, expandedStates: Map<String, Boolean>,
homeCount: RoomAggregateNotificationCount) { homeCount: RoomAggregateNotificationCount) {
if (summaries.isNullOrEmpty()) {
return
}
genericItemHeader { genericItemHeader {
id("spaces") id("spaces")
text(stringProvider.getString(R.string.spaces_header)) text(stringProvider.getString(R.string.spaces_header))
@ -115,24 +111,16 @@ class SpaceSummaryController @Inject constructor(
// show invites on top // show invites on top
summaries.filter { it.membership == Membership.INVITE } summaries?.filter { it.membership == Membership.INVITE }
.let { invites -> ?.forEach {
if (invites.isNotEmpty()) { spaceSummaryItem {
// genericItemHeader { avatarRenderer(avatarRenderer)
// id("invites") id(it.roomId)
// text(stringProvider.getString(R.string.spaces_invited_header)) matrixItem(it.toMatrixItem())
// } countState(UnreadCounterBadgeView.State(1, true))
invites.forEach { selected(false)
spaceSummaryItem { description(stringProvider.getString(R.string.you_are_invited))
avatarRenderer(avatarRenderer) listener { callback?.onSpaceInviteSelected(it) }
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 val isSelected = selected is RoomGroupingMethod.BySpace && groupSummary.roomId == selected.space()?.roomId
// does it have children? // does it have children?
val subSpaces = groupSummary.spaceChildren?.filter { childInfo -> 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 hasChildren = (subSpaces?.size ?: 0) > 0
val expanded = expandedStates[groupSummary.roomId] == true val expanded = expandedStates[groupSummary.roomId] == true
@ -175,7 +163,7 @@ class SpaceSummaryController @Inject constructor(
if (hasChildren && expanded) { if (hasChildren && expanded) {
// it's expanded // it's expanded
subSpaces?.forEach { child -> 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 val isChildSelected = selected is RoomGroupingMethod.BySpace && childSum.roomId == selected.space()?.roomId
spaceSummaryItem { spaceSummaryItem {
avatarRenderer(avatarRenderer) avatarRenderer(avatarRenderer)
@ -197,7 +185,6 @@ class SpaceSummaryController @Inject constructor(
} }
} }
// Temporary item to create a new Space (will move with final design)
spaceAddItem { spaceAddItem {
id("create") id("create")
listener { callback?.onAddSpaceSelected() } listener { callback?.onAddSpaceSelected() }