2020-10-17 14:12:00 +03:00
|
|
|
<template>
|
2020-11-25 14:31:34 +02:00
|
|
|
<div>
|
|
|
|
<MkTab v-model:value="tab">
|
|
|
|
<option value="soft">{{ $t('_wordMute.soft') }}</option>
|
|
|
|
<option value="hard">{{ $t('_wordMute.hard') }}</option>
|
|
|
|
</MkTab>
|
|
|
|
<FormBase>
|
|
|
|
<div class="_formItem">
|
2020-10-17 14:12:00 +03:00
|
|
|
<div v-show="tab === 'soft'">
|
|
|
|
<MkInfo>{{ $t('_wordMute.softDescription') }}</MkInfo>
|
2020-11-25 14:31:34 +02:00
|
|
|
<FormTextarea v-model:value="softMutedWords">
|
2020-10-17 14:12:00 +03:00
|
|
|
<span>{{ $t('_wordMute.muteWords') }}</span>
|
|
|
|
<template #desc>{{ $t('_wordMute.muteWordsDescription') }}<br>{{ $t('_wordMute.muteWordsDescription2') }}</template>
|
2020-11-25 14:31:34 +02:00
|
|
|
</FormTextarea>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
|
|
|
<div v-show="tab === 'hard'">
|
|
|
|
<MkInfo>{{ $t('_wordMute.hardDescription') }}</MkInfo>
|
2020-11-25 14:31:34 +02:00
|
|
|
<FormTextarea v-model:value="hardMutedWords">
|
2020-10-17 14:12:00 +03:00
|
|
|
<span>{{ $t('_wordMute.muteWords') }}</span>
|
|
|
|
<template #desc>{{ $t('_wordMute.muteWordsDescription') }}<br>{{ $t('_wordMute.muteWordsDescription2') }}</template>
|
2020-11-25 14:31:34 +02:00
|
|
|
</FormTextarea>
|
|
|
|
<FormKeyValueView v-if="hardWordMutedNotesCount != null">
|
|
|
|
<template #key>{{ $t('_wordMute.mutedNotes') }}</template>
|
|
|
|
<template #value>{{ number(hardWordMutedNotesCount) }}</template>
|
|
|
|
</FormKeyValueView>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-25 14:31:34 +02:00
|
|
|
<FormButton @click="save()" primary inline :disabled="!changed"><Fa :icon="faSave"/> {{ $t('save') }}</FormButton>
|
|
|
|
</FormBase>
|
2020-10-17 14:12:00 +03:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
import { faCommentSlash, faSave } from '@fortawesome/free-solid-svg-icons';
|
2020-11-25 14:31:34 +02:00
|
|
|
import FormTextarea from '@/components/form/textarea.vue';
|
|
|
|
import FormBase from '@/components/form/base.vue';
|
|
|
|
import FormKeyValueView from '@/components/form/key-value-view.vue';
|
|
|
|
import FormButton from '@/components/form/button.vue';
|
2020-10-17 14:12:00 +03:00
|
|
|
import MkTab from '@/components/tab.vue';
|
|
|
|
import MkInfo from '@/components/ui/info.vue';
|
|
|
|
import * as os from '@/os';
|
2020-11-25 14:31:34 +02:00
|
|
|
import number from '@/filters/number';
|
2020-10-17 14:12:00 +03:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-11-25 14:31:34 +02:00
|
|
|
FormBase,
|
|
|
|
FormButton,
|
|
|
|
FormTextarea,
|
|
|
|
FormKeyValueView,
|
2020-10-17 14:12:00 +03:00
|
|
|
MkTab,
|
|
|
|
MkInfo,
|
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
INFO: {
|
2020-11-03 13:36:12 +02:00
|
|
|
title: this.$t('wordMute'),
|
|
|
|
icon: faCommentSlash
|
2020-10-17 14:12:00 +03: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() {
|
2020-12-19 03:55:52 +02:00
|
|
|
this.softMutedWords = this.$store.state.mutedWords.map(x => x.join(' ')).join('\n');
|
|
|
|
this.hardMutedWords = this.$i.mutedWords.map(x => x.join(' ')).join('\n');
|
2020-10-17 14:12:00 +03:00
|
|
|
|
|
|
|
this.hardWordMutedNotesCount = (await os.api('i/get-word-muted-notes-count', {})).count;
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.$emit('info', this.INFO);
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async save() {
|
2020-12-19 03:55:52 +02:00
|
|
|
this.$store.set('mutedWords', this.softMutedWords.trim().split('\n').map(x => x.trim().split(' ')));
|
2020-10-17 14:12:00 +03:00
|
|
|
await os.api('i/update', {
|
|
|
|
mutedWords: this.hardMutedWords.trim().split('\n').map(x => x.trim().split(' ')),
|
|
|
|
});
|
|
|
|
this.changed = false;
|
|
|
|
},
|
2020-11-25 14:31:34 +02:00
|
|
|
|
|
|
|
number
|
2020-10-17 14:12:00 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|