2023-07-27 08:31:52 +03:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
<template>
|
2023-01-06 06:40:17 +02:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormLink @click="configure"><template #icon><i class="ti ti-settings"></i></template>{{ i18n.ts.notificationSetting }}</FormLink>
|
2021-11-28 13:07:37 +02:00
|
|
|
<FormSection>
|
2023-01-06 06:40:17 +02:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 14:04:56 +02:00
|
|
|
<FormLink @click="readAllNotifications">{{ i18n.ts.markAsReadAllNotifications }}</FormLink>
|
|
|
|
<FormLink @click="readAllUnreadNotes">{{ i18n.ts.markAsReadAllUnreadNotes }}</FormLink>
|
|
|
|
</div>
|
2021-11-28 13:07:37 +02:00
|
|
|
</FormSection>
|
2022-12-17 18:59:59 +02:00
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ i18n.ts.pushNotification }}</template>
|
2023-01-05 14:04:56 +02:00
|
|
|
|
2023-01-06 06:40:17 +02:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 14:04:56 +02:00
|
|
|
<MkPushNotificationAllowButton ref="allowButton"/>
|
2023-05-19 14:52:15 +03:00
|
|
|
<MkSwitch :disabled="!pushRegistrationInServer" :modelValue="sendReadMessage" @update:modelValue="onChangeSendReadMessage">
|
2023-01-05 14:04:56 +02:00
|
|
|
<template #label>{{ i18n.ts.sendPushNotificationReadMessage }}</template>
|
|
|
|
<template #caption>
|
|
|
|
<I18n :src="i18n.ts.sendPushNotificationReadMessageCaption">
|
|
|
|
<template #emptyPushNotificationMessage>{{ i18n.ts._notification.emptyPushNotificationMessage }}</template>
|
|
|
|
</I18n>
|
|
|
|
</template>
|
2023-01-07 07:59:54 +02:00
|
|
|
</MkSwitch>
|
2023-01-05 14:04:56 +02:00
|
|
|
</div>
|
2022-12-17 18:59:59 +02:00
|
|
|
</FormSection>
|
2021-11-28 13:07:37 +02:00
|
|
|
</div>
|
2020-10-17 14:12:00 +03:00
|
|
|
</template>
|
|
|
|
|
2022-05-12 20:31:26 +03:00
|
|
|
<script lang="ts" setup>
|
2022-06-20 11:38:49 +03:00
|
|
|
import { defineAsyncComponent } from 'vue';
|
2021-11-28 13:07:37 +02:00
|
|
|
import FormLink from '@/components/form/link.vue';
|
|
|
|
import FormSection from '@/components/form/section.vue';
|
2023-01-07 07:59:54 +02:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import * as os from '@/os';
|
2022-05-04 06:25:19 +03:00
|
|
|
import { $i } from '@/account';
|
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 11:38:49 +03:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-12-17 18:59:59 +02:00
|
|
|
import MkPushNotificationAllowButton from '@/components/MkPushNotificationAllowButton.vue';
|
2023-02-23 13:46:14 +02:00
|
|
|
import { notificationTypes } from '@/const';
|
2022-12-17 18:59:59 +02:00
|
|
|
|
2023-01-03 06:37:32 +02:00
|
|
|
let allowButton = $shallowRef<InstanceType<typeof MkPushNotificationAllowButton>>();
|
2022-12-17 18:59:59 +02:00
|
|
|
let pushRegistrationInServer = $computed(() => allowButton?.pushRegistrationInServer);
|
|
|
|
let sendReadMessage = $computed(() => pushRegistrationInServer?.sendReadMessage || false);
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-05-04 06:25:19 +03:00
|
|
|
async function readAllUnreadNotes() {
|
|
|
|
await os.api('i/read-all-unread-notes');
|
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-05-04 06:25:19 +03:00
|
|
|
async function readAllNotifications() {
|
|
|
|
await os.api('notifications/mark-all-as-read');
|
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-05-04 06:25:19 +03:00
|
|
|
function configure() {
|
|
|
|
const includingTypes = notificationTypes.filter(x => !$i!.mutingNotificationTypes.includes(x));
|
2022-08-30 18:24:33 +03:00
|
|
|
os.popup(defineAsyncComponent(() => import('@/components/MkNotificationSettingWindow.vue')), {
|
2022-05-04 06:25:19 +03:00
|
|
|
includingTypes,
|
|
|
|
showGlobalToggle: false,
|
|
|
|
}, {
|
|
|
|
done: async (res) => {
|
|
|
|
const { includingTypes: value } = res;
|
|
|
|
await os.apiWithDialog('i/update', {
|
|
|
|
mutingNotificationTypes: notificationTypes.filter(x => !value.includes(x)),
|
|
|
|
}).then(i => {
|
|
|
|
$i!.mutingNotificationTypes = i.mutingNotificationTypes;
|
|
|
|
});
|
2022-06-20 11:38:49 +03:00
|
|
|
},
|
2022-05-04 06:25:19 +03:00
|
|
|
}, 'closed');
|
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-12-17 18:59:59 +02:00
|
|
|
function onChangeSendReadMessage(v: boolean) {
|
|
|
|
if (!pushRegistrationInServer) return;
|
|
|
|
|
|
|
|
os.apiWithDialog('sw/update-registration', {
|
|
|
|
endpoint: pushRegistrationInServer.endpoint,
|
|
|
|
sendReadMessage: v,
|
|
|
|
}).then(res => {
|
|
|
|
if (!allowButton) return;
|
|
|
|
allowButton.pushRegistrationInServer = res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-06-20 11:38:49 +03:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.notifications,
|
2022-12-19 12:01:30 +02:00
|
|
|
icon: 'ti ti-bell',
|
2020-10-17 14:12:00 +03:00
|
|
|
});
|
|
|
|
</script>
|