mirror of
https://github.com/He4eT/tabswitcher.git
synced 2026-05-05 01:17:23 +00:00
pages/search: enable fuzzy search
This commit is contained in:
parent
499bd4dceb
commit
b7de8393a7
2 changed files with 7 additions and 7 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import * as labels from './labels.js'
|
||||
const fuzzysort = window.fuzzysort
|
||||
|
||||
export const init = ({
|
||||
tabs: browserTabs,
|
||||
|
|
@ -42,17 +43,15 @@ export const init = ({
|
|||
browserTabs.query({ currentWindow: true, active: false })
|
||||
.then(shapeTabs)
|
||||
.then((tabs) => tabs.reverse())
|
||||
.then((tabs) => {
|
||||
void (state.tabs = tabs)
|
||||
void (state.results = tabs)
|
||||
})
|
||||
.then((tabs) => void (state.tabs = tabs))
|
||||
|
||||
/* */
|
||||
|
||||
const updateResults = () => {
|
||||
state.results = state.query.length === 0
|
||||
? state.tabs
|
||||
: []
|
||||
state.results = fuzzysort.go(state.query, state.tabs, {
|
||||
keys: ['label', 'title', 'url'],
|
||||
all: true,
|
||||
}).map(({obj}) => obj)
|
||||
}
|
||||
/* */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue