[groups] Change default sorts for groups and groups collection
This commit is contained in:
parent
1c647b0b06
commit
3f6e8a62fd
|
@ -25,7 +25,7 @@ import GroupsCollection from './groups_collection'
|
||||||
class GroupCollectionTimeline extends React.PureComponent {
|
class GroupCollectionTimeline extends React.PureComponent {
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
//keep track of page loads for if no user,
|
//keep track of page loads for if no user,
|
||||||
//only allow MIN_UNAUTHENTICATED_PAGES page loads before showing sign up msg
|
//only allow MIN_UNAUTHENTICATED_PAGES page loads before showing sign up msg
|
||||||
page: 1,
|
page: 1,
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@ class GroupCollectionTimeline extends React.PureComponent {
|
||||||
|
|
||||||
if (this.props.collectionType === 'featured' && sortByValue !== GROUP_TIMELINE_SORTING_TYPE_HOT) {
|
if (this.props.collectionType === 'featured' && sortByValue !== GROUP_TIMELINE_SORTING_TYPE_HOT) {
|
||||||
this.props.setFeaturedTop()
|
this.props.setFeaturedTop()
|
||||||
} else if (!!me && this.props.collectionType === 'member' && sortByValue !== GROUP_TIMELINE_SORTING_TYPE_NEWEST) {
|
} else if (!!me && this.props.collectionType === 'member' && sortByValue !== GROUP_TIMELINE_SORTING_TYPE_HOT) {
|
||||||
this.props.setMemberNewest()
|
this.props.setMemberHot()
|
||||||
} else {
|
} else {
|
||||||
const sortBy = getSortBy(sortByValue, sortByTopValue)
|
const sortBy = getSortBy(sortByValue, sortByTopValue)
|
||||||
this.props.onExpandGroupCollectionTimeline(collectionType, { sortBy })
|
this.props.onExpandGroupCollectionTimeline(collectionType, { sortBy })
|
||||||
|
@ -48,7 +48,7 @@ class GroupCollectionTimeline extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
if (prevProps.sortByValue !== this.props.sortByValue ||
|
if (prevProps.sortByValue !== this.props.sortByValue ||
|
||||||
prevProps.sortByTopValue !== this.props.sortByTopValue ||
|
prevProps.sortByTopValue !== this.props.sortByTopValue ||
|
||||||
prevProps.collectionType !== this.props.collectionType) {
|
prevProps.collectionType !== this.props.collectionType) {
|
||||||
this.props.onClearTimeline(`group_collection:${prevProps.collectionType}`)
|
this.props.onClearTimeline(`group_collection:${prevProps.collectionType}`)
|
||||||
|
@ -63,7 +63,7 @@ class GroupCollectionTimeline extends React.PureComponent {
|
||||||
sortByTopValue,
|
sortByTopValue,
|
||||||
} = this.props
|
} = this.props
|
||||||
const { page } = this.state
|
const { page } = this.state
|
||||||
|
|
||||||
const newPage = !!maxId ? this.state.page + 1 : 1
|
const newPage = !!maxId ? this.state.page + 1 : 1
|
||||||
if (!!maxId && !me && page >= MIN_UNAUTHENTICATED_PAGES) return false
|
if (!!maxId && !me && page >= MIN_UNAUTHENTICATED_PAGES) return false
|
||||||
this.setState({ page: newPage })
|
this.setState({ page: newPage })
|
||||||
|
@ -73,7 +73,7 @@ class GroupCollectionTimeline extends React.PureComponent {
|
||||||
|
|
||||||
this.props.onExpandGroupCollectionTimeline(collectionType, options)
|
this.props.onExpandGroupCollectionTimeline(collectionType, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
collectionType,
|
collectionType,
|
||||||
|
@ -141,6 +141,9 @@ const mapDispatchToProps = (dispatch) => ({
|
||||||
setMemberNewest() {
|
setMemberNewest() {
|
||||||
dispatch(setGroupTimelineSort(GROUP_TIMELINE_SORTING_TYPE_NEWEST))
|
dispatch(setGroupTimelineSort(GROUP_TIMELINE_SORTING_TYPE_NEWEST))
|
||||||
},
|
},
|
||||||
|
setMemberHot() {
|
||||||
|
dispatch(setGroupTimelineSort(GROUP_TIMELINE_SORTING_TYPE_HOT))
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
GroupCollectionTimeline.propTypes = {
|
GroupCollectionTimeline.propTypes = {
|
||||||
|
@ -156,4 +159,4 @@ GroupCollectionTimeline.propTypes = {
|
||||||
hasStatuses: PropTypes.bool.isRequired,
|
hasStatuses: PropTypes.bool.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(GroupCollectionTimeline))
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(GroupCollectionTimeline))
|
||||||
|
|
|
@ -14,10 +14,12 @@ import {
|
||||||
} from '../actions/timelines'
|
} from '../actions/timelines'
|
||||||
import {
|
import {
|
||||||
setGroupTimelineSort,
|
setGroupTimelineSort,
|
||||||
|
setGroupTimelineTopSort,
|
||||||
} from '../actions/groups'
|
} from '../actions/groups'
|
||||||
import {
|
import {
|
||||||
MIN_UNAUTHENTICATED_PAGES,
|
MIN_UNAUTHENTICATED_PAGES,
|
||||||
GROUP_TIMELINE_SORTING_TYPE_NEWEST,
|
GROUP_TIMELINE_SORTING_TYPE_NEWEST,
|
||||||
|
GROUP_TIMELINE_SORTING_TYPE_TOP_OPTION_WEEKLY,
|
||||||
} from '../constants'
|
} from '../constants'
|
||||||
import StatusList from '../components/status_list'
|
import StatusList from '../components/status_list'
|
||||||
import ColumnIndicator from '../components/column_indicator'
|
import ColumnIndicator from '../components/column_indicator'
|
||||||
|
@ -26,11 +28,11 @@ import GroupSortBlock from '../components/group_sort_block'
|
||||||
class GroupTimeline extends ImmutablePureComponent {
|
class GroupTimeline extends ImmutablePureComponent {
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
//keep track of page loads for if no user,
|
//keep track of page loads for if no user,
|
||||||
//only allow MIN_UNAUTHENTICATED_PAGES page loads before showing sign up msg
|
//only allow MIN_UNAUTHENTICATED_PAGES page loads before showing sign up msg
|
||||||
page: 1,
|
page: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const {
|
const {
|
||||||
groupId,
|
groupId,
|
||||||
|
@ -40,8 +42,8 @@ class GroupTimeline extends ImmutablePureComponent {
|
||||||
isDeckConnected,
|
isDeckConnected,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
if (sortByValue !== GROUP_TIMELINE_SORTING_TYPE_NEWEST) {
|
if (sortByValue !== GROUP_TIMELINE_SORTING_TYPE_TOP_OPTION_WEEKLY) {
|
||||||
this.props.setMemberNewest()
|
this.props.setMemberTopWeekly()
|
||||||
} else {
|
} else {
|
||||||
const sortBy = getSortBy(sortByValue, sortByTopValue, onlyMedia)
|
const sortBy = getSortBy(sortByValue, sortByTopValue, onlyMedia)
|
||||||
|
|
||||||
|
@ -74,11 +76,11 @@ class GroupTimeline extends ImmutablePureComponent {
|
||||||
onlyMedia,
|
onlyMedia,
|
||||||
} = this.props
|
} = this.props
|
||||||
const { page } = this.state
|
const { page } = this.state
|
||||||
|
|
||||||
const newPage = !!maxId ? this.state.page + 1 : 1
|
const newPage = !!maxId ? this.state.page + 1 : 1
|
||||||
if (!!maxId && !me && page >= MIN_UNAUTHENTICATED_PAGES) return false
|
if (!!maxId && !me && page >= MIN_UNAUTHENTICATED_PAGES) return false
|
||||||
this.setState({ page: newPage })
|
this.setState({ page: newPage })
|
||||||
|
|
||||||
const sortBy = getSortBy(sortByValue, sortByTopValue)
|
const sortBy = getSortBy(sortByValue, sortByTopValue)
|
||||||
this.props.onExpandGroupTimeline(groupId, {
|
this.props.onExpandGroupTimeline(groupId, {
|
||||||
sortBy,
|
sortBy,
|
||||||
|
@ -146,6 +148,9 @@ const mapDispatchToProps = (dispatch) => ({
|
||||||
setMemberNewest() {
|
setMemberNewest() {
|
||||||
dispatch(setGroupTimelineSort(GROUP_TIMELINE_SORTING_TYPE_NEWEST))
|
dispatch(setGroupTimelineSort(GROUP_TIMELINE_SORTING_TYPE_NEWEST))
|
||||||
},
|
},
|
||||||
|
setMemberTopWeekly() {
|
||||||
|
dispatch(setGroupTimelineTopSort(GROUP_TIMELINE_SORTING_TYPE_TOP_OPTION_WEEKLY))
|
||||||
|
},
|
||||||
onExpandGroupFeaturedTimeline(groupId) {
|
onExpandGroupFeaturedTimeline(groupId) {
|
||||||
dispatch(expandGroupFeaturedTimeline(groupId))
|
dispatch(expandGroupFeaturedTimeline(groupId))
|
||||||
},
|
},
|
||||||
|
@ -168,4 +173,4 @@ GroupTimeline.propTypes = {
|
||||||
onlyMedia: PropTypes.bool,
|
onlyMedia: PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(GroupTimeline))
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(GroupTimeline))
|
||||||
|
|
Loading…
Reference in New Issue