summaryrefslogtreecommitdiff
path: root/src/client/pages/settings/email-notification.vue
blob: 1b78621c3f7440a2d52a419dd5d6a050838bd7d9 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<template>
<FormBase>
	<FormGroup>
		<FormSwitch v-model="mention">
			{{ $ts._notification._types.mention }}
		</FormSwitch>
		<FormSwitch v-model="reply">
			{{ $ts._notification._types.reply }}
		</FormSwitch>
		<FormSwitch v-model="quote">
			{{ $ts._notification._types.quote }}
		</FormSwitch>
		<FormSwitch v-model="follow">
			{{ $ts._notification._types.follow }}
		</FormSwitch>
		<FormSwitch v-model="receiveFollowRequest">
			{{ $ts._notification._types.receiveFollowRequest }}
		</FormSwitch>
		<FormSwitch v-model="groupInvited">
			{{ $ts._notification._types.groupInvited }}
		</FormSwitch>
	</FormGroup>
</FormBase>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import FormButton from '@client/components/debobigego/button.vue';
import FormSwitch from '@client/components/form/switch.vue';
import FormBase from '@client/components/debobigego/base.vue';
import FormGroup from '@client/components/debobigego/group.vue';
import * as os from '@client/os';
import * as symbols from '@client/symbols';
import * as symbols from '@client/symbols';

export default defineComponent({
	components: {
		FormBase,
		FormSwitch,
		FormButton,
		FormGroup,
	},

	emits: ['info'],
	
	data() {
		return {
			[symbols.PAGE_INFO]: {
				title: this.$ts.emailNotification,
				icon: 'fas fa-envelope',
				bg: 'var(--bg)',
			},

			mention: this.$i.emailNotificationTypes.includes('mention'),
			reply: this.$i.emailNotificationTypes.includes('reply'),
			quote: this.$i.emailNotificationTypes.includes('quote'),
			follow: this.$i.emailNotificationTypes.includes('follow'),
			receiveFollowRequest: this.$i.emailNotificationTypes.includes('receiveFollowRequest'),
			groupInvited: this.$i.emailNotificationTypes.includes('groupInvited'),
		}
	},

	created() {
		this.$watch('mention', this.save);
		this.$watch('reply', this.save);
		this.$watch('quote', this.save);
		this.$watch('follow', this.save);
		this.$watch('receiveFollowRequest', this.save);
		this.$watch('groupInvited', this.save);
	},

	mounted() {
		this.$emit('info', this[symbols.PAGE_INFO]);
	},

	methods: {
		save() {
			os.api('i/update', {
				emailNotificationTypes: [
					...[this.mention ? 'mention' : null],
					...[this.reply ? 'reply' : null],
					...[this.quote ? 'quote' : null],
					...[this.follow ? 'follow' : null],
					...[this.receiveFollowRequest ? 'receiveFollowRequest' : null],
					...[this.groupInvited ? 'groupInvited' : null],
				].filter(x => x != null)
			});
		}
	}
});
</script>