mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
improve instanceMute setting.
This commit is contained in:
parent
dc53a1edf0
commit
b0b2a321f8
1 changed files with 13 additions and 10 deletions
|
@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch, computed } from 'vue';
|
||||||
import MkTextarea from '@/components/MkTextarea.vue';
|
import MkTextarea from '@/components/MkTextarea.vue';
|
||||||
import MkInfo from '@/components/MkInfo.vue';
|
import MkInfo from '@/components/MkInfo.vue';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
|
@ -26,8 +26,13 @@ import { i18n } from '@/i18n.js';
|
||||||
const $i = ensureSignin();
|
const $i = ensureSignin();
|
||||||
|
|
||||||
const instanceMutes = ref($i.mutedInstances.join('\n'));
|
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 changed = ref(false);
|
||||||
const autochange = ref(false);
|
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
const mutes = instanceMutes.value
|
const mutes = instanceMutes.value
|
||||||
|
@ -39,17 +44,15 @@ async function save() {
|
||||||
mutedInstances: mutes,
|
mutedInstances: mutes,
|
||||||
});
|
});
|
||||||
|
|
||||||
changed.value = false;
|
|
||||||
|
|
||||||
// Refresh filtered list to signal to the user how they've been saved
|
// Refresh filtered list to signal to the user how they've been saved
|
||||||
if (instanceMutes.value !== mutes.join('\n')) {
|
instanceMutes.value = domainArray.value.join('\n');
|
||||||
instanceMutes.value = mutes.join('\n');
|
|
||||||
autochange.value = true;
|
changed.value = false;
|
||||||
} else { autochange.value = false; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(instanceMutes, () => {
|
watch(domainArray, (newArray, oldArray) => {
|
||||||
if (!autochange.value) {
|
// compare arrays
|
||||||
|
if (newArray.length !== oldArray.length || !newArray.every((a, i) => a === oldArray[i])) {
|
||||||
changed.value = true;
|
changed.value = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue