Added new sorting for "Hot" in GroupCollection, GroupTimeline
• Added: - new sorting for "Hot" in GroupCollection, GroupTimeline
This commit is contained in:
parent
5f6a2e9cab
commit
b2c69afdbd
@ -33,6 +33,7 @@ class Api::V1::Timelines::GroupCollectionController < Api::BaseController
|
||||
def set_sort_type
|
||||
@sort_type = 'newest'
|
||||
@sort_type = params[:sort_by] if [
|
||||
'hot',
|
||||
'newest',
|
||||
'recent',
|
||||
'top_today',
|
||||
@ -43,7 +44,7 @@ class Api::V1::Timelines::GroupCollectionController < Api::BaseController
|
||||
].include? params[:sort_by]
|
||||
|
||||
if @collection_type === 'featured' && (@sort_type == 'newest' || @sort_type == 'recent')
|
||||
@sort_type = 'top_today'
|
||||
@sort_type = 'hot'
|
||||
end
|
||||
|
||||
return @sort_type
|
||||
@ -72,7 +73,12 @@ class Api::V1::Timelines::GroupCollectionController < Api::BaseController
|
||||
date_limit = 30.days.ago
|
||||
top_order = 'status_stats.favourites_count DESC, status_stats.reblogs_count DESC, status_stats.replies_count DESC'
|
||||
|
||||
if @sort_type == 'top_today'
|
||||
if @sort_type == 'hot'
|
||||
# : todo :
|
||||
# unique groups
|
||||
# unique users
|
||||
date_limit = 8.hours.ago
|
||||
elsif @sort_type == 'top_today'
|
||||
date_limit = 24.hours.ago
|
||||
elsif @sort_type == 'top_weekly'
|
||||
date_limit = 7.days.ago
|
||||
@ -99,7 +105,7 @@ class Api::V1::Timelines::GroupCollectionController < Api::BaseController
|
||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
||||
params_slice(:max_id, :since_id, :min_id)
|
||||
).reject { |status| FeedManager.instance.filter?(:home, status, current_account.id) }
|
||||
elsif ['top_today', 'top_weekly', 'top_monthly', 'top_yearly', 'top_all_time'].include? @sort_type
|
||||
elsif ['top_today', 'top_weekly', 'top_monthly', 'top_yearly', 'top_all_time', 'hot'].include? @sort_type
|
||||
if @sort_type == 'top_all_time'
|
||||
statuses = Status.unscoped.where(
|
||||
group: @groupIds, reply: false
|
||||
@ -133,7 +139,7 @@ class Api::V1::Timelines::GroupCollectionController < Api::BaseController
|
||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
||||
params_slice(:max_id, :since_id, :min_id)
|
||||
)
|
||||
elsif ['top_today', 'top_weekly', 'top_monthly', 'top_yearly', 'top_all_time'].include? @sort_type
|
||||
elsif ['top_today', 'top_weekly', 'top_monthly', 'top_yearly', 'top_all_time', 'hot'].include? @sort_type
|
||||
if @sort_type == 'top_all_time'
|
||||
statuses = Status.unscoped.where(
|
||||
group: @groupIds, reply: false
|
||||
|
@ -22,6 +22,7 @@ class Api::V1::Timelines::GroupController < Api::BaseController
|
||||
def set_sort_type
|
||||
@sort_type = 'newest'
|
||||
@sort_type = params[:sort_by] if [
|
||||
'hot',
|
||||
'newest',
|
||||
'recent',
|
||||
'top_today',
|
||||
@ -52,7 +53,12 @@ class Api::V1::Timelines::GroupController < Api::BaseController
|
||||
date_limit = 30.days.ago
|
||||
top_order = 'status_stats.favourites_count DESC, status_stats.reblogs_count DESC, status_stats.replies_count DESC'
|
||||
|
||||
if @sort_type == 'top_today'
|
||||
if @sort_type == 'hot'
|
||||
# : todo :
|
||||
# unique groups
|
||||
# unique users
|
||||
date_limit = 8.hours.ago
|
||||
elsif @sort_type == 'top_today'
|
||||
date_limit = 24.hours.ago
|
||||
elsif @sort_type == 'top_weekly'
|
||||
date_limit = 7.days.ago
|
||||
@ -79,7 +85,7 @@ class Api::V1::Timelines::GroupController < Api::BaseController
|
||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
||||
params_slice(:max_id, :since_id, :min_id)
|
||||
).reject { |status| FeedManager.instance.filter?(:home, status, current_account.id) }
|
||||
elsif ['top_today', 'top_weekly', 'top_monthly', 'top_yearly', 'top_all_time'].include? @sort_type
|
||||
elsif ['top_today', 'top_weekly', 'top_monthly', 'top_yearly', 'top_all_time', 'hot'].include? @sort_type
|
||||
if @sort_type == 'top_all_time'
|
||||
statuses = Status.unscoped.where(
|
||||
group: @group, reply: false
|
||||
@ -116,7 +122,7 @@ class Api::V1::Timelines::GroupController < Api::BaseController
|
||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
||||
params_slice(:max_id, :since_id, :min_id)
|
||||
)
|
||||
elsif ['top_today', 'top_weekly', 'top_monthly', 'top_yearly', 'top_all_time'].include? @sort_type
|
||||
elsif ['top_today', 'top_weekly', 'top_monthly', 'top_yearly', 'top_all_time', 'hot'].include? @sort_type
|
||||
if @sort_type == 'top_all_time'
|
||||
statuses = Status.unscoped.where(
|
||||
group: @group, reply: false
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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'
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user