perf: 优化notify插件代码

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

@ -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);
}
}
);

Loading…
Cancel
Save