feat(pwa): add base
All checks were successful
/ build-web (push) Successful in 5m35s
/ build-desktop (linux) (push) Successful in 9m41s
/ build-mobile (push) Successful in 20m12s
/ release (push) Successful in 1m51s
Dependency builds / Build web (pull_request) Has been skipped
Dependency builds / Build desktop (pull_request) Has been skipped
Dependency builds / Build mobile (pull_request) Has been skipped
All checks were successful
/ build-web (push) Successful in 5m35s
/ build-desktop (linux) (push) Successful in 9m41s
/ build-mobile (push) Successful in 20m12s
/ release (push) Successful in 1m51s
Dependency builds / Build web (pull_request) Has been skipped
Dependency builds / Build desktop (pull_request) Has been skipped
Dependency builds / Build mobile (pull_request) Has been skipped
This commit is contained in:
parent
6e977bca7e
commit
7b36218ffa
40 changed files with 4014 additions and 922 deletions
|
|
@ -141,20 +141,30 @@ export default function Provider(props: { children: React.ReactNode }) {
|
|||
const hasPermissions = await requestNotificationPermission();
|
||||
|
||||
if (hasPermissions) {
|
||||
const notification = new Notification(user.Display, {
|
||||
const options: NotificationOptions = {
|
||||
body: content,
|
||||
icon: user.Avatar || user.Display.slice(0, 2).toUpperCase(),
|
||||
badge: user.Avatar || user.Display.slice(0, 2).toUpperCase(),
|
||||
icon: user.Avatar || "/icons/icon-192.png",
|
||||
badge: "/icons/notification-badge.png",
|
||||
tag: `message-${user.UserId}`,
|
||||
silent: true,
|
||||
});
|
||||
|
||||
};
|
||||
if ("serviceWorker" in navigator) {
|
||||
const registration =
|
||||
await navigator.serviceWorker.getRegistration();
|
||||
if (registration) {
|
||||
await registration.showNotification(user.Display, {
|
||||
...options,
|
||||
data: { url: `/chat?id=${user.UserId}` },
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
const notification = new Notification(user.Display, options);
|
||||
notification.onclick = () => {
|
||||
window.focus();
|
||||
navigate({
|
||||
to: `/chat?id=${user.UserId}`,
|
||||
});
|
||||
|
||||
notification.close();
|
||||
};
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue