enhance: Implement the toggle to (or not to) close push notifications when notifications or messages are read (#9219)
* create file * wip * fix * wip * tabun dekita * ✌️ * implement subscribe push notification button to tutorial * check-exists→show-registration * add column sendReadMessage * fix migration file * sw api * change PushNotificationService * wip * ✌️ * fix tutorial footer flex
This commit is contained in:
parent
96dda253b0
commit
4ecc42744c
14 changed files with 483 additions and 106 deletions
|
|
@ -6,6 +6,18 @@
|
|||
<FormLink class="_formBlock" @click="readAllUnreadNotes">{{ i18n.ts.markAsReadAllUnreadNotes }}</FormLink>
|
||||
<FormLink class="_formBlock" @click="readAllMessagingMessages">{{ i18n.ts.markAsReadAllTalkMessages }}</FormLink>
|
||||
</FormSection>
|
||||
<FormSection>
|
||||
<template #label>{{ i18n.ts.pushNotification }}</template>
|
||||
<MkPushNotificationAllowButton ref="allowButton" />
|
||||
<FormSwitch class="_formBlock" :disabled="!pushRegistrationInServer" :model-value="sendReadMessage" @update:modelValue="onChangeSendReadMessage">
|
||||
<template #label>{{ i18n.ts.sendPushNotificationReadMessage }}</template>
|
||||
<template #caption>
|
||||
<I18n :src="i18n.ts.sendPushNotificationReadMessageCaption">
|
||||
<template #emptyPushNotificationMessage>{{ i18n.ts._notification.emptyPushNotificationMessage }}</template>
|
||||
</I18n>
|
||||
</template>
|
||||
</FormSwitch>
|
||||
</FormSection>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -15,10 +27,16 @@ import { notificationTypes } from 'misskey-js';
|
|||
import FormButton from '@/components/MkButton.vue';
|
||||
import FormLink from '@/components/form/link.vue';
|
||||
import FormSection from '@/components/form/section.vue';
|
||||
import FormSwitch from '@/components/form/switch.vue';
|
||||
import * as os from '@/os';
|
||||
import { $i } from '@/account';
|
||||
import { i18n } from '@/i18n';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||
import MkPushNotificationAllowButton from '@/components/MkPushNotificationAllowButton.vue';
|
||||
|
||||
let allowButton = $ref<InstanceType<typeof MkPushNotificationAllowButton>>();
|
||||
let pushRegistrationInServer = $computed(() => allowButton?.pushRegistrationInServer);
|
||||
let sendReadMessage = $computed(() => pushRegistrationInServer?.sendReadMessage || false);
|
||||
|
||||
async function readAllUnreadNotes() {
|
||||
await os.api('i/read-all-unread-notes');
|
||||
|
|
@ -49,6 +67,18 @@ function configure() {
|
|||
}, 'closed');
|
||||
}
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
const headerActions = $computed(() => []);
|
||||
|
||||
const headerTabs = $computed(() => []);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue