From 87a12c020f6b1c17bf90af91cc2afd18aec8b714 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Thu, 10 Oct 2024 19:03:46 -0400 Subject: [PATCH 1/3] convert "suspend deliver" button into a toggle --- packages/frontend/src/pages/instance-info.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/pages/instance-info.vue b/packages/frontend/src/pages/instance-info.vue index 3dc2b2878c..9b73df557a 100644 --- a/packages/frontend/src/pages/instance-info.vue +++ b/packages/frontend/src/pages/instance-info.vue @@ -46,9 +46,8 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.ts.deleteAllFiles }} {{ i18n.ts.severAllFollowRelations }} - {{ i18n.ts._delivery.stop }} - {{ i18n.ts._delivery.resume }}
+ {{ i18n.ts._delivery.stop }} {{ i18n.ts.blockedByBase }} {{ i18n.ts.blockThisInstance }} {{ i18n.ts.silencedByBase }} @@ -214,6 +213,11 @@ const isMediaSilenced = ref(false); const faviconUrl = ref(null); const moderationNote = ref(''); +const isSuspended = computed({ + get: () => suspensionState.value !== 'none', + set: value => value ? stopDelivery() : resumeDelivery(), +}); + const baseDomains = computed(() => { const domains: string[] = []; From 5a499550643ff8af5150614eab7a2ed74f0e01ae Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Thu, 10 Oct 2024 19:09:19 -0400 Subject: [PATCH 2/3] fix typo in "Server is suspended due to no responding" --- locales/en-US.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index e50a78e414..70c06ab326 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1359,7 +1359,7 @@ _delivery: none: "Publishing" manuallySuspended: "Manually suspended" goneSuspended: "Server is suspended due to server deletion" - autoSuspendedForNotResponding: "Server is suspended due to no responding" + autoSuspendedForNotResponding: "Server is suspended due to not responding" _bubbleGame: howToPlay: "How to play" hold: "Hold" From f496d4b88b7818fd8bd03909f952da7cd9e139c4 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Fri, 11 Oct 2024 10:16:57 -0400 Subject: [PATCH 3/3] re-implement suspension toggle to match other controls --- packages/frontend/src/pages/instance-info.vue | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/packages/frontend/src/pages/instance-info.vue b/packages/frontend/src/pages/instance-info.vue index 9b73df557a..e1a30a21b5 100644 --- a/packages/frontend/src/pages/instance-info.vue +++ b/packages/frontend/src/pages/instance-info.vue @@ -47,7 +47,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.deleteAllFiles }} {{ i18n.ts.severAllFollowRelations }} - {{ i18n.ts._delivery.stop }} + {{ i18n.ts._delivery.stop }} {{ i18n.ts.blockedByBase }} {{ i18n.ts.blockThisInstance }} {{ i18n.ts.silencedByBase }} @@ -205,6 +205,7 @@ const chartSrc = ref('instance-requests'); const meta = ref(null); const instance = ref(null); const suspensionState = ref<'none' | 'manuallySuspended' | 'goneSuspended' | 'autoSuspendedForNotResponding'>('none'); +const isSuspended = ref(false); const isBlocked = ref(false); const isSilenced = ref(false); const isNSFW = ref(false); @@ -213,11 +214,6 @@ const isMediaSilenced = ref(false); const faviconUrl = ref(null); const moderationNote = ref(''); -const isSuspended = computed({ - get: () => suspensionState.value !== 'none', - set: value => value ? stopDelivery() : resumeDelivery(), -}); - const baseDomains = computed(() => { const domains: string[] = []; @@ -276,6 +272,7 @@ async function fetch(): Promise { host: props.host, }); suspensionState.value = instance.value?.suspensionState ?? 'none'; + isSuspended.value = instance.value?.suspensionState !== 'none'; isBlocked.value = instance.value?.isBlocked ?? false; isSilenced.value = instance.value?.isSilenced ?? false; isNSFW.value = instance.value?.isNSFW ?? false; @@ -314,21 +311,12 @@ async function toggleMediaSilenced(): Promise { }); } -async function stopDelivery(): Promise { +async function toggleSuspended(): Promise { if (!instance.value) throw new Error('No instance?'); - suspensionState.value = 'manuallySuspended'; + suspensionState.value = isSuspended.value ? 'manuallySuspended' : 'none'; await misskeyApi('admin/federation/update-instance', { host: instance.value.host, - isSuspended: true, - }); -} - -async function resumeDelivery(): Promise { - if (!instance.value) throw new Error('No instance?'); - suspensionState.value = 'none'; - await misskeyApi('admin/federation/update-instance', { - host: instance.value.host, - isSuspended: false, + isSuspended: isSuspended.value, }); }