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) },