Commit 2649c19a authored by mgabdev's avatar mgabdev

Fixed issue with promotions count checking in StatusList, SidebarPanelGroup

• Fixed:
- issue with promotions count checking in StatusList, SidebarPanelGroup
parent 6f8a1c01
......@@ -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 }} />)
}
}
}
......
......@@ -49,13 +49,13 @@ class StatusList extends ImmutablePureComponent {
promotions,
} = this.props
if (!!promotions && promotions.count() > 0) {
if (Array.isArray(promotions)) {
promotions.forEach((promotion) => {
if (promotion.get('timeline_id') === timelineId &&
statusIds.count() >= promotion.get('position') &&
!promotedStatuses[promotion.get('status_id')]) {
onFetchStatus(promotion.get('status_id'))
if (promotion.timeline_id === timelineId &&
statusIds.count() >= promotion.position &&
!promotedStatuses[promotion.status_id]) {
onFetchStatus(promotion.status_id)
}
})
......@@ -203,13 +203,13 @@ class StatusList extends ImmutablePureComponent {
/>
)
} else {
if (!!promotions && promotions.count() > 0) {
const promotion = promotions.find((p) => (p.get('position') === i && p.get('timeline_id') === timelineId))
if (Array.isArray(promotions)) {
const promotion = promotions.find((promotion) => (promotion.position === i && promotion.timeline_id === timelineId))
if (promotion) {
scrollableContent.push(
<StatusContainer
key={`promotion-${i}-${promotion.get('status_id')}`}
id={promotion.get('status_id')}
key={`promotion-${i}-${promotion.status_id}`}
id={promotion.status_id}
onMoveUp={this.handleMoveUp}
onMoveDown={this.handleMoveDown}
contextType={timelineId}
......@@ -350,10 +350,10 @@ const mapStateToProps = (state, { timelineId }) => {
id: timelineId
})
const promotedStatuses = (!!promotions && promotions.count() > 0) ?
const promotedStatuses = Array.isArray(promotions) ?
promotions.map((promotion) => {
const s = {}
s[promotion.get('status_id')] = state.getIn(['statuses', promotion.get('status_id')])
s[promotion.status_id] = state.getIn(['statuses', promotion.status_id])
return s
}) : []
......
import {
List as ImmutableList,
fromJS,
}from 'immutable'
import {
PROMOTIONS_FETCH_REQUEST,
PROMOTIONS_FETCH_SUCCESS,
PROMOTIONS_FETCH_FAIL,
} from '../actions/promotions'
const initialState = ImmutableList()
const initialState = []
export default function promotions(state = initialState, action) {
switch (action.type) {
......@@ -16,7 +12,7 @@ export default function promotions(state = initialState, action) {
case PROMOTIONS_FETCH_FAIL:
return initialState
case PROMOTIONS_FETCH_SUCCESS:
return fromJS(action.items)
return action.items
default:
return state
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment