Skip to content

Commit

Permalink
hotfix: height indexing with unit's bz name instead of id- critical
Browse files Browse the repository at this point in the history
We need to use the bz name as it is available even if matching with
unit meta data fails. Otherwise, the entire view crashes
  • Loading branch information
nbiton committed May 6, 2019
1 parent 543e18b commit 50aa286
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions imports/ui/explorer-components/unit-group-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export class UnitGroupList extends PureComponent {
stateMutation = {
expandedUnits: expandedUnits.filter(title => title !== unitTitle)
}
this.calculatedHeights[bzId] = UNIT_ROW_HEIGHT
this.calculatedHeights[unitTitle] = UNIT_ROW_HEIGHT
} else {
stateMutation = {
expandedUnits: expandedUnits.concat([unitTitle])
}
this.calculatedHeights[bzId] = UNIT_ROW_HEIGHT + (items.length * ITEM_ROW_HEIGHT)
this.calculatedHeights[unitTitle] = UNIT_ROW_HEIGHT + (items.length * ITEM_ROW_HEIGHT)
}
this.setState(stateMutation)
}
Expand Down Expand Up @@ -63,9 +63,9 @@ export class UnitGroupList extends PureComponent {
// Finding the first row index that should be rendered for the current scroll position
let rowIndex = 0
// "As long as the current row's height doesn't exceed the remainder"
while (requestedBeforeHeight - this.calculatedHeights[unitGroupList[rowIndex].bzId.toString()] > 0) {
while (requestedBeforeHeight - this.calculatedHeights[unitGroupList[rowIndex].unitTitle.toString()] > 0) {
// Subtracting the current row's height from the remainder
requestedBeforeHeight -= this.calculatedHeights[unitGroupList[rowIndex].bzId.toString()]
requestedBeforeHeight -= this.calculatedHeights[unitGroupList[rowIndex].unitTitle.toString()]
// Counting to the next row
rowIndex++
}
Expand Down Expand Up @@ -100,7 +100,7 @@ export class UnitGroupList extends PureComponent {

calcHeightForData = data => {
return data.reduce((sum, d) => {
return sum + this.calculatedHeights[d.bzId.toString()]
return sum + this.calculatedHeights[d.unitTitle.toString()]
}, 0)
}

Expand All @@ -110,7 +110,7 @@ export class UnitGroupList extends PureComponent {
this.beforeHeight = 0
if (unitGroupList.length) {
unitGroupList.forEach((item, idx) => {
const strId = item.bzId.toString()
const strId = item.unitTitle.toString()
if (!this.calculatedHeights[strId]) {
this.calculatedHeights[strId] = UNIT_ROW_HEIGHT
}
Expand Down

0 comments on commit 50aa286

Please sign in to comment.