Added group sorting to GroupCollection

• Added:
- group sorting to GroupCollection
- constants for group sorting
- GroupListSortOptionsPopover
This commit is contained in:
mgabdev
2020-07-24 21:41:05 -05:00
parent e9fbccaa12
commit 86ac15ce90
7 changed files with 152 additions and 55 deletions

View File

@@ -3,6 +3,7 @@ import {
GROUPS_FETCH_REQUEST,
GROUPS_FETCH_SUCCESS,
GROUPS_FETCH_FAIL,
GROUP_SORT,
} from '../actions/groups'
const tabs = ['new', 'featured', 'member', 'admin']
@@ -42,7 +43,6 @@ export default function groupLists(state = initialState, action) {
return state.withMutations((mutable) => {
let list = ImmutableList(action.groups.map(item => item.id))
if (action.tab === 'featured') list = list.sortBy(Math.random)
mutable.setIn([action.tab, 'items'], list)
mutable.setIn([action.tab, 'isLoading'], false)
mutable.setIn([action.tab, 'isFetched'], true)
@@ -53,6 +53,10 @@ export default function groupLists(state = initialState, action) {
mutable.setIn([action.tab, 'isLoading'], false)
mutable.setIn([action.tab, 'isFetched'], true)
})
case GROUP_SORT:
return state.withMutations((mutable) => {
mutable.setIn([action.tab, 'items'], ImmutableList(action.groupIds))
})
default:
return state
}