diff --git a/locales/index.d.ts b/locales/index.d.ts index 858736be6a..83819ef8ff 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -2132,6 +2132,9 @@ export interface Locale { "unreadAntennaNote": string; "emptyPushNotificationMessage": string; "achievementEarned": string; + "testNotification": string; + "doTestNotification": string; + "notificationWillBeDisplayedLikeThis": string; "_types": { "all": string; "follow": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 7e625b9ac8..6fbcef26a3 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2047,6 +2047,9 @@ _notification: unreadAntennaNote: "アンテナ {name}" emptyPushNotificationMessage: "プッシュ通知の更新をしました" achievementEarned: "実績を獲得" + testNotification: "通知テスト" + doTestNotification: "通知をテストする" + notificationWillBeDisplayedLikeThis: "通知はこのように表示されます" _types: all: "すべて" diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 3b39a5c00a..9197dfca04 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -90,6 +90,8 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.vertical }} {{ i18n.ts.horizontal }} + + {{ i18n.ts._notification.doTestNotification }} @@ -185,6 +187,7 @@ import { unisonReload } from '@/scripts/unison-reload'; import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; import { miLocalStorage } from '@/local-storage'; +import { infoImageUrl } from '@/instance'; const lang = ref(miLocalStorage.getItem('lang')); const fontSize = ref(miLocalStorage.getItem('fontSize')); @@ -296,6 +299,14 @@ function removeEmojiIndex(lang: string) { os.promiseDialog(main()); } +function testNotification(): void { + os.api('notifications/create', { + header: i18n.ts._notification.testNotification, + body: i18n.ts._notification.notificationWillBeDisplayedLikeThis, + icon: infoImageUrl.value, + }); +} + const headerActions = $computed(() => []); const headerTabs = $computed(() => []); diff --git a/packages/frontend/src/pages/settings/notifications.vue b/packages/frontend/src/pages/settings/notifications.vue index b9e4c58f79..2afd91fa99 100644 --- a/packages/frontend/src/pages/settings/notifications.vue +++ b/packages/frontend/src/pages/settings/notifications.vue @@ -12,6 +12,11 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.markAsReadAllUnreadNotes }} + + + {{ i18n.ts._notification.doTestNotification }} + + {{ i18n.ts.pushNotification }} @@ -41,6 +46,7 @@ import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; import MkPushNotificationAllowButton from '@/components/MkPushNotificationAllowButton.vue'; import { notificationTypes } from '@/const'; +import { infoImageUrl } from '@/instance'; let allowButton = $shallowRef>(); let pushRegistrationInServer = $computed(() => allowButton?.pushRegistrationInServer); @@ -83,6 +89,14 @@ function onChangeSendReadMessage(v: boolean) { }); } +function testNotification(): void { + os.api('notifications/create', { + header: i18n.ts._notification.testNotification, + body: i18n.ts._notification.notificationWillBeDisplayedLikeThis, + icon: infoImageUrl.value, + }); +} + const headerActions = $computed(() => []); const headerTabs = $computed(() => []);