mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +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.
|
||||
const result = await this.conn.tx(tx)
|
||||
this.notify?.(tx)
|
||||
return result
|
||||
}
|
||||
|
||||
@ -166,9 +165,14 @@ class ClientImpl implements AccountClient, BackupClient, MeasureClient {
|
||||
|
||||
async updateFromRemote (...tx: Tx[]): Promise<void> {
|
||||
for (const t of tx) {
|
||||
if (t.objectSpace === core.space.Model) {
|
||||
this.hierarchy.tx(t)
|
||||
await this.model.tx(t)
|
||||
try {
|
||||
if (t.objectSpace === core.space.Model) {
|
||||
this.hierarchy.tx(t)
|
||||
await this.model.tx(t)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('failed to apply model transaction, skipping', t)
|
||||
continue
|
||||
}
|
||||
}
|
||||
this.notify?.(...tx)
|
||||
|
@ -76,7 +76,7 @@ FulltextStorage & {
|
||||
}
|
||||
await Promise.all([model.tx(tx), transactions.tx(tx)])
|
||||
// Not required, since handled in client.
|
||||
// handler(tx)
|
||||
handler(tx)
|
||||
return {}
|
||||
},
|
||||
close: async () => {},
|
||||
|
@ -156,7 +156,7 @@ export class ClientSession implements Session {
|
||||
}
|
||||
|
||||
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 (this.useBroadcast) {
|
||||
@ -176,7 +176,7 @@ export class ClientSession implements Session {
|
||||
if (tx._class === core.class.TxApplyIf) {
|
||||
;(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 {
|
||||
if (tx._class === core.class.TxApplyIf) {
|
||||
;(result as TxApplyResult).derived.push(...derived)
|
||||
@ -184,12 +184,7 @@ export class ClientSession implements Session {
|
||||
while (derived.length > 0) {
|
||||
const part = derived.splice(0, 250)
|
||||
console.log('Broadcasting part', part.length, derived.length)
|
||||
this.broadcast(
|
||||
tx._class === core.class.TxApplyIf ? this : null,
|
||||
this.token.workspace,
|
||||
{ result: part },
|
||||
target
|
||||
)
|
||||
this.broadcast(null, this.token.workspace, { result: part }, target)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user