From fa38a41e42dbbbd5aa9d1aa2efb107d99ce8cd7d Mon Sep 17 00:00:00 2001 From: Shpuld Shpludson Date: Mon, 2 Dec 2019 12:20:24 +0000 Subject: [PATCH] fix "can't find property of undefined" errors in mrf transparency panel --- .../mrf_transparency_panel.js | 31 +++++++++++++------ .../mrf_transparency_panel.vue | 4 ++- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/components/mrf_transparency_panel/mrf_transparency_panel.js b/src/components/mrf_transparency_panel/mrf_transparency_panel.js index 20f8a08a..6a1baec8 100644 --- a/src/components/mrf_transparency_panel/mrf_transparency_panel.js +++ b/src/components/mrf_transparency_panel/mrf_transparency_panel.js @@ -1,16 +1,27 @@ import { mapState } from 'vuex' +import { get } from 'lodash' const MRFTransparencyPanel = { - computed: mapState({ - federationPolicy: state => state.instance.federationPolicy, - mrfPolicies: state => state.instance.federationPolicy.mrf_policies, - acceptInstances: state => state.instance.federationPolicy.mrf_simple.accept, - rejectInstances: state => state.instance.federationPolicy.mrf_simple.reject, - quarantineInstances: state => state.instance.federationPolicy.quarantined_instances, - ftlRemovalInstances: state => state.instance.federationPolicy.mrf_simple.federated_timeline_removal, - mediaNsfwInstances: state => state.instance.federationPolicy.mrf_simple.media_nsfw, - mediaRemovalInstances: state => state.instance.federationPolicy.mrf_simple.media_removal - }) + computed: { + ...mapState({ + federationPolicy: state => get(state, 'instance.federationPolicy'), + mrfPolicies: state => get(state, 'instance.federationPolicy.mrf_policies', []), + quarantineInstances: state => get(state, 'instance.federationPolicy.quarantined_instances', []), + acceptInstances: state => get(state, 'instance.federationPolicy.mrf_simple.accept', []), + rejectInstances: state => get(state, 'instance.federationPolicy.mrf_simple.reject', []), + ftlRemovalInstances: state => get(state, 'instance.federationPolicy.mrf_simple.federated_timeline_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 diff --git a/src/components/mrf_transparency_panel/mrf_transparency_panel.vue b/src/components/mrf_transparency_panel/mrf_transparency_panel.vue index 2640d68c..d6495dc6 100644 --- a/src/components/mrf_transparency_panel/mrf_transparency_panel.vue +++ b/src/components/mrf_transparency_panel/mrf_transparency_panel.vue @@ -22,7 +22,9 @@ /> -

{{ $t("about.mrf_policy_simple") }}

+

+ {{ $t("about.mrf_policy_simple") }} +

{{ $t("about.mrf_policy_simple_accept") }}