mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-20 23:32:14 +00:00
Change tx notify logic (#5172)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
20cd262081
commit
5d6c33249d
@ -156,7 +156,6 @@ class ClientImpl implements AccountClient, BackupClient, MeasureClient {
|
|||||||
|
|
||||||
// We need to handle it on server, before performing local live query updates.
|
// We need to handle it on server, before performing local live query updates.
|
||||||
const result = await this.conn.tx(tx)
|
const result = await this.conn.tx(tx)
|
||||||
this.notify?.(tx)
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,9 +165,14 @@ class ClientImpl implements AccountClient, BackupClient, MeasureClient {
|
|||||||
|
|
||||||
async updateFromRemote (...tx: Tx[]): Promise<void> {
|
async updateFromRemote (...tx: Tx[]): Promise<void> {
|
||||||
for (const t of tx) {
|
for (const t of tx) {
|
||||||
if (t.objectSpace === core.space.Model) {
|
try {
|
||||||
this.hierarchy.tx(t)
|
if (t.objectSpace === core.space.Model) {
|
||||||
await this.model.tx(t)
|
this.hierarchy.tx(t)
|
||||||
|
await this.model.tx(t)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('failed to apply model transaction, skipping', t)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.notify?.(...tx)
|
this.notify?.(...tx)
|
||||||
|
@ -76,7 +76,7 @@ FulltextStorage & {
|
|||||||
}
|
}
|
||||||
await Promise.all([model.tx(tx), transactions.tx(tx)])
|
await Promise.all([model.tx(tx), transactions.tx(tx)])
|
||||||
// Not required, since handled in client.
|
// Not required, since handled in client.
|
||||||
// handler(tx)
|
handler(tx)
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
close: async () => {},
|
close: async () => {},
|
||||||
|
@ -156,7 +156,7 @@ export class ClientSession implements Session {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tx._class !== core.class.TxApplyIf) {
|
if (tx._class !== core.class.TxApplyIf) {
|
||||||
this.broadcast(this, this.token.workspace, { result: tx }, target)
|
this.broadcast(null, this.token.workspace, { result: tx }, target)
|
||||||
}
|
}
|
||||||
if (shouldBroadcast) {
|
if (shouldBroadcast) {
|
||||||
if (this.useBroadcast) {
|
if (this.useBroadcast) {
|
||||||
@ -176,7 +176,7 @@ export class ClientSession implements Session {
|
|||||||
if (tx._class === core.class.TxApplyIf) {
|
if (tx._class === core.class.TxApplyIf) {
|
||||||
;(result as TxApplyResult).derived.push(bevent)
|
;(result as TxApplyResult).derived.push(bevent)
|
||||||
}
|
}
|
||||||
this.broadcast(this, this.token.workspace, { result: bevent }, target)
|
this.broadcast(null, this.token.workspace, { result: bevent }, target)
|
||||||
} else {
|
} else {
|
||||||
if (tx._class === core.class.TxApplyIf) {
|
if (tx._class === core.class.TxApplyIf) {
|
||||||
;(result as TxApplyResult).derived.push(...derived)
|
;(result as TxApplyResult).derived.push(...derived)
|
||||||
@ -184,12 +184,7 @@ export class ClientSession implements Session {
|
|||||||
while (derived.length > 0) {
|
while (derived.length > 0) {
|
||||||
const part = derived.splice(0, 250)
|
const part = derived.splice(0, 250)
|
||||||
console.log('Broadcasting part', part.length, derived.length)
|
console.log('Broadcasting part', part.length, derived.length)
|
||||||
this.broadcast(
|
this.broadcast(null, this.token.workspace, { result: part }, target)
|
||||||
tx._class === core.class.TxApplyIf ? this : null,
|
|
||||||
this.token.workspace,
|
|
||||||
{ result: part },
|
|
||||||
target
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user