mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-09 11:17:43 +02:00
UBERF-8899: Fix Reconnect performance (#7597)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -115,6 +115,7 @@ export class ModelMiddleware extends BaseMiddleware implements Middleware {
|
||||
|
||||
private setLastHash (hash: string): void {
|
||||
this.lastHash = hash
|
||||
this.context.lastHash = this.lastHash
|
||||
this.lastHashResponse = Promise.resolve({
|
||||
full: false,
|
||||
hash,
|
||||
|
||||
@@ -16,12 +16,16 @@
|
||||
import core, {
|
||||
DOMAIN_TRANSIENT,
|
||||
DOMAIN_TX,
|
||||
generateId,
|
||||
TxProcessor,
|
||||
WorkspaceEvent,
|
||||
type Doc,
|
||||
type MeasureContext,
|
||||
type SessionData,
|
||||
type Tx,
|
||||
type TxCUD,
|
||||
type TxResult
|
||||
type TxResult,
|
||||
type TxWorkspaceEvent
|
||||
} from '@hcengineering/core'
|
||||
import { PlatformError, unknownError } from '@hcengineering/platform'
|
||||
import type { DBAdapterManager, Middleware, PipelineContext, TxMiddlewareResult } from '@hcengineering/server-core'
|
||||
@@ -68,6 +72,22 @@ export class TxMiddleware extends BaseMiddleware implements Middleware {
|
||||
txes: Array.from(new Set(txToStore.map((it) => it._class)))
|
||||
}
|
||||
)
|
||||
// We need to remember last Tx Id in context, so it will be used during reconnect to track a requirement for refresh.
|
||||
this.context.lastTx = txToStore[txToStore.length - 1]._id
|
||||
// We need to deliver information to all clients so far.
|
||||
const evt: TxWorkspaceEvent = {
|
||||
_class: core.class.TxWorkspaceEvent,
|
||||
_id: generateId(),
|
||||
event: WorkspaceEvent.LastTx,
|
||||
modifiedBy: core.account.System,
|
||||
modifiedOn: Date.now(),
|
||||
objectSpace: core.space.DerivedTx,
|
||||
space: core.space.DerivedTx,
|
||||
params: {
|
||||
lastTx: this.context.lastTx
|
||||
}
|
||||
}
|
||||
;(ctx.contextData as SessionData).broadcast.txes.push(evt)
|
||||
}
|
||||
if (txPromise !== undefined) {
|
||||
await txPromise
|
||||
|
||||
Reference in New Issue
Block a user