summaryrefslogtreecommitdiff
path: root/packages/client/src/pages/settings/instance-mute.vue
blob: f84a209b60edf1f6ff0b1c23402281ede28d00df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
<div class="_formRoot">
	<MkInfo>{{ $ts._instanceMute.title }}</MkInfo>
	<FormTextarea v-model="instanceMutes" class="_formBlock">
		<template #label>{{ $ts._instanceMute.heading }}</template>
		<template #caption>{{ $ts._instanceMute.instanceMuteDescription }}<br>{{ $ts._instanceMute.instanceMuteDescription2 }}</template>
	</FormTextarea>
	<MkButton primary :disabled="!changed" class="_formBlock" @click="save()"><i class="fas fa-save"></i> {{ $ts.save }}</MkButton>
</div>
</template>

<script>
import { defineComponent } from 'vue';
import FormTextarea from '@/components/form/textarea.vue';
import MkInfo from '@/components/ui/info.vue';
import MkButton from '@/components/ui/button.vue';
import * as os from '@/os';
import * as symbols from '@/symbols';

export default defineComponent({
	components: {
		MkButton,
		FormTextarea,
		MkInfo,
	},

	emits: ['info'],

	data() {
		return {
			[symbols.PAGE_INFO]: {
				title: this.$ts.instanceMute,
				icon: 'fas fa-volume-mute'
			},
			tab: 'soft',
			instanceMutes: '',
			changed: false,
		}
	},

	watch: {
		instanceMutes: {
			handler() {
				this.changed = true;
			},
			deep: true
		},
	},

	async created() {
		this.instanceMutes = this.$i.mutedInstances.join('\n');
	},

	methods: {
		async save() {
			let mutes = this.instanceMutes.trim().split('\n').map(el => el.trim()).filter(el => el);
			await os.api('i/update', {
				mutedInstances: mutes,
			});
			this.changed = false;

			// Refresh filtered list to signal to the user how they've been saved
			this.instanceMutes = mutes.join('\n');
		},
	}
})
</script>