🚧 Avoid duplicated returns

This commit is contained in:
Kevin van der Werff
2019-11-07 00:18:13 +01:00
parent 23d97f00b1
commit 35a11766d8
2 changed files with 13 additions and 9 deletions

View File

@@ -52,6 +52,12 @@ export const getters = {
return getDesiredResources(state.resources)
},
findBySearchInputs: (_, getters) => (keywords = [], tags = []) => {
const foundByKeywords = getters.findByName(keywords)
const foundByTags = getters.findByTags(tags)
const uniqueResources = foundByTags.filter(x => !foundByKeywords.some(y => equalResources(x, y)))
return uniqueResources.concat(foundByKeywords)
},
sortByTitle: (_, getters) => title => {
const category = getters.findCategory(title)
const clone = [...category.resources]
@@ -70,4 +76,8 @@ const compareTitles = (x, y) => {
} else {
return 0
}
}
}
const equalResources = (a, b) =>
a.title === b.title &&
a.cleanTitle == b.cleanTitle