yumechi-no-kuni/packages/client/src/pages/settings/email-notification.vue

92 lines
2.4 KiB
Vue
Raw Normal View History

2021-02-12 21:28:26 -06:00
<template>
<FormBase>
<FormGroup>
2021-09-29 10:50:45 -05:00
<FormSwitch v-model="mention">
2021-02-12 21:28:26 -06:00
{{ $ts._notification._types.mention }}
</FormSwitch>
2021-09-29 10:50:45 -05:00
<FormSwitch v-model="reply">
2021-02-12 21:28:26 -06:00
{{ $ts._notification._types.reply }}
</FormSwitch>
2021-09-29 10:50:45 -05:00
<FormSwitch v-model="quote">
2021-02-12 21:28:26 -06:00
{{ $ts._notification._types.quote }}
</FormSwitch>
2021-09-29 10:50:45 -05:00
<FormSwitch v-model="follow">
2021-02-12 21:28:26 -06:00
{{ $ts._notification._types.follow }}
</FormSwitch>
2021-09-29 10:50:45 -05:00
<FormSwitch v-model="receiveFollowRequest">
2021-02-12 21:28:26 -06:00
{{ $ts._notification._types.receiveFollowRequest }}
</FormSwitch>
2021-09-29 10:50:45 -05:00
<FormSwitch v-model="groupInvited">
2021-02-12 21:28:26 -06:00
{{ $ts._notification._types.groupInvited }}
</FormSwitch>
</FormGroup>
</FormBase>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
2021-11-11 11:02:25 -06:00
import FormButton from '@/components/debobigego/button.vue';
import FormSwitch from '@/components/form/switch.vue';
import FormBase from '@/components/debobigego/base.vue';
import FormGroup from '@/components/debobigego/group.vue';
import * as os from '@/os';
import * as symbols from '@/symbols';
import * as symbols from '@/symbols';
2021-02-12 21:28:26 -06:00
export default defineComponent({
components: {
FormBase,
FormSwitch,
FormButton,
FormGroup,
},
emits: ['info'],
data() {
return {
2021-04-09 22:54:12 -05:00
[symbols.PAGE_INFO]: {
2021-02-12 21:28:26 -06:00
title: this.$ts.emailNotification,
2021-09-29 10:50:45 -05:00
icon: 'fas fa-envelope',
bg: 'var(--bg)',
2021-02-12 21:28:26 -06:00
},
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() {
2021-04-09 22:54:12 -05:00
this.$emit('info', this[symbols.PAGE_INFO]);
2021-02-12 21:28:26 -06:00
},
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>