2023-09-29 02:29:54 +00:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<MkModalWindow
|
|
|
|
ref="dialog"
|
|
|
|
:width="400"
|
|
|
|
:height="450"
|
|
|
|
:withOkButton="true"
|
|
|
|
:okButtonDisabled="false"
|
|
|
|
@ok="ok()"
|
|
|
|
@close="dialog?.close()"
|
|
|
|
@closed="emit('closed')"
|
|
|
|
>
|
|
|
|
<template #header>{{ i18n.ts.notificationSetting }}</template>
|
|
|
|
|
|
|
|
<MkSpacer :marginMin="20" :marginMax="28">
|
|
|
|
<div class="_gaps_m">
|
|
|
|
<MkInfo>{{ i18n.ts.notificationSettingDesc }}</MkInfo>
|
|
|
|
<div class="_buttons">
|
|
|
|
<MkButton inline @click="disableAll">{{ i18n.ts.disableAll }}</MkButton>
|
|
|
|
<MkButton inline @click="enableAll">{{ i18n.ts.enableAll }}</MkButton>
|
|
|
|
</div>
|
2024-01-19 23:11:59 +00:00
|
|
|
<MkSwitch v-for="ntype in notificationTypes" :key="ntype" v-model="typesMap[ntype].value">{{ i18n.ts._notification._types[ntype] }}</MkSwitch>
|
2023-09-29 02:29:54 +00:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkModalWindow>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-12-07 05:42:09 +00:00
|
|
|
import { ref, Ref, shallowRef } from 'vue';
|
2023-09-29 02:29:54 +00:00
|
|
|
import MkSwitch from './MkSwitch.vue';
|
|
|
|
import MkInfo from './MkInfo.vue';
|
|
|
|
import MkButton from './MkButton.vue';
|
|
|
|
import MkModalWindow from '@/components/MkModalWindow.vue';
|
|
|
|
import { notificationTypes } from '@/const.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
|
|
|
|
type TypesMap = Record<typeof notificationTypes[number], Ref<boolean>>
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
(ev: 'done', v: { excludeTypes: string[] }): void,
|
|
|
|
(ev: 'closed'): void,
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
excludeTypes?: typeof notificationTypes[number][];
|
|
|
|
}>(), {
|
|
|
|
excludeTypes: () => [],
|
|
|
|
});
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const dialog = shallowRef<InstanceType<typeof MkModalWindow>>();
|
2023-09-29 02:29:54 +00:00
|
|
|
|
|
|
|
const typesMap: TypesMap = notificationTypes.reduce((p, t) => ({ ...p, [t]: ref<boolean>(!props.excludeTypes.includes(t)) }), {} as any);
|
|
|
|
|
|
|
|
function ok() {
|
|
|
|
emit('done', {
|
|
|
|
excludeTypes: (Object.keys(typesMap) as typeof notificationTypes[number][])
|
|
|
|
.filter(type => !typesMap[type].value),
|
|
|
|
});
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
if (dialog.value) dialog.value.close();
|
2023-09-29 02:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function disableAll() {
|
|
|
|
for (const type of notificationTypes) {
|
|
|
|
typesMap[type].value = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function enableAll() {
|
|
|
|
for (const type of notificationTypes) {
|
|
|
|
typesMap[type].value = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|