Skip to content

Commit

Permalink
Implements fuzzy search #1103
Browse files Browse the repository at this point in the history
  • Loading branch information
amir20 committed Mar 26, 2021
1 parent af5ce38 commit 0c59422
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion assets/pages/Index.vue
Expand Up @@ -74,6 +74,7 @@ import { mapActions, mapGetters, mapState } from "vuex";
import Icon from "../components/Icon";
import PastTime from "../components/PastTime";
import config from "../store/config";
import fuzzysort from "fuzzysort";
export default {
name: "Index",
Expand Down Expand Up @@ -107,7 +108,7 @@ export default {
results() {
if (this.search) {
const term = this.search.toLowerCase();
return this.allContainers.filter((c) => c.name.toLowerCase().includes(term));
return fuzzysort.go(term, this.allContainers, { key: "name" }).map((i) => i.obj);
}
switch (this.sort) {
case "all":
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -32,6 +32,7 @@
"bulma": "^0.9.2",
"date-fns": "^2.19.0",
"dompurify": "^2.2.7",
"fuzzysort": "^1.1.4",
"hotkeys-js": "^3.8.3",
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -4029,6 +4029,11 @@ function-bind@^1.1.1:
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==

fuzzysort@^1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/fuzzysort/-/fuzzysort-1.1.4.tgz#a0510206ed44532cbb52cf797bf5a3cb12acd4ba"
integrity sha512-JzK/lHjVZ6joAg3OnCjylwYXYVjRiwTY6Yb25LvfpJHK8bjisfnZJ5bY8aVWwTwCXgxPNgLAtmHL+Hs5q1ddLQ==

gensync@^1.0.0-beta.2:
version "1.0.0-beta.2"
resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0"
Expand Down

0 comments on commit 0c59422

Please sign in to comment.