Skip to content

Commit

Permalink
fixup! fixup! fixup! WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bas080 committed Dec 17, 2023
1 parent 52a5487 commit ab83b59
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions browser/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ const tokenMatches = token => {
return issue => issue.textContent.includes(token)
}

const issueMatches = tokens => tokens.reduce((acc, token, index) => {
const prev = tokens[index - 1]

if (token === 'or') return acc

return (prev === 'or')
? or(acc, tokenMatches(token))
: and(acc, tokenMatches(token))
}, alwaysTrue)


state(
() => ({
query: getQueryParam('q') || '',
Expand All @@ -84,18 +95,8 @@ state(
return acc
}, {})

const issueMatches = state.tokens.reduce((acc, token, index) => {
const prev = state.tokens[index - 1]

if (token === 'or') return acc

return (prev === 'or')
? or(acc, tokenMatches(token))
: and(acc, tokenMatches(token))
}, alwaysTrue)

// What to do with things that are not a token?
state.matchedIssueElements = issues.filter(issueMatches)
state.matchedIssueElements = issues.filter(issueMatches(tokens))

search(state, push)
issuesFn(state)
Expand Down

0 comments on commit ab83b59

Please sign in to comment.