Added GroupCollection timeline, redux, streaming, routes
• Added: - GroupCollection timeline, redux, streaming, routes
This commit is contained in:
@@ -55,6 +55,7 @@ export const connectProStream = () => connectTimelineStream('pro', 'pro');
|
||||
export const connectHashtagStream = (id, tag, accept) => connectTimelineStream(`hashtag:${id}`, `hashtag&tag=${tag}`, null, accept);
|
||||
export const connectListStream = id => connectTimelineStream(`list:${id}`, `list&list=${id}`);
|
||||
export const connectGroupStream = id => connectTimelineStream(`group:${id}`, `group&group=${id}`);
|
||||
export const connectGroupCollectionStream = (id) => connectTimelineStream(`group:collection:${id}`, `group&group:collection=${id}`);
|
||||
|
||||
export const connectStatusUpdateStream = () => {
|
||||
return connectStream('statuscard', null, (dispatch, getState) => {
|
||||
|
||||
@@ -172,7 +172,8 @@ export const expandAccountTimeline = (accountId, { maxId, withReplies, commentsO
|
||||
export const expandAccountFeaturedTimeline = accountId => expandTimeline(`account:${accountId}:pinned`, `/api/v1/accounts/${accountId}/statuses`, { pinned: true });
|
||||
export const expandAccountMediaTimeline = (accountId, { maxId, limit, mediaType } = {}) => expandTimeline(`account:${accountId}:media`, `/api/v1/accounts/${accountId}/statuses`, { max_id: maxId, only_media: true, limit: limit || 20, media_type: mediaType });
|
||||
export const expandListTimeline = (id, { maxId } = {}, done = noOp) => expandTimeline(`list:${id}`, `/api/v1/timelines/list/${id}`, { max_id: maxId }, done);
|
||||
export const expandGroupTimeline = (id, { maxId } = {}, done = noOp) => expandTimeline(`group:${id}`, `/api/v1/timelines/group/${id}`, { max_id: maxId }, done);
|
||||
export const expandGroupTimeline = (id, { sortBy, maxId } = {}, done = noOp) => expandTimeline(`group:${id}`, `/api/v1/timelines/group/${id}`, { sort_by: sortBy, max_id: maxId }, done);
|
||||
export const expandGroupCollectionTimeline = (collectionType, { sortBy, maxId } = {}, done = noOp) => expandTimeline(`group:collection:${collectionType}`, `/api/v1/timelines/group_collection/${collectionType}`, { sort_by: sortBy, max_id: maxId }, done);
|
||||
export const expandHashtagTimeline = (hashtag, { maxId, tags } = {}, done = noOp) => {
|
||||
return expandTimeline(`hashtag:${hashtag}`, `/api/v1/timelines/tag/${hashtag}`, {
|
||||
max_id: maxId,
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { injectIntl, defineMessages } from 'react-intl'
|
||||
import { me } from '../initial_state'
|
||||
import { connectGroupCollectionStream } from '../actions/streaming'
|
||||
import { expandGroupCollectionTimeline } from '../actions/timelines'
|
||||
import StatusList from '../components/status_list'
|
||||
|
||||
const messages = defineMessages({
|
||||
empty: { id: 'empty_column.group_collection_timeline', defaultMessage: 'There are no gabs to display.' },
|
||||
})
|
||||
|
||||
const mapStateToProps = (state) = ({
|
||||
sortByValue: state.getIn(['group_lists', 'sortByValue']),
|
||||
sortByTopValue: state.getIn(['group_lists', 'sortByTopValue']),
|
||||
})
|
||||
|
||||
export default
|
||||
@injectIntl
|
||||
@connect(mapStateToProps)
|
||||
class GroupCollectionTimeline extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
params: PropTypes.object.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
sortByValue: PropTypes.string.isRequired,
|
||||
sortByTopValue: PropTypes.string,
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { collectionType, dispatch } = this.props
|
||||
|
||||
dispatch(expandGroupCollectionTimeline(collectionType))
|
||||
|
||||
if (!!me) {
|
||||
this.disconnect = dispatch(connectGroupCollectionStream(collectionType))
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.disconnect && !!me) {
|
||||
this.disconnect()
|
||||
this.disconnect = null
|
||||
}
|
||||
}
|
||||
|
||||
handleLoadMore = (maxId) => {
|
||||
const { collectionType } = this.props
|
||||
this.props.dispatch(expandGroupCollectionTimeline(collectionType, { maxId }))
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
collectionType,
|
||||
intl,
|
||||
} = this.props
|
||||
|
||||
return (
|
||||
<StatusList
|
||||
scrollKey={`group-collection-timeline-${collectionType}`}
|
||||
timelineId={`group:collection:${collectionType}`}
|
||||
onLoadMore={this.handleLoadMore}
|
||||
emptyMessage={intl.formatMessage(messages.empty)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user