diff --git a/package.json b/package.json index 2014aafb9..b229b50bd 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "dompurify": "2.3.3", "easymde": "2.15.0", "flatpickr": "4.6.9", + "flexsearch": "^0.7.21", "highlight.js": "11.3.1", "is-touch-device": "1.0.1", "lodash.clonedeep": "4.5.0", @@ -54,6 +55,7 @@ "@fortawesome/free-regular-svg-icons": "5.15.4", "@fortawesome/free-solid-svg-icons": "5.15.4", "@fortawesome/vue-fontawesome": "3.0.0-5", + "@types/flexsearch": "^0.7.2", "@types/jest": "27.0.2", "@typescript-eslint/eslint-plugin": "5.3.1", "@typescript-eslint/parser": "5.3.1", @@ -81,8 +83,8 @@ "typescript": "4.4.4", "vite": "2.6.14", "vite-plugin-pwa": "0.11.5", - "vue-tsc": "0.29.4", "vite-svg-loader": "3.1.0", + "vue-tsc": "0.29.4", "wait-on": "6.0.0", "workbox-cli": "6.3.0" }, diff --git a/src/components/namespace/namespace-search.vue b/src/components/namespace/namespace-search.vue index cbe424d27..875583afd 100644 --- a/src/components/namespace/namespace-search.vue +++ b/src/components/namespace/namespace-search.vue @@ -25,15 +25,7 @@ export default { }, computed: { namespaces() { - if (this.query === '') { - return [] - } - - return this.$store.state.namespaces.namespaces.filter(n => { - return !n.isArchived && - n.id > 0 && - n.title.toLowerCase().includes(this.query.toLowerCase()) - }) + return this.$store.getters['namespaces/searchNamespace'](this.query) }, }, methods: { diff --git a/src/components/quick-actions/quick-actions.vue b/src/components/quick-actions/quick-actions.vue index 16a5a0342..3e8c38d14 100644 --- a/src/components/quick-actions/quick-actions.vue +++ b/src/components/quick-actions/quick-actions.vue @@ -110,40 +110,32 @@ export default { results() { let lists = [] if (this.searchMode === SEARCH_MODE_ALL || this.searchMode === SEARCH_MODE_LISTS) { - const ncache = {} - - const history = getHistory() - // Puts recently visited lists at the top - const allLists = [...new Set([ - ...history.map(l => { - return this.$store.getters['lists/getListById'](l.id) - }), - ...Object.values(this.$store.state.lists)])] - const {list} = this.parsedQuery if (list === null) { lists = [] } else { + const ncache = {} + const history = getHistory() + // Puts recently visited lists at the top + const allLists = [...new Set([ + ...history.map(l => { + return this.$store.getters['lists/getListById'](l.id) + }), + ...this.$store.getters['lists/searchList'](list), + ])] + lists = allLists.filter(l => { if (typeof l === 'undefined' || l === null) { return false } - if (l.isArchived) { - return false - } - if (typeof ncache[l.namespaceId] === 'undefined') { ncache[l.namespaceId] = this.$store.getters['namespaces/getNamespaceById'](l.namespaceId) } - if (ncache[l.namespaceId].isArchived) { - return false - } - - return l.title.toLowerCase().includes(list.toLowerCase()) - }) ?? [] + return !ncache[l.namespaceId].isArchived + }) } } diff --git a/src/components/tasks/partials/listSearch.vue b/src/components/tasks/partials/listSearch.vue index ea642f1f2..e05d52f8a 100644 --- a/src/components/tasks/partials/listSearch.vue +++ b/src/components/tasks/partials/listSearch.vue @@ -1,7 +1,6 @@