2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
2023-01-06 05:40:17 +01:00
|
|
|
<div class="_gaps_m">
|
2023-09-29 04:29:54 +02:00
|
|
|
<FormSection first>
|
|
|
|
<template #label>{{ i18n.ts.notificationRecieveConfig }}</template>
|
|
|
|
<div class="_gaps_s">
|
|
|
|
<MkFolder v-for="type in notificationTypes" :key="type">
|
|
|
|
<template #label>{{ i18n.t('_notification._types.' + type) }}</template>
|
|
|
|
<template #suffix>
|
|
|
|
{{
|
|
|
|
$i.notificationRecieveConfig[type]?.type === 'never' ? i18n.ts.none :
|
|
|
|
$i.notificationRecieveConfig[type]?.type === 'following' ? i18n.ts.following :
|
|
|
|
$i.notificationRecieveConfig[type]?.type === 'follower' ? i18n.ts.followers :
|
|
|
|
$i.notificationRecieveConfig[type]?.type === 'mutualFollow' ? i18n.ts.mutualFollow :
|
|
|
|
$i.notificationRecieveConfig[type]?.type === 'list' ? i18n.ts.userList :
|
|
|
|
i18n.ts.all
|
|
|
|
}}
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<XNotificationConfig :userLists="userLists" :value="$i.notificationRecieveConfig[type] ?? { type: 'all' }" @update="(res) => updateReceiveConfig(type, res)"/>
|
|
|
|
</MkFolder>
|
|
|
|
</div>
|
|
|
|
</FormSection>
|
2021-11-28 12:07:37 +01:00
|
|
|
<FormSection>
|
2023-01-06 05:40:17 +01:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 13:04:56 +01:00
|
|
|
<FormLink @click="readAllNotifications">{{ i18n.ts.markAsReadAllNotifications }}</FormLink>
|
|
|
|
<FormLink @click="readAllUnreadNotes">{{ i18n.ts.markAsReadAllUnreadNotes }}</FormLink>
|
|
|
|
</div>
|
2021-11-28 12:07:37 +01:00
|
|
|
</FormSection>
|
2023-09-11 07:31:50 +02:00
|
|
|
<FormSection>
|
|
|
|
<div class="_gaps_m">
|
2023-09-12 08:48:19 +02:00
|
|
|
<FormLink @click="testNotification">{{ i18n.ts._notification.sendTestNotification }}</FormLink>
|
2023-09-11 07:31:50 +02:00
|
|
|
</div>
|
|
|
|
</FormSection>
|
2022-12-17 17:59:59 +01:00
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ i18n.ts.pushNotification }}</template>
|
2023-01-05 13:04:56 +01:00
|
|
|
|
2023-01-06 05:40:17 +01:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 13:04:56 +01:00
|
|
|
<MkPushNotificationAllowButton ref="allowButton"/>
|
2023-05-19 13:52:15 +02:00
|
|
|
<MkSwitch :disabled="!pushRegistrationInServer" :modelValue="sendReadMessage" @update:modelValue="onChangeSendReadMessage">
|
2023-01-05 13:04:56 +01: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 06:59:54 +01:00
|
|
|
</MkSwitch>
|
2023-01-05 13:04:56 +01:00
|
|
|
</div>
|
2022-12-17 17:59:59 +01:00
|
|
|
</FormSection>
|
2021-11-28 12:07:37 +01:00
|
|
|
</div>
|
2020-10-17 13:12:00 +02:00
|
|
|
</template>
|
|
|
|
|
2022-05-12 19:31:26 +02:00
|
|
|
<script lang="ts" setup>
|
2022-06-20 10:38:49 +02:00
|
|
|
import { defineAsyncComponent } from 'vue';
|
2023-09-29 04:29:54 +02:00
|
|
|
import XNotificationConfig from './notifications.notification-config.vue';
|
2021-11-28 12:07:37 +01:00
|
|
|
import FormLink from '@/components/form/link.vue';
|
|
|
|
import FormSection from '@/components/form/section.vue';
|
2023-09-29 04:29:54 +02:00
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
2023-01-07 06:59:54 +01:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { $i } from '@/account.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
2022-12-17 17:59:59 +01:00
|
|
|
import MkPushNotificationAllowButton from '@/components/MkPushNotificationAllowButton.vue';
|
2023-09-29 04:29:54 +02:00
|
|
|
import { notificationTypes } from '@/const.js';
|
2022-12-17 17:59:59 +01:00
|
|
|
|
2023-01-03 05:37:32 +01:00
|
|
|
let allowButton = $shallowRef<InstanceType<typeof MkPushNotificationAllowButton>>();
|
2022-12-17 17:59:59 +01:00
|
|
|
let pushRegistrationInServer = $computed(() => allowButton?.pushRegistrationInServer);
|
|
|
|
let sendReadMessage = $computed(() => pushRegistrationInServer?.sendReadMessage || false);
|
2023-09-29 04:29:54 +02:00
|
|
|
const userLists = await os.api('users/lists/list');
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-04 05:25:19 +02:00
|
|
|
async function readAllUnreadNotes() {
|
|
|
|
await os.api('i/read-all-unread-notes');
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-05-04 05:25:19 +02:00
|
|
|
async function readAllNotifications() {
|
|
|
|
await os.api('notifications/mark-all-as-read');
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2023-09-29 04:29:54 +02:00
|
|
|
async function updateReceiveConfig(type, value) {
|
|
|
|
await os.apiWithDialog('i/update', {
|
|
|
|
notificationRecieveConfig: {
|
|
|
|
...$i!.notificationRecieveConfig,
|
|
|
|
[type]: value,
|
2022-06-20 10:38:49 +02:00
|
|
|
},
|
2023-09-29 04:29:54 +02:00
|
|
|
}).then(i => {
|
|
|
|
$i!.notificationRecieveConfig = i.notificationRecieveConfig;
|
|
|
|
});
|
2022-05-04 05:25:19 +02:00
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-12-17 17:59:59 +01: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;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-09-12 08:48:19 +02:00
|
|
|
function testNotification(): void {
|
|
|
|
os.api('notifications/test-notification');
|
|
|
|
}
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.notifications,
|
2022-12-19 11:01:30 +01:00
|
|
|
icon: 'ti ti-bell',
|
2020-10-17 13:12:00 +02:00
|
|
|
});
|
|
|
|
</script>
|