2020-02-19 23:57:07 +00:00
|
|
|
import { injectIntl, defineMessages } from 'react-intl'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
2020-04-04 00:18:26 +01:00
|
|
|
import { fetchGabTrends } from '../../actions/gab_trends'
|
2020-02-19 23:57:07 +00:00
|
|
|
import PanelLayout from './panel_layout'
|
2020-04-28 06:33:58 +01:00
|
|
|
import ScrollableList from '../scrollable_list'
|
2020-04-29 23:32:49 +01:00
|
|
|
import TrendsItem from '../trends_item'
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
2020-04-07 02:53:23 +01:00
|
|
|
title: { id: 'trends.title', defaultMessage: 'Trending right now' },
|
2020-02-19 23:57:07 +00:00
|
|
|
})
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-04-11 23:29:19 +01:00
|
|
|
const mapStateToProps = (state) => ({
|
2020-04-04 00:18:26 +01:00
|
|
|
gabtrends: state.getIn(['gab_trends', 'items']),
|
|
|
|
})
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-04-11 23:29:19 +01:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
onFetchGabTrends: () => dispatch(fetchGabTrends()),
|
|
|
|
})
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-02-19 23:57:07 +00:00
|
|
|
export default
|
2020-04-04 00:18:26 +01:00
|
|
|
@connect(mapStateToProps, mapDispatchToProps)
|
2019-08-07 06:02:36 +01:00
|
|
|
@injectIntl
|
|
|
|
class TrendsPanel extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
2020-04-04 00:18:26 +01:00
|
|
|
gabtrends: ImmutablePropTypes.list.isRequired,
|
|
|
|
onFetchGabTrends: PropTypes.func.isRequired,
|
2020-02-19 23:57:07 +00:00
|
|
|
}
|
2019-08-07 06:02:36 +01:00
|
|
|
|
2020-04-29 23:32:49 +01:00
|
|
|
updateOnProps = [
|
|
|
|
'gabtrends',
|
|
|
|
]
|
|
|
|
|
2020-04-28 06:33:58 +01:00
|
|
|
componentDidMount() {
|
2020-04-04 00:18:26 +01:00
|
|
|
this.props.onFetchGabTrends()
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2020-04-04 00:18:26 +01:00
|
|
|
const { intl, gabtrends } = this.props
|
2019-08-07 06:02:36 +01:00
|
|
|
|
|
|
|
return (
|
2020-02-21 00:57:29 +00:00
|
|
|
<PanelLayout
|
|
|
|
noPadding
|
|
|
|
title={intl.formatMessage(messages.title)}
|
|
|
|
>
|
2020-04-29 23:32:49 +01:00
|
|
|
<ScrollableList
|
|
|
|
showLoading={gabtrends.size == 0}
|
|
|
|
scrollKey='trending-items'
|
|
|
|
>
|
2020-04-04 00:18:26 +01:00
|
|
|
{
|
2020-04-29 23:32:49 +01:00
|
|
|
gabtrends.slice(0, 8).map((trend, i) => (
|
|
|
|
<TrendsItem
|
|
|
|
key={`gab-trend-${i}`}
|
|
|
|
index={i + 1}
|
|
|
|
isLast={i === 7}
|
|
|
|
trend={trend}
|
|
|
|
/>
|
|
|
|
))
|
2020-04-04 00:18:26 +01:00
|
|
|
}
|
2020-04-29 23:32:49 +01:00
|
|
|
</ScrollableList>
|
2019-08-07 06:02:36 +01:00
|
|
|
</PanelLayout>
|
2020-02-19 23:57:07 +00:00
|
|
|
)
|
2019-08-07 06:02:36 +01:00
|
|
|
}
|
2020-02-19 23:57:07 +00:00
|
|
|
}
|