Pass tag names to tagsSorter instead of taggedOperations values

This commit is contained in:
Kyle Shockey
2017-07-13 21:02:37 -07:00
parent 1cdc4691f7
commit e6c8eb3c61
2 changed files with 8 additions and 6 deletions

View File

@@ -202,12 +202,14 @@ export const operationsWithTags = createSelector(
export const taggedOperations = (state) => ({ getConfigs }) => {
let { tagsSorter, operationsSorter } = getConfigs()
return operationsWithTags(state)
.sort((operationA, operationB) => {
let sortFn = (typeof tagsSorter === "function" ? tagsSorter : sorters.tagsSorter[ tagsSorter ])
return (!sortFn ? null : sortFn(operationA, operationB))
})
.sortBy(
(val, key) => key, // get the name of the tag to be passed to the sorter
(tagA, tagB) => {
let sortFn = (typeof tagsSorter === "function" ? tagsSorter : sorters.tagsSorter[ tagsSorter ])
return (!sortFn ? null : sortFn(tagA, tagB))
}
)
.map((ops, tag) => {
let sortFn = (typeof operationsSorter === "function" ? operationsSorter : sorters.operationsSorter[ operationsSorter ])
let operations = (!sortFn ? ops : ops.sort(sortFn))