diff --git a/packages/data-center/src/datacenter.ts b/packages/data-center/src/datacenter.ts index e4fe394c71..8e70718c36 100644 --- a/packages/data-center/src/datacenter.ts +++ b/packages/data-center/src/datacenter.ts @@ -186,7 +186,7 @@ export class DataCenter { */ public async onWorkspacesChange( callback: (workspaces: WorkspaceUnitCollectionChangeEvent) => void, - { immediate = true }: { immediate?: boolean } + { immediate = true }: { immediate?: boolean } = {} ) { if (immediate) { callback({ diff --git a/packages/data-center/src/provider/affine/affine.ts b/packages/data-center/src/provider/affine/affine.ts index cbe5adef18..890fc6dc00 100644 --- a/packages/data-center/src/provider/affine/affine.ts +++ b/packages/data-center/src/provider/affine/affine.ts @@ -16,6 +16,7 @@ import { getApis } from './apis/index.js'; import type { Apis, WorkspaceDetail, Callback } from './apis'; import { setDefaultAvatar } from '../utils.js'; import { MessageCode } from '../../message'; +import { blob } from 'stream/consumers'; export interface AffineProviderConstructorParams extends ProviderConstructorParams { @@ -348,9 +349,10 @@ export class AffineProvider extends BaseProvider { assert(to.room, 'Blocksuite Workspace without room(workspaceId).'); const ws = this._getWebsocketProvider(to); applyUpdate(to.doc, encodeStateAsUpdate(from.doc)); + // TODO: upload blobs and make sure doc is synced await new Promise((resolve, reject) => { ws.once('synced', () => { - resolve(); + setTimeout(() => resolve(), 1000); }); ws.once('lost-connection', () => reject()); ws.once('connection-error', () => reject());