UBER-472: don't update when it's not needed (#3460)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2023-06-27 08:41:17 +05:00 committed by GitHub
parent 70d78e50b3
commit dbfbcc12ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View File

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

View File

@ -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) {