Skip to content

Commit

Permalink
fix live note counts when multiple tags are selected
Browse files Browse the repository at this point in the history
  • Loading branch information
daiyam committed Aug 27, 2018
1 parent 7cde30d commit 5006aaa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions browser/main/SideNav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {SortableContainer} from 'react-sortable-hoc'
import i18n from 'browser/lib/i18n'
import context from 'browser/lib/context'

function findOne (haystack, arr) {
return arr.some(v => haystack.indexOf(v) >= 0)
function matchActiveTags (tags, activeTags) {
return _.every(activeTags, v => tags.indexOf(v) >= 0)
}

class SideNav extends React.Component {
Expand Down Expand Up @@ -158,7 +158,7 @@ class SideNav extends React.Component {
if (config.ui.enableLiveNoteCounts && activeTags.length !== 0) {
const notesTags = data.noteMap.map(note => note.tags)
tagList = tagList.map(tag => {
tag.size = notesTags.filter(tags => tags.includes(tag.name) && findOne(tags, activeTags)).length
tag.size = notesTags.filter(tags => tags.includes(tag.name) && matchActiveTags(tags, activeTags)).length
return tag
})
}
Expand Down

0 comments on commit 5006aaa

Please sign in to comment.