aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfenn-cs <fenn25.fn@gmail.com>2024-02-19 11:23:28 +0100
committerfenn-cs <fenn25.fn@gmail.com>2024-03-06 02:05:51 +0100
commit647f4bc1c8c92fd41c8e98555da0cd0aee817a54 (patch)
treeb724a57431fd51316a6ac476be4cf0bdd0f633a8
parentd35a49caba0ec1b8ff2857b77b9471ea53076838 (diff)
downloadnextcloud-server-647f4bc1c8c92fd41c8e98555da0cd0aee817a54.tar.gz
nextcloud-server-647f4bc1c8c92fd41c8e98555da0cd0aee817a54.zip
refactor: migrate from vuex to pinia
Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
-rw-r--r--core/src/store/index.js11
-rw-r--r--core/src/store/unified-search-external-filters.js30
-rw-r--r--core/src/unified-search.js19
-rw-r--r--core/src/views/UnifiedSearchModal.vue8
4 files changed, 24 insertions, 44 deletions
diff --git a/core/src/store/index.js b/core/src/store/index.js
deleted file mode 100644
index d263a5dc407..00000000000
--- a/core/src/store/index.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import search from './unified-search-external-filters';
-
-Vue.use(Vuex);
-
-export default new Vuex.Store({
- modules: {
- search,
- },
-});
diff --git a/core/src/store/unified-search-external-filters.js b/core/src/store/unified-search-external-filters.js
index 45d0f4c7090..3a8cd2aca2d 100644
--- a/core/src/store/unified-search-external-filters.js
+++ b/core/src/store/unified-search-external-filters.js
@@ -19,24 +19,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-const state = {
- externalFilters: [],
-}
+import { defineStore } from 'pinia'
-const mutations = {
- registerExternalFilter(state, { id, label, callback, icon }) {
- state.externalFilters.push({ id, name: label, callback, icon, isPluginFilter: true })
- },
-}
+export const useSearchStore = defineStore({
+ id: 'search',
-const actions = {
- registerExternalFilter({ commit }, { id, label, callback, icon }) {
- commit('registerExternalFilter', { id, label, callback, icon })
- },
-}
+ state: () => ({
+ externalFilters: [],
+ }),
-export default {
- state,
- mutations,
- actions,
-}
+ actions: {
+ registerExternalFilter({ id, appId, label, callback, icon }) {
+ this.externalFilters.push({ id, appId, name: label, callback, icon, isPluginFilter: true })
+ },
+ },
+})
diff --git a/core/src/unified-search.js b/core/src/unified-search.js
index 3d7ead37cbb..4be923085d3 100644
--- a/core/src/unified-search.js
+++ b/core/src/unified-search.js
@@ -23,10 +23,11 @@
import { getLoggerBuilder } from '@nextcloud/logger'
import { getRequestToken } from '@nextcloud/auth'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
+import { createPinia, PiniaVuePlugin } from 'pinia'
import Vue from 'vue'
import UnifiedSearch from './views/UnifiedSearch.vue'
-import store from '../src/store/index.js'
+import { useSearchStore } from '../src/store/unified-search-external-filters.js'
// eslint-disable-next-line camelcase
__webpack_nonce__ = btoa(getRequestToken())
@@ -51,21 +52,19 @@ Vue.mixin({
// Register the add/register filter action API globally
window.OCA = window.OCA || {}
window.OCA.UnifiedSearch = {
- registerFilterAction: ({ id, name, label, callback, icon }) => {
- store.dispatch('registerExternalFilter', {
- id,
- name,
- label,
- icon,
- callback,
- })
+ registerFilterAction: ({ id, appId, label, callback, icon }) => {
+ const searchStore = useSearchStore()
+ searchStore.registerExternalFilter({ id, appId, label, callback, icon })
},
}
+Vue.use(PiniaVuePlugin)
+const pinia = createPinia()
+
export default new Vue({
el: '#unified-search',
+ pinia,
// eslint-disable-next-line vue/match-component-file-name
name: 'UnifiedSearchRoot',
- store,
render: h => h(UnifiedSearch),
})
diff --git a/core/src/views/UnifiedSearchModal.vue b/core/src/views/UnifiedSearchModal.vue
index 881e49d6405..b33cebed8e2 100644
--- a/core/src/views/UnifiedSearchModal.vue
+++ b/core/src/views/UnifiedSearchModal.vue
@@ -154,8 +154,8 @@ import SearchResult from '../components/UnifiedSearch/SearchResult.vue'
import debounce from 'debounce'
import { emit, subscribe } from '@nextcloud/event-bus'
import { useBrowserLocation } from '@vueuse/core'
-import { mapState } from 'vuex'
import { getProviders, search as unifiedSearch, getContacts } from '../services/UnifiedSearchService.js'
+import { useSearchStore } from '../store/unified-search-external-filters.js'
export default {
name: 'UnifiedSearchModal',
@@ -190,8 +190,10 @@ export default {
* Reactive version of window.location
*/
const currentLocation = useBrowserLocation()
+ const searchStore = useSearchStore()
return {
currentLocation,
+ externalFilters: searchStore.externalFilters,
}
},
data() {
@@ -220,9 +222,6 @@ export default {
},
computed: {
- ...mapState({
- externalFilters: state => state.search.externalFilters,
- }),
userContacts() {
return this.contacts
},
@@ -577,7 +576,6 @@ export default {
break
}
}
- console.debug('Search scope set to conversation', addFilterEvent)
this.debouncedFind(this.searchQuery)
},
groupProvidersByApp(filters) {