Fixed issue with promotions count checking in StatusList, SidebarPanelGroup

• Fixed:
- issue with promotions count checking in StatusList, SidebarPanelGroup
This commit is contained in:
mgabdev
2020-11-09 14:31:19 -06:00
parent 6f8a1c012d
commit 2649c19a50
3 changed files with 17 additions and 21 deletions

View File

@@ -18,14 +18,14 @@ class SidebarPanelGroup extends React.PureComponent {
promotions,
} = this.props
if (!!promotions && promotions.count() > 0 && Array.isArray(layout) && !!me) {
if (Array.isArray(promotions) && Array.isArray(layout) && !!me) {
const sidebarPromotionPageId = `${page}.sidebar`
const promotion = promotions.find((p) => p.get('timeline_id') === sidebarPromotionPageId)
const promotion = promotions.find((promotion) => promotion.timeline_id === sidebarPromotionPageId)
if (!!promotion) {
const correctedPosition = promotion.get('position') - 1 > layout.length ? layout.length - 1 : promotion.get('position')
const correctedPosition = promotion.position - 1 > layout.length ? layout.length - 1 : promotion.position
if (!layout.find(p => p.key === 'status-promotion-panel')) {
layout.splice(correctedPosition, 0, <WrappedBundle key='status-promotion-panel' component={StatusPromotionPanel} componentParams={{ statusId: promotion.get('status_id') }} />)
layout.splice(correctedPosition, 0, <WrappedBundle key='status-promotion-panel' component={StatusPromotionPanel} componentParams={{ statusId: promotion.status_id }} />)
}
}
}