Merge pull request #4693 from SpiritCroc/spaceChildIds

Fix possible crash when having identical subspaces in multiple root spaces
This commit is contained in:
Benoit Marty 2021-12-13 22:59:57 +01:00 committed by GitHub
commit 3719551913
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

1
changelog.d/4693.bugfix Normal file
View file

@ -0,0 +1 @@
Fix possible crash when having identical subspaces in multiple root spaces

View file

@ -170,7 +170,7 @@ class SpaceSummaryController @Inject constructor(
if (hasChildren && expanded) { if (hasChildren && expanded) {
// it's expanded // it's expanded
subSpaces?.forEach { child -> subSpaces?.forEach { child ->
buildSubSpace(summaries, expandedStates, selected, child, 1, 3) buildSubSpace(groupSummary.roomId, summaries, expandedStates, selected, child, 1, 3)
} }
} }
} }
@ -181,7 +181,8 @@ class SpaceSummaryController @Inject constructor(
} }
} }
private fun buildSubSpace(summaries: List<RoomSummary>?, private fun buildSubSpace(idPrefix: String,
summaries: List<RoomSummary>?,
expandedStates: Map<String, Boolean>, expandedStates: Map<String, Boolean>,
selected: RoomGroupingMethod, selected: RoomGroupingMethod,
info: SpaceChildInfo, currentDepth: Int, maxDepth: Int) { info: SpaceChildInfo, currentDepth: Int, maxDepth: Int) {
@ -195,9 +196,11 @@ class SpaceSummaryController @Inject constructor(
val expanded = expandedStates[childSummary.roomId] == true val expanded = expandedStates[childSummary.roomId] == true
val isSelected = selected is RoomGroupingMethod.BySpace && childSummary.roomId == selected.space()?.roomId val isSelected = selected is RoomGroupingMethod.BySpace && childSummary.roomId == selected.space()?.roomId
val id = "$idPrefix:${childSummary.roomId}"
subSpaceSummaryItem { subSpaceSummaryItem {
avatarRenderer(host.avatarRenderer) avatarRenderer(host.avatarRenderer)
id(childSummary.roomId) id(id)
hasChildren(!subSpaces.isNullOrEmpty()) hasChildren(!subSpaces.isNullOrEmpty())
selected(isSelected) selected(isSelected)
expanded(expanded) expanded(expanded)
@ -216,7 +219,7 @@ class SpaceSummaryController @Inject constructor(
if (expanded) { if (expanded) {
subSpaces?.forEach { subSpaces?.forEach {
buildSubSpace(summaries, expandedStates, selected, it, currentDepth + 1, maxDepth) buildSubSpace(id, summaries, expandedStates, selected, it, currentDepth + 1, maxDepth)
} }
} }
} }