From b16a649dd9501c7b3e960b2a4b077ab3a7cc3292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimund=20Schl=C3=BC=C3=9Fler?= Date: Sat, 29 Aug 2020 11:05:33 +0200 Subject: [PATCH] Adjust app to unified search in NC20 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raimund Schlüßler --- package.json | 1 + src/main.js | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 54827a8f6..d6539c1ac 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "dependencies": { "@nextcloud/axios": "^1.3.3", "@nextcloud/dialogs": "^2.0.1", + "@nextcloud/event-bus": "^1.2.0", "@nextcloud/initial-state": "1.1.2", "@nextcloud/moment": "^1.1.1", "@nextcloud/router": "^1.1.0", diff --git a/src/main.js b/src/main.js index 72982bc91..0d05f0941 100644 --- a/src/main.js +++ b/src/main.js @@ -31,6 +31,8 @@ import VTooltip from 'v-tooltip' import VueClipboard from 'vue-clipboard2' import { linkTo } from '@nextcloud/router' +import { subscribe, unsubscribe } from '@nextcloud/event-bus' + // Disable on production Vue.config.devtools = true Vue.config.performance = true @@ -83,13 +85,28 @@ OCA.Tasks.App = new Vue({ } }, mounted() { - this.$OC.Search = new OCA.Search(this.filter, this.cleanSearch) + const version = this.$OC.config.version.split('.') + + if (version[0] >= 20) { + // Hook to new global event for unified search + subscribe('nextcloud:unified-search:search', this.filterProxy) + subscribe('nextcloud:unified-search:close', this.cleanSearch) + } else { + this.$OC.Search = new OCA.Search(this.filter, this.cleanSearch) + } }, beforeMount() { this.$store.dispatch('loadCollections') this.$store.dispatch('loadSettings') }, + beforeDestroy() { + unsubscribe('nextcloud:unified-search:search', this.filterProxy) + unsubscribe('nextcloud:unified-search:close', this.cleanSearch) + }, methods: { + filterProxy({ query }) { + this.filter(query) + }, filter(query) { this.$store.commit('setSearchQuery', query) },