diff --git a/plugins/notification-resources/src/components/Inbox.svelte b/plugins/notification-resources/src/components/Inbox.svelte index 0d4418790c9..19a29536582 100644 --- a/plugins/notification-resources/src/components/Inbox.svelte +++ b/plugins/notification-resources/src/components/Inbox.svelte @@ -59,9 +59,11 @@ return } if (prevValue !== undefined) { - prevValue.txes.forEach((p) => (p.isNew = false)) - const txes = prevValue.txes - await client.update(prevValue, { txes }) + if (prevValue.txes.some((p) => p.isNew)) { + prevValue.txes.forEach((p) => (p.isNew = false)) + const txes = prevValue.txes + await client.update(prevValue, { txes }) + } } const targetClass = hierarchy.getClass(value.attachedToClass) const panelComponent = hierarchy.as(targetClass, view.mixin.ObjectPanel) diff --git a/plugins/notification-resources/src/utils.ts b/plugins/notification-resources/src/utils.ts index fbf0379a038..62b0f24814f 100644 --- a/plugins/notification-resources/src/utils.ts +++ b/plugins/notification-resources/src/utils.ts @@ -62,8 +62,10 @@ export class NotificationClientImpl implements NotificationClient { const client = getClient() const docUpdate = this.docUpdatesMap.get(_id) if (docUpdate !== undefined) { - docUpdate.txes.forEach((p) => (p.isNew = false)) - await client.update(docUpdate, { txes: docUpdate.txes }) + if (docUpdate.txes.some((p) => p.isNew)) { + docUpdate.txes.forEach((p) => (p.isNew = false)) + await client.update(docUpdate, { txes: docUpdate.txes }) + } } } @@ -71,8 +73,10 @@ export class NotificationClientImpl implements NotificationClient { const client = getClient() const docUpdate = this.docUpdatesMap.get(_id) if (docUpdate !== undefined) { - docUpdate.txes.forEach((p) => (p.isNew = false)) - await client.update(docUpdate, { txes: docUpdate.txes }) + if (docUpdate.txes.some((p) => p.isNew)) { + docUpdate.txes.forEach((p) => (p.isNew = false)) + await client.update(docUpdate, { txes: docUpdate.txes }) + } } else { const doc = await client.findOne(_class, { _id }) if (doc !== undefined) {