From 2511114c287d95010e15a08deb7ff20561b0c3b0 Mon Sep 17 00:00:00 2001
From: syuilo <Syuilotan@yahoo.co.jp>
Date: Mon, 10 Feb 2020 23:17:42 +0900
Subject: なんかもうめっちゃ変えた
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Resolve #5846
---
 src/client/pages/instance/federation.instance.vue | 34 +++++++++++------------
 1 file changed, 17 insertions(+), 17 deletions(-)

(limited to 'src/client/pages/instance/federation.instance.vue')

diff --git a/src/client/pages/instance/federation.instance.vue b/src/client/pages/instance/federation.instance.vue
index a27556064a..b86f52809e 100644
--- a/src/client/pages/instance/federation.instance.vue
+++ b/src/client/pages/instance/federation.instance.vue
@@ -98,7 +98,7 @@
 		<div class="operations">
 			<span class="label">{{ $t('operations') }}</span>
 			<mk-switch v-model="isSuspended" class="switch">{{ $t('stopActivityDelivery') }}</mk-switch>
-			<mk-switch v-model="isBlocked" class="switch">{{ $t('blockThisInstance') }}</mk-switch>
+			<mk-switch :value="isBlocked" class="switch" @change="changeBlock">{{ $t('blockThisInstance') }}</mk-switch>
 		</div>
 		<details class="metadata">
 			<summary class="label">{{ $t('metadata') }}</summary>
@@ -147,9 +147,7 @@ export default Vue.extend({
 
 	data() {
 		return {
-			meta: null,
-			isSuspended: false,
-			isBlocked: false,
+			isSuspended: this.instance.isSuspended,
 			now: null,
 			chart: null,
 			chartInstance: null,
@@ -184,6 +182,14 @@ export default Vue.extend({
 				null;
 
 			return stats;
+		},
+
+		meta() {
+			return this.$store.state.instance.meta;
+		},
+
+		isBlocked() {
+			return this.meta && this.meta.blockedHosts.includes(this.instance.host);
 		}
 	},
 
@@ -195,12 +201,6 @@ export default Vue.extend({
 			});
 		},
 
-		isBlocked() {
-			this.$root.api('admin/update-meta', {
-				blockedHosts: this.isBlocked ? this.meta.blockedHosts.concat([this.instance.host]) : this.meta.blockedHosts.filter(x => x !== this.instance.host)
-			});
-		},
-
 		chartSrc() {
 			this.renderChart();
 		},
@@ -210,13 +210,7 @@ export default Vue.extend({
 		}
 	},
 
-	async created() {
-		this.$root.getMeta().then(meta => {
-			this.meta = meta;
-			this.isSuspended = this.instance.isSuspended;
-			this.isBlocked = this.meta.blockedHosts.includes(this.instance.host);
-		});
-	
+	async created() {	
 		this.now = new Date();
 
 		const [perHour, perDay] = await Promise.all([
@@ -235,6 +229,12 @@ export default Vue.extend({
 	},
 
 	methods: {
+		changeBlock(e) {
+			this.$root.api('admin/update-meta', {
+				blockedHosts: this.isBlocked ? this.meta.blockedHosts.concat([this.instance.host]) : this.meta.blockedHosts.filter(x => x !== this.instance.host)
+			});
+		},
+
 		setSrc(src) {
 			this.chartSrc = src;
 		},
-- 
cgit v1.2.3-freya

