Added new sorting for "Hot" in GroupCollection, GroupTimeline

• Added:
- new sorting for "Hot" in GroupCollection, GroupTimeline
This commit is contained in:
mgabdev
2020-08-10 22:16:08 -05:00
parent 5f6a2e9cab
commit b2c69afdbd
6 changed files with 39 additions and 14 deletions

View File

@@ -3,6 +3,7 @@ import { openPopover } from '../actions/popover'
import {
POPOVER_GROUP_TIMELINE_SORT_OPTIONS,
POPOVER_GROUP_TIMELINE_SORT_TOP_OPTIONS,
GROUP_TIMELINE_SORTING_TYPE_HOT,
GROUP_TIMELINE_SORTING_TYPE_NEWEST,
GROUP_TIMELINE_SORTING_TYPE_RECENT_ACTIVITY,
GROUP_TIMELINE_SORTING_TYPE_TOP,
@@ -15,7 +16,8 @@ import {
import SortBlock from '../components/sort_block'
const messages = defineMessages({
sortBy: { id: 'comment_sort.title', defaultMessage: 'Sort by' },
sortBy: { id: 'comment_sort.title', defaultMessage: 'Sort by' },
hotTitle: { id: 'group_timeline_sorting.hot_title', defaultMessage: 'Hot Posts' },
topTitle: { id: 'group_timeline_sorting.top_title', defaultMessage: 'Top Posts' },
topTodayTitle: { id: 'group_timeline_sorting.top_today_title', defaultMessage: 'Today' },
topWeekTitle: { id: 'group_timeline_sorting.top_week_title', defaultMessage: 'This Week' },
@@ -85,6 +87,9 @@ class GroupSortBlock extends PureComponent {
let sortValueTopTitle = ''
switch (sortByValue) {
case GROUP_TIMELINE_SORTING_TYPE_HOT:
sortValueTitle = intl.formatMessage(messages.hotTitle)
break
case GROUP_TIMELINE_SORTING_TYPE_NEWEST:
sortValueTitle = intl.formatMessage(messages.newTitle)
break

View File

@@ -3,6 +3,7 @@ import isObject from 'lodash.isobject'
import { closePopover } from '../../actions/popover'
import { setGroupTimelineSort } from '../../actions/groups'
import {
GROUP_TIMELINE_SORTING_TYPE_HOT,
GROUP_TIMELINE_SORTING_TYPE_NEWEST,
GROUP_TIMELINE_SORTING_TYPE_RECENT_ACTIVITY,
GROUP_TIMELINE_SORTING_TYPE_TOP,
@@ -17,6 +18,8 @@ const messages = defineMessages({
recentSubtitle: { id: 'group_timeline_sorting.recent_subtitle', defaultMessage: 'See gabs with most recent comments first' },
newTitle: { id: 'group_timeline_sorting.new_title', defaultMessage: 'New Posts' },
newSubtitle: { id: 'group_timeline_sorting.new_subtitle', defaultMessage: 'See most recent gabs first' },
hotTitle: { id: 'group_timeline_sorting.hot_title', defaultMessage: 'Hot Posts' },
hotSubtitle: { id: 'group_timeline_sorting.hot_subtitle', defaultMessage: 'See the most popular and recent gabs' },
})
const mapStateToProps = (state) => ({
@@ -64,6 +67,13 @@ class GroupTimelineSortOptionsPopover extends PureComponent {
const isFeaturedTimeline = isObject(options) && options.collectionType === 'featured'
const items = [
{
hideArrow: true,
isActive: sorting === GROUP_TIMELINE_SORTING_TYPE_HOT,
title: intl.formatMessage(messages.hotTitle),
subtitle: intl.formatMessage(messages.hotSubtitle),
onClick: () => this.handleOnClick(GROUP_TIMELINE_SORTING_TYPE_HOT),
},
{
hideArrow: true,
isActive: sorting === GROUP_TIMELINE_SORTING_TYPE_TOP,

View File

@@ -125,6 +125,7 @@ export const STATUS_EXPIRATION_OPTION_24_HOURS = '24-hours'
export const STATUS_EXPIRATION_OPTION_3_DAYS = '3-days'
export const STATUS_EXPIRATION_OPTION_7_DAYS = '7-days'
export const GROUP_TIMELINE_SORTING_TYPE_HOT = 'hot'
export const GROUP_TIMELINE_SORTING_TYPE_NEWEST = 'newest'
export const GROUP_TIMELINE_SORTING_TYPE_RECENT_ACTIVITY = 'recent'
export const GROUP_TIMELINE_SORTING_TYPE_TOP = 'top'

View File

@@ -9,11 +9,9 @@ import {
} from '../actions/timelines'
import {
setGroupTimelineSort,
setGroupTimelineTopSort,
} from '../actions/groups'
import {
GROUP_TIMELINE_SORTING_TYPE_TOP,
GROUP_TIMELINE_SORTING_TYPE_TOP_OPTION_TODAY,
GROUP_TIMELINE_SORTING_TYPE_HOT,
GROUP_TIMELINE_SORTING_TYPE_NEWEST,
} from '../constants'
import getSortBy from '../utils/group_sort_by'
@@ -53,8 +51,7 @@ const mapDispatchToProps = (dispatch) => ({
dispatch(expandGroupCollectionTimeline(collectionType, options))
},
setFeaturedTop() {
dispatch(setGroupTimelineSort(GROUP_TIMELINE_SORTING_TYPE_TOP))
dispatch(setGroupTimelineTopSort(GROUP_TIMELINE_SORTING_TYPE_TOP_OPTION_TODAY))
dispatch(setGroupTimelineSort(GROUP_TIMELINE_SORTING_TYPE_HOT))
},
setMemberNewest() {
dispatch(setGroupTimelineSort(GROUP_TIMELINE_SORTING_TYPE_NEWEST))
@@ -115,7 +112,7 @@ class GroupCollectionTimeline extends PureComponent {
sortByTopValue,
} = this.props
if (this.props.collectionType === 'featured' && sortByValue !== GROUP_TIMELINE_SORTING_TYPE_TOP) {
if (this.props.collectionType === 'featured' && sortByValue !== GROUP_TIMELINE_SORTING_TYPE_HOT) {
this.props.setFeaturedTop()
} else if (!!me && this.props.collectionType === 'member' && sortByValue !== GROUP_TIMELINE_SORTING_TYPE_NEWEST) {
this.props.setMemberNewest()