perf: 优化notify插件代码

pull/64/head
moonrailgun 2 years ago
parent 8c30282d0b
commit 1f537816c2

@ -37,21 +37,18 @@ export function initNotify() {
const registration: ServiceWorkerRegistration | null = const registration: ServiceWorkerRegistration | null =
getServiceWorkerRegistration(); getServiceWorkerRegistration();
if (registration) { const title = `${Translate.from} ${nickname}`;
registration.showNotification(`${Translate.from} ${nickname}`, { const options: NotificationOptions = {
body: content, body: content,
icon, icon,
tag: 'tailchat-message', tag: 'tailchat-message',
renotify: true, renotify: true,
}); };
if (registration) {
registration.showNotification(title, options);
} else { } else {
// fallback // fallback
new Notification(`${Translate.from} ${nickname}`, { new Notification(title, options);
body: content,
icon,
tag: 'tailchat-message',
renotify: true,
});
} }
} }
); );

Loading…
Cancel
Save