feat: テスト通知を送信できるようにする (#11810)

* (add) Notification test

* Update Changelog

* (add) backend, frontend impl

* globalEventの名前を明確にする

* Run API Extractor
This commit is contained in:
かっこかり
2023-09-11 14:31:50 +09:00
committed by GitHub
parent 98e40e666c
commit cd6428715e
16 changed files with 112 additions and 4 deletions

View File

@@ -56,6 +56,7 @@ import { $i } from '@/account';
import { useStream } from '@/stream';
import { i18n } from '@/i18n';
import { defaultStore } from '@/store';
import { globalEvents } from '@/events';
const XStreamIndicator = defineAsyncComponent(() => import('./stream-indicator.vue'));
const XUpload = defineAsyncComponent(() => import('./upload.vue'));
@@ -64,11 +65,13 @@ const dev = _DEV_;
let notifications = $ref<Misskey.entities.Notification[]>([]);
function onNotification(notification) {
function onNotification(notification: Misskey.entities.Notification, isClient: boolean = false) {
if ($i.mutingNotificationTypes.includes(notification.type)) return;
if (document.visibilityState === 'visible') {
useStream().send('readNotification');
if (!isClient) {
useStream().send('readNotification');
}
notifications.unshift(notification);
window.setTimeout(() => {
@@ -86,6 +89,7 @@ function onNotification(notification) {
if ($i) {
const connection = useStream().useChannel('main', null, 'UI');
connection.on('notification', onNotification);
globalEvents.on('clientNotification', notification => onNotification(notification, true));
//#region Listen message from SW
if ('serviceWorker' in navigator) {