From 0fa2d2f267685d89751ffea480041deed10213d3 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Thu, 27 Aug 2020 01:07:20 +0300 Subject: [PATCH] Save tag policy status in state --- src/store/modules/users.js | 14 ++++++++++++++ src/views/users/index.vue | 1 + 2 files changed, 15 insertions(+) diff --git a/src/store/modules/users.js b/src/store/modules/users.js index 631bff8e..e0aa59d6 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -19,12 +19,14 @@ import { resendConfirmationEmail, updateUserCredentials } from '@/api/users' +import { fetchSettings } from '@/api/settings' const users = { state: { fetchedUsers: [], loading: true, searchQuery: '', + tagPolicyEnabled: true, totalUsersCount: 0, currentPage: 1, pageSize: 50, @@ -78,6 +80,9 @@ const users = { SET_SEARCH_QUERY: (state, query) => { state.searchQuery = query }, + SET_TAG_POLICY: (state, policyEnabled) => { + state.tagPolicyEnabled = policyEnabled + }, SET_USERS_FILTERS: (state, filters) => { state.filters = filters } @@ -206,6 +211,15 @@ const users = { } dispatch('SuccessMessage') }, + async FetchTagPolicySetting({ commit, getters }) { + const { data } = await fetchSettings(getters.authHost, getters.token) + const tagPolicyEnabled = data.configs + .find(el => el.key === ':mrf').value + .find(el => el.tuple[0] === ':policies').tuple[1] + .includes('Pleroma.Web.ActivityPub.MRF.TagPolicy') + + commit('SET_TAG_POLICY', tagPolicyEnabled) + }, async FetchUsers({ commit, dispatch, getters, state }, { page }) { commit('SET_LOADING', true) const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join() diff --git a/src/views/users/index.vue b/src/views/users/index.vue index ea892416..bd4ebb0a 100644 --- a/src/views/users/index.vue +++ b/src/views/users/index.vue @@ -198,6 +198,7 @@ export default { }, mounted: function() { this.$store.dispatch('NeedReboot') + this.$store.dispatch('FetchTagPolicySetting') this.$store.dispatch('FetchUsers', { page: 1 }) }, destroyed() {