From 1f537816c277ada199b2b5597f396acc4f5e7699 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 1 Jan 2023 00:05:15 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96notify=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/com.msgbyte.notify/src/notify.ts | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/client/web/plugins/com.msgbyte.notify/src/notify.ts b/client/web/plugins/com.msgbyte.notify/src/notify.ts index c35d958b..62ddb214 100644 --- a/client/web/plugins/com.msgbyte.notify/src/notify.ts +++ b/client/web/plugins/com.msgbyte.notify/src/notify.ts @@ -37,21 +37,18 @@ export function initNotify() { const registration: ServiceWorkerRegistration | null = getServiceWorkerRegistration(); + const title = `${Translate.from} ${nickname}`; + const options: NotificationOptions = { + body: content, + icon, + tag: 'tailchat-message', + renotify: true, + }; if (registration) { - registration.showNotification(`${Translate.from} ${nickname}`, { - body: content, - icon, - tag: 'tailchat-message', - renotify: true, - }); + registration.showNotification(title, options); } else { // fallback - new Notification(`${Translate.from} ${nickname}`, { - body: content, - icon, - tag: 'tailchat-message', - renotify: true, - }); + new Notification(title, options); } } );