Progress
This commit is contained in:
79
app/javascript/gabsocial/features/community_timeline.js
Normal file
79
app/javascript/gabsocial/features/community_timeline.js
Normal file
@@ -0,0 +1,79 @@
|
||||
import { defineMessages, injectIntl } from 'react-intl'
|
||||
import { expandCommunityTimeline } from '../actions/timelines'
|
||||
import { connectCommunityStream } from '../actions/streaming'
|
||||
import StatusListContainer from '../containers/status_list_container'
|
||||
|
||||
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 => {
|
||||
const onlyMedia = state.getIn(['settings', 'community', 'other', 'onlyMedia'])
|
||||
|
||||
return {
|
||||
onlyMedia,
|
||||
}
|
||||
}
|
||||
|
||||
export default
|
||||
@connect(mapStateToProps)
|
||||
@injectIntl
|
||||
class CommunityTimeline extends 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 }))
|
||||
this.disconnect = dispatch(connectCommunityStream({ onlyMedia }))
|
||||
}
|
||||
|
||||
componentDidUpdate (prevProps) {
|
||||
if (prevProps.onlyMedia !== this.props.onlyMedia) {
|
||||
const { dispatch, onlyMedia } = this.props
|
||||
|
||||
this.disconnect()
|
||||
|
||||
dispatch(expandCommunityTimeline({ onlyMedia }))
|
||||
this.disconnect = dispatch(connectCommunityStream({ onlyMedia }))
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
if (this.disconnect) {
|
||||
this.disconnect()
|
||||
this.disconnect = null
|
||||
}
|
||||
}
|
||||
|
||||
handleLoadMore = maxId => {
|
||||
const { dispatch, onlyMedia } = this.props
|
||||
|
||||
dispatch(expandCommunityTimeline({ maxId, onlyMedia }))
|
||||
}
|
||||
|
||||
render () {
|
||||
const { intl, onlyMedia } = this.props
|
||||
|
||||
const emptyMessage = intl.formatMessage(messages.empty)
|
||||
|
||||
return (
|
||||
<StatusListContainer
|
||||
scrollKey='community_timeline'
|
||||
timelineId={`community${onlyMedia ? ':media' : ''}`}
|
||||
onLoadMore={this.handleLoadMore}
|
||||
emptyMessage={emptyMessage}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user