gab-social/app/javascript/gabsocial/features/community_timeline.js
mgabdev 7e47bb1d9c Removed prop-types global import, added to files directly
• Removed:
- prop-types global import, added to files directly
2020-08-17 15:59:29 -05:00

67 lines
1.7 KiB
JavaScript

import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { defineMessages, injectIntl } from 'react-intl'
import { expandCommunityTimeline } from '../actions/timelines'
import StatusList from '../components/status_list'
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'])
})
export default
@connect(mapStateToProps)
@injectIntl
class CommunityTimeline extends React.PureComponent {
static contextTypes = {
router: PropTypes.object,
}
static propTypes = {
dispatch: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
onlyMedia: PropTypes.bool,
}
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 (
<StatusList
scrollKey='community_timeline'
timelineId={`community${onlyMedia ? ':media' : ''}`}
onLoadMore={this.handleLoadMore}
emptyMessage={emptyMessage}
/>
)
}
}