2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
|
|
|
<div class="_section">
|
|
|
|
<div class="_card">
|
2020-11-17 06:59:15 +01:00
|
|
|
<MkTab v-model:value="tab">
|
|
|
|
<option value="soft">{{ $t('_wordMute.soft') }}</option>
|
|
|
|
<option value="hard">{{ $t('_wordMute.hard') }}</option>
|
|
|
|
</MkTab>
|
2020-10-17 13:12:00 +02:00
|
|
|
<div class="_content">
|
|
|
|
<div v-show="tab === 'soft'">
|
|
|
|
<MkInfo>{{ $t('_wordMute.softDescription') }}</MkInfo>
|
|
|
|
<MkTextarea v-model:value="softMutedWords">
|
|
|
|
<span>{{ $t('_wordMute.muteWords') }}</span>
|
|
|
|
<template #desc>{{ $t('_wordMute.muteWordsDescription') }}<br>{{ $t('_wordMute.muteWordsDescription2') }}</template>
|
|
|
|
</MkTextarea>
|
|
|
|
</div>
|
|
|
|
<div v-show="tab === 'hard'">
|
|
|
|
<MkInfo>{{ $t('_wordMute.hardDescription') }}</MkInfo>
|
|
|
|
<MkTextarea v-model:value="hardMutedWords" style="margin-bottom: 16px;">
|
|
|
|
<span>{{ $t('_wordMute.muteWords') }}</span>
|
|
|
|
<template #desc>{{ $t('_wordMute.muteWordsDescription') }}<br>{{ $t('_wordMute.muteWordsDescription2') }}</template>
|
|
|
|
</MkTextarea>
|
|
|
|
<div v-if="hardWordMutedNotesCount != null" class="_caption">{{ $t('_wordMute.mutedNotes') }}: {{ hardWordMutedNotesCount | number }}</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="_footer">
|
|
|
|
<MkButton @click="save()" primary inline :disabled="!changed"><Fa :icon="faSave"/> {{ $t('save') }}</MkButton>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
import { faCommentSlash, faSave } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkTextarea from '@/components/ui/textarea.vue';
|
|
|
|
import MkTab from '@/components/tab.vue';
|
|
|
|
import MkInfo from '@/components/ui/info.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
MkButton,
|
|
|
|
MkTextarea,
|
|
|
|
MkTab,
|
|
|
|
MkInfo,
|
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
INFO: {
|
2020-11-03 12:36:12 +01:00
|
|
|
title: this.$t('wordMute'),
|
|
|
|
icon: faCommentSlash
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
tab: 'soft',
|
|
|
|
softMutedWords: '',
|
|
|
|
hardMutedWords: '',
|
|
|
|
hardWordMutedNotesCount: null,
|
|
|
|
changed: false,
|
|
|
|
faSave,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
softMutedWords: {
|
|
|
|
handler() {
|
|
|
|
this.changed = true;
|
|
|
|
},
|
|
|
|
deep: true
|
|
|
|
},
|
|
|
|
hardMutedWords: {
|
|
|
|
handler() {
|
|
|
|
this.changed = true;
|
|
|
|
},
|
|
|
|
deep: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
async created() {
|
|
|
|
this.softMutedWords = this.$store.state.settings.mutedWords.map(x => x.join(' ')).join('\n');
|
|
|
|
this.hardMutedWords = this.$store.state.i.mutedWords.map(x => x.join(' ')).join('\n');
|
|
|
|
|
|
|
|
this.hardWordMutedNotesCount = (await os.api('i/get-word-muted-notes-count', {})).count;
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.$emit('info', this.INFO);
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async save() {
|
|
|
|
this.$store.dispatch('settings/set', { key: 'mutedWords', value: this.softMutedWords.trim().split('\n').map(x => x.trim().split(' ')) });
|
|
|
|
await os.api('i/update', {
|
|
|
|
mutedWords: this.hardMutedWords.trim().split('\n').map(x => x.trim().split(' ')),
|
|
|
|
});
|
|
|
|
this.changed = false;
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|