2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-08-17 21:39:25 +01:00
|
|
|
import { connect } from 'react-redux'
|
2020-03-25 03:08:43 +00:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
|
|
|
import { expandCommunityTimeline } from '../actions/timelines'
|
2020-04-11 23:29:19 +01:00
|
|
|
import StatusList from '../components/status_list'
|
2020-03-25 03:08:43 +00:00
|
|
|
|
2020-08-17 21:07:16 +01:00
|
|
|
class CommunityTimeline extends React.PureComponent {
|
2020-03-25 03:08:43 +00:00
|
|
|
|
|
|
|
static contextTypes = {
|
|
|
|
router: PropTypes.object,
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount () {
|
|
|
|
const { dispatch, onlyMedia } = this.props
|
|
|
|
|
|
|
|
dispatch(expandCommunityTimeline({ onlyMedia }))
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidUpdate (prevProps) {
|
|
|
|
if (prevProps.onlyMedia !== this.props.onlyMedia) {
|
|
|
|
const { dispatch, onlyMedia } = this.props
|
|
|
|
|
|
|
|
dispatch(expandCommunityTimeline({ onlyMedia }))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleLoadMore = maxId => {
|
|
|
|
const { dispatch, onlyMedia } = this.props
|
|
|
|
|
|
|
|
dispatch(expandCommunityTimeline({ maxId, onlyMedia }))
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { intl, onlyMedia } = this.props
|
|
|
|
|
|
|
|
const emptyMessage = intl.formatMessage(messages.empty)
|
|
|
|
|
|
|
|
return (
|
2020-04-11 23:29:19 +01:00
|
|
|
<StatusList
|
2020-03-25 03:08:43 +00:00
|
|
|
scrollKey='community_timeline'
|
|
|
|
timelineId={`community${onlyMedia ? ':media' : ''}`}
|
|
|
|
onLoadMore={this.handleLoadMore}
|
|
|
|
emptyMessage={emptyMessage}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-08-19 01:22:15 +01:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
empty: { id: 'empty_column.community', defaultMessage: 'The community timeline is empty. Write something publicly to get the ball rolling!' },
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({
|
|
|
|
onlyMedia: state.getIn(['settings', 'community', 'other', 'onlyMedia'])
|
|
|
|
})
|
|
|
|
|
|
|
|
CommunityTimeline.propTypes = {
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
onlyMedia: PropTypes.bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(connect(mapStateToProps)(CommunityTimeline))
|