-
Notifications
You must be signed in to change notification settings - Fork 759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Space list crash fix #5924
Merged
Merged
Space list crash fix #5924
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,8 @@ import javax.inject.Inject | |
class SpaceSummaryController @Inject constructor( | ||
private val avatarRenderer: AvatarRenderer, | ||
private val colorProvider: ColorProvider, | ||
private val stringProvider: StringProvider) : EpoxyController() { | ||
private val stringProvider: StringProvider, | ||
) : EpoxyController() { | ||
|
||
var callback: Callback? = null | ||
private var viewState: SpaceListViewState? = null | ||
|
@@ -62,7 +63,8 @@ class SpaceSummaryController @Inject constructor( | |
nonNullViewState.selectedGroupingMethod, | ||
nonNullViewState.rootSpacesOrdered, | ||
nonNullViewState.expandedStates, | ||
nonNullViewState.homeAggregateCount) | ||
nonNullViewState.homeAggregateCount | ||
) | ||
|
||
if (!nonNullViewState.legacyGroups.isNullOrEmpty()) { | ||
genericFooterItem { | ||
|
@@ -82,8 +84,10 @@ class SpaceSummaryController @Inject constructor( | |
avatarRenderer(host.avatarRenderer) | ||
id("all_communities") | ||
matrixItem(mxItem.copy(displayName = host.stringProvider.getString(R.string.group_all_communities))) | ||
selected(nonNullViewState.selectedGroupingMethod is RoomGroupingMethod.ByLegacyGroup && | ||
nonNullViewState.selectedGroupingMethod.group() == null) | ||
selected( | ||
nonNullViewState.selectedGroupingMethod is RoomGroupingMethod.ByLegacyGroup && | ||
nonNullViewState.selectedGroupingMethod.group() == null | ||
) | ||
listener { host.callback?.onGroupSelected(null) } | ||
} | ||
} | ||
|
@@ -93,8 +97,10 @@ class SpaceSummaryController @Inject constructor( | |
avatarRenderer(host.avatarRenderer) | ||
id(groupSummary.groupId) | ||
matrixItem(groupSummary.toMatrixItem()) | ||
selected(nonNullViewState.selectedGroupingMethod is RoomGroupingMethod.ByLegacyGroup && | ||
nonNullViewState.selectedGroupingMethod.group()?.groupId == groupSummary.groupId) | ||
selected( | ||
nonNullViewState.selectedGroupingMethod is RoomGroupingMethod.ByLegacyGroup && | ||
nonNullViewState.selectedGroupingMethod.group()?.groupId == groupSummary.groupId | ||
) | ||
listener { host.callback?.onGroupSelected(groupSummary) } | ||
} | ||
} | ||
|
@@ -112,12 +118,12 @@ class SpaceSummaryController @Inject constructor( | |
} | ||
|
||
// show invites on top | ||
|
||
summaries?.filter { it.membership == Membership.INVITE } | ||
summaries | ||
?.filter { it.membership == Membership.INVITE } | ||
?.forEach { roomSummary -> | ||
spaceSummaryItem { | ||
avatarRenderer(host.avatarRenderer) | ||
id(roomSummary.roomId) | ||
id("invite_${roomSummary.roomId}") | ||
matrixItem(roomSummary.toMatrixItem()) | ||
countState(UnreadCounterBadgeView.State(1, true)) | ||
selected(false) | ||
|
@@ -135,41 +141,42 @@ class SpaceSummaryController @Inject constructor( | |
} | ||
|
||
rootSpaces | ||
?.forEach { groupSummary -> | ||
val isSelected = selected is RoomGroupingMethod.BySpace && groupSummary.roomId == selected.space()?.roomId | ||
?.filter { it.membership != Membership.INVITE } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
?.forEach { roomSummary -> | ||
val isSelected = selected is RoomGroupingMethod.BySpace && roomSummary.roomId == selected.space()?.roomId | ||
// does it have children? | ||
val subSpaces = groupSummary.spaceChildren?.filter { childInfo -> | ||
val subSpaces = roomSummary.spaceChildren?.filter { childInfo -> | ||
summaries?.any { it.roomId == childInfo.childRoomId }.orFalse() | ||
}?.sortedWith(subSpaceComparator) | ||
val hasChildren = (subSpaces?.size ?: 0) > 0 | ||
val expanded = expandedStates[groupSummary.roomId] == true | ||
val expanded = expandedStates[roomSummary.roomId] == true | ||
|
||
spaceSummaryItem { | ||
avatarRenderer(host.avatarRenderer) | ||
id(groupSummary.roomId) | ||
id(roomSummary.roomId) | ||
hasChildren(hasChildren) | ||
expanded(expanded) | ||
// to debug order | ||
// matrixItem(groupSummary.copy(displayName = "${groupSummary.displayName} / ${spaceOrderInfo?.get(groupSummary.roomId)}") | ||
// .toMatrixItem()) | ||
matrixItem(groupSummary.toMatrixItem()) | ||
matrixItem(roomSummary.toMatrixItem()) | ||
selected(isSelected) | ||
canDrag(true) | ||
onMore { host.callback?.onSpaceSettings(groupSummary) } | ||
listener { host.callback?.onSpaceSelected(groupSummary) } | ||
toggleExpand { host.callback?.onToggleExpand(groupSummary) } | ||
onMore { host.callback?.onSpaceSettings(roomSummary) } | ||
listener { host.callback?.onSpaceSelected(roomSummary) } | ||
toggleExpand { host.callback?.onToggleExpand(roomSummary) } | ||
countState( | ||
UnreadCounterBadgeView.State( | ||
groupSummary.notificationCount, | ||
groupSummary.highlightCount > 0 | ||
roomSummary.notificationCount, | ||
roomSummary.highlightCount > 0 | ||
) | ||
) | ||
} | ||
|
||
if (hasChildren && expanded) { | ||
// it's expanded | ||
subSpaces?.forEach { child -> | ||
buildSubSpace(groupSummary.roomId, summaries, expandedStates, selected, child, 1, 3) | ||
buildSubSpace(roomSummary.roomId, summaries, expandedStates, selected, child, 1, 3) | ||
} | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a unique id for the invite makes sense to me to fix the crash, we can iterate on the proper UX (whether two spaces with the same id should be present in the spaces list...)