diff options
| author | piuvas <mail@piuvas.net> | 2025-05-30 20:06:47 -0300 |
|---|---|---|
| committer | piuvas <mail@piuvas.net> | 2025-05-30 20:06:47 -0300 |
| commit | b0b2a321f8f79daa9009b0a920c2b40dc11de2ab (patch) | |
| tree | 21680243601e02514cd3f3b848b2f5f7d6c4f4f7 | |
| parent | generate types. (diff) | |
| download | sharkey-b0b2a321f8f79daa9009b0a920c2b40dc11de2ab.tar.gz sharkey-b0b2a321f8f79daa9009b0a920c2b40dc11de2ab.tar.bz2 sharkey-b0b2a321f8f79daa9009b0a920c2b40dc11de2ab.zip | |
improve instanceMute setting.
| -rw-r--r-- | packages/frontend/src/pages/settings/mute-block.instance-mute.vue | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/packages/frontend/src/pages/settings/mute-block.instance-mute.vue b/packages/frontend/src/pages/settings/mute-block.instance-mute.vue index 8671ec102d..862d66ad67 100644 --- a/packages/frontend/src/pages/settings/mute-block.instance-mute.vue +++ b/packages/frontend/src/pages/settings/mute-block.instance-mute.vue @@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only </template> <script lang="ts" setup> -import { ref, watch } from 'vue'; +import { ref, watch, computed } from 'vue'; import MkTextarea from '@/components/MkTextarea.vue'; import MkInfo from '@/components/MkInfo.vue'; import MkButton from '@/components/MkButton.vue'; @@ -26,8 +26,13 @@ import { i18n } from '@/i18n.js'; const $i = ensureSignin(); const instanceMutes = ref($i.mutedInstances.join('\n')); +const domainArray = computed(() => { + return instanceMutes.value + .trim().split('\n') + .map(el => el.trim().toLowerCase()) + .filter(el => el); +}); const changed = ref(false); -const autochange = ref(false); async function save() { const mutes = instanceMutes.value @@ -39,17 +44,15 @@ async function save() { mutedInstances: mutes, }); - changed.value = false; - // Refresh filtered list to signal to the user how they've been saved - if (instanceMutes.value !== mutes.join('\n')) { - instanceMutes.value = mutes.join('\n'); - autochange.value = true; - } else { autochange.value = false; } + instanceMutes.value = domainArray.value.join('\n'); + + changed.value = false; } -watch(instanceMutes, () => { - if (!autochange.value) { +watch(domainArray, (newArray, oldArray) => { + // compare arrays + if (newArray.length !== oldArray.length || !newArray.every((a, i) => a === oldArray[i])) { changed.value = true; } }); |