Skip to content

Commit

Permalink
Merge branch 'staging' into upgrade-electron-to-11
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Feb 12, 2021
2 parents f98453d + 87f7f7c commit c66daa4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/altair-app/package.json
Expand Up @@ -70,6 +70,7 @@
"express": "^4.17.1",
"file-dialog": "^0.0.8",
"file-saver": "^2.0.2",
"fuse.js": "^6.4.6",
"graphql": "^14.4.2",
"graphql-query-compress": "^1.2.2",
"loglevel": "^1.7.0",
Expand Down
13 changes: 10 additions & 3 deletions packages/altair-app/src/app/components/doc-viewer/doc-utils.ts
@@ -1,3 +1,4 @@
import Fuse from 'fuse.js';
import { GraphQLSchema } from 'graphql/type/schema';
import { DocumentIndexEntry } from './models';
import { buildSchema } from 'graphql/utilities';
Expand Down Expand Up @@ -149,12 +150,18 @@ export class DocUtils {
/**
* search through the docs for the provided term
*/
searchDocs(term: string) {
searchDocs(term: string): DocumentIndexEntry[] {
if (!this.searchIndex.length) {
return false;
return [];
}
const fuse = new Fuse(this.searchIndex, {
keys: [ 'search' ],
threshold: .4,
});

return fuse.search(term).map(res => res.item);

return this.searchIndex.filter(item => new RegExp(term as string, 'i').test(item.search));
// return this.searchIndex.filter(item => new RegExp(term as string, 'i').test(item.search));
}


Expand Down
5 changes: 5 additions & 0 deletions packages/altair-app/yarn.lock
Expand Up @@ -6062,6 +6062,11 @@ function-bind@^1.1.1:
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==

fuse.js@^6.4.6:
version "6.4.6"
resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-6.4.6.tgz#62f216c110e5aa22486aff20be7896d19a059b79"
integrity sha512-/gYxR/0VpXmWSfZOIPS3rWwU8SHgsRTwWuXhyb2O6s7aRuVtHtxCkR33bNYu3wyLyNx/Wpv0vU7FZy8Vj53VNw==

genfun@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/genfun/-/genfun-5.0.0.tgz#9dd9710a06900a5c4a5bf57aca5da4e52fe76537"
Expand Down

0 comments on commit c66daa4

Please sign in to comment.