fix: use notification tag
This commit is contained in:
parent
748fe22101
commit
1a984a8075
@ -32,7 +32,7 @@ interface PushNotificationMention {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.addEventListener("notificationclick", event => {
|
self.addEventListener("notificationclick", event => {
|
||||||
const id = event.notification.data as string;
|
const id = event.notification.tag as string;
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
(async () => {
|
(async () => {
|
||||||
const windows = await self.clients.matchAll({ type: "window" });
|
const windows = await self.clients.matchAll({ type: "window" });
|
||||||
@ -62,13 +62,12 @@ self.addEventListener("push", async e => {
|
|||||||
title: `Reply from ${getDisplayName(userProfile, ev.pubkey)}`,
|
title: `Reply from ${getDisplayName(userProfile, ev.pubkey)}`,
|
||||||
body: replaceMentions(ev.content, mention.profiles).substring(0, 250),
|
body: replaceMentions(ev.content, mention.profiles).substring(0, 250),
|
||||||
icon: avatarUrl,
|
icon: avatarUrl,
|
||||||
timestamp: ev.created_at * 1000,
|
timestamp: ev.created_at * 1000
|
||||||
data: NostrLink.fromEvent(ev).encode(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
console.debug("Sending notification", notif);
|
console.debug("Sending notification", notif);
|
||||||
await self.registration.showNotification(notif.title, {
|
await self.registration.showNotification(notif.title, {
|
||||||
tag: "notification",
|
tag: NostrLink.fromEvent(ev).encode(),
|
||||||
vibrate: [500],
|
vibrate: [500],
|
||||||
...notif,
|
...notif,
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user