Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions plugins/notification-resources/src/components/Inbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 8 additions & 4 deletions plugins/notification-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,21 @@ 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 })
}
}
}

async forceRead (_id: Ref<Doc>, _class: Ref<Class<Doc>>): Promise<void> {
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) {
Expand Down