Fix fetching MRF data in case it's undefined

This commit is contained in:
Angelina Filippova 2020-09-05 23:41:06 +03:00
parent 767322c355
commit dd88974338
2 changed files with 7 additions and 4 deletions

View file

@ -223,9 +223,12 @@ const users = {
},
async FetchTagPolicySetting({ commit, getters }) {
const { data } = await fetchSettings(getters.authHost, getters.token)
const mrfPolicies = data.configs
.find(el => el.key === ':mrf').value
.find(el => el.tuple[0] === ':policies').tuple[1] || []
const mrfSettings = data.configs.find(el => el.key === ':mrf')
? data.configs.find(el => el.key === ':mrf').value
: []
const mrfPolicies = mrfSettings.find(el => el.tuple[0] === ':policies')
? mrfSettings.find(el => el.tuple[0] === ':policies').tuple[1]
: []
commit('SET_TAG_POLICY', Array.isArray(mrfPolicies) ? mrfPolicies : [mrfPolicies])
},

View file

@ -69,7 +69,7 @@ export default {
})
},
showMrfPolicy(key) {
const selectedMrfPolicies = _.get(this.settings.settings, [':pleroma', ':mrf', ':policies'])
const selectedMrfPolicies = _.get(this.settings.settings, [':pleroma', ':mrf', ':policies']) || []
const mappedPolicies = this.mrfSettings.reduce((acc, { key, related_policy }) => {
if (key !== ':mrf') {
acc[key] = related_policy