Skip to content

Commit 0300a5f

Browse files
Merge pull request #1202 from nextcloud/fix/1171/unified-search
Adjust app to unified search in NC20
2 parents 4d990b4 + b16a649 commit 0300a5f

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"dependencies": {
3030
"@nextcloud/axios": "^1.3.3",
3131
"@nextcloud/dialogs": "^2.0.1",
32+
"@nextcloud/event-bus": "^1.2.0",
3233
"@nextcloud/initial-state": "1.1.2",
3334
"@nextcloud/moment": "^1.1.1",
3435
"@nextcloud/router": "^1.1.0",

src/main.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import VTooltip from 'v-tooltip'
3131
import VueClipboard from 'vue-clipboard2'
3232
import { linkTo } from '@nextcloud/router'
3333

34+
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
35+
3436
// Disable on production
3537
Vue.config.devtools = true
3638
Vue.config.performance = true
@@ -83,13 +85,28 @@ OCA.Tasks.App = new Vue({
8385
}
8486
},
8587
mounted() {
86-
this.$OC.Search = new OCA.Search(this.filter, this.cleanSearch)
88+
const version = this.$OC.config.version.split('.')
89+
90+
if (version[0] >= 20) {
91+
// Hook to new global event for unified search
92+
subscribe('nextcloud:unified-search:search', this.filterProxy)
93+
subscribe('nextcloud:unified-search:close', this.cleanSearch)
94+
} else {
95+
this.$OC.Search = new OCA.Search(this.filter, this.cleanSearch)
96+
}
8797
},
8898
beforeMount() {
8999
this.$store.dispatch('loadCollections')
90100
this.$store.dispatch('loadSettings')
91101
},
102+
beforeDestroy() {
103+
unsubscribe('nextcloud:unified-search:search', this.filterProxy)
104+
unsubscribe('nextcloud:unified-search:close', this.cleanSearch)
105+
},
92106
methods: {
107+
filterProxy({ query }) {
108+
this.filter(query)
109+
},
93110
filter(query) {
94111
this.$store.commit('setSearchQuery', query)
95112
},

0 commit comments

Comments
 (0)