This commit is contained in:
Denis Bykhov 2022-07-02 08:01:33 +06:00 committed by GitHub
parent 6b0b3a51b2
commit 3994a7ec94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 14 deletions

View File

@ -353,20 +353,7 @@ export class LiveQuery extends TxProcessor implements Client {
}
} else {
const updatedDoc = q.result[pos]
if (updatedDoc.modifiedOn > tx.modifiedOn) return
if (updatedDoc.modifiedOn === tx.modifiedOn) {
const current = await this.findOne(q._class, { _id: updatedDoc._id }, q.options)
if (current !== undefined && this.match(q, current)) {
q.result[pos] = current
} else {
if (q.options?.limit === q.result.length) {
return await this.refresh(q)
} else {
q.result.splice(pos, 1)
q.total--
}
}
} else {
if (updatedDoc.modifiedOn < tx.modifiedOn) {
await this.__updateDoc(q, updatedDoc, tx)
if (!this.match(q, updatedDoc)) {
if (q.options?.limit === q.result.length) {
@ -378,6 +365,18 @@ export class LiveQuery extends TxProcessor implements Client {
} else {
q.result[pos] = updatedDoc
}
} else {
const current = await this.findOne(q._class, { _id: updatedDoc._id }, q.options)
if (current !== undefined && this.match(q, current)) {
q.result[pos] = current
} else {
if (q.options?.limit === q.result.length) {
return await this.refresh(q)
} else {
q.result.splice(pos, 1)
q.total--
}
}
}
}
this.sort(q, tx)

View File

@ -446,6 +446,8 @@ class TServerStorage implements ServerStorage {
))
]
derived.sort((a, b) => a.modifiedOn - b.modifiedOn)
for (const tx of derived) {
await ctx.with('derived-route-tx', { _class: txClass(tx) }, (ctx) => this.routeTx(ctx, tx))
}