mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-11-23 19:59:26 +01:00
Make web app work for updated notifications
This commit is contained in:
parent
86baa80ab8
commit
a327fe802e
1 changed files with 8 additions and 4 deletions
|
@ -65,13 +65,17 @@ class SubscriptionManager {
|
||||||
|
|
||||||
/** Adds notification, or returns false if it already exists */
|
/** Adds notification, or returns false if it already exists */
|
||||||
async addNotification(subscriptionId, notification) {
|
async addNotification(subscriptionId, notification) {
|
||||||
const exists = await db.notifications.get(notification.id);
|
const existingNotification = await db.notifications.get(notification.id);
|
||||||
if (exists) {
|
if (existingNotification) {
|
||||||
|
const upToDate = (existingNotification?.updated ?? 0) >= (notification.updated ?? 0);
|
||||||
|
if (upToDate) {
|
||||||
|
console.error(`[SubscriptionManager] up to date`, existingNotification, notification);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
notification.new = 1; // New marker (used for bubble indicator); cannot be boolean; Dexie index limitation
|
notification.new = 1; // New marker (used for bubble indicator); cannot be boolean; Dexie index limitation
|
||||||
await db.notifications.add({ ...notification, subscriptionId }); // FIXME consider put() for double tab
|
await db.notifications.put({ ...notification, subscriptionId });
|
||||||
await db.subscriptions.update(subscriptionId, {
|
await db.subscriptions.update(subscriptionId, {
|
||||||
last: notification.id
|
last: notification.id
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue