Merge branch 'fix/mrf-js-errors' into 'develop'

fix "can't find property of undefined" errors in mrf transparency panel

See merge request pleroma/pleroma-fe!1008
This commit is contained in:
Shpuld Shpludson 2019-12-02 12:20:25 +00:00
commit 5096bff16c
2 changed files with 24 additions and 11 deletions

View File

@ -1,16 +1,27 @@
import { mapState } from 'vuex' import { mapState } from 'vuex'
import { get } from 'lodash'
const MRFTransparencyPanel = { const MRFTransparencyPanel = {
computed: mapState({ computed: {
federationPolicy: state => state.instance.federationPolicy, ...mapState({
mrfPolicies: state => state.instance.federationPolicy.mrf_policies, federationPolicy: state => get(state, 'instance.federationPolicy'),
acceptInstances: state => state.instance.federationPolicy.mrf_simple.accept, mrfPolicies: state => get(state, 'instance.federationPolicy.mrf_policies', []),
rejectInstances: state => state.instance.federationPolicy.mrf_simple.reject, quarantineInstances: state => get(state, 'instance.federationPolicy.quarantined_instances', []),
quarantineInstances: state => state.instance.federationPolicy.quarantined_instances, acceptInstances: state => get(state, 'instance.federationPolicy.mrf_simple.accept', []),
ftlRemovalInstances: state => state.instance.federationPolicy.mrf_simple.federated_timeline_removal, rejectInstances: state => get(state, 'instance.federationPolicy.mrf_simple.reject', []),
mediaNsfwInstances: state => state.instance.federationPolicy.mrf_simple.media_nsfw, ftlRemovalInstances: state => get(state, 'instance.federationPolicy.mrf_simple.federated_timeline_removal', []),
mediaRemovalInstances: state => state.instance.federationPolicy.mrf_simple.media_removal mediaNsfwInstances: state => get(state, 'instance.federationPolicy.mrf_simple.media_nsfw', []),
}) mediaRemovalInstances: state => get(state, 'instance.federationPolicy.mrf_simple.media_removal', [])
}),
hasInstanceSpecificPolicies () {
return this.quarantineInstances.length ||
this.acceptInstances.length ||
this.rejectInstances.length ||
this.ftlRemovalInstances.length ||
this.mediaNsfwInstances.length ||
this.mediaRemovalInstances.length
}
}
} }
export default MRFTransparencyPanel export default MRFTransparencyPanel

View File

@ -22,7 +22,9 @@
/> />
</ul> </ul>
<h2>{{ $t("about.mrf_policy_simple") }}</h2> <h2 v-if="hasInstanceSpecificPolicies">
{{ $t("about.mrf_policy_simple") }}
</h2>
<div v-if="acceptInstances.length"> <div v-if="acceptInstances.length">
<h4>{{ $t("about.mrf_policy_simple_accept") }}</h4> <h4>{{ $t("about.mrf_policy_simple_accept") }}</h4>