fix: add param for download public workspace

This commit is contained in:
alt0
2023-01-11 20:53:53 +08:00
parent bda94bb865
commit 2d1fd3a083
2 changed files with 11 additions and 4 deletions

View File

@@ -104,10 +104,13 @@ export class AffineProvider extends BaseProvider {
return ws;
}
private async _applyCloudUpdates(blocksuiteWorkspace: BlocksuiteWorkspace) {
private async _applyCloudUpdates(
blocksuiteWorkspace: BlocksuiteWorkspace,
published = false
) {
const { doc, room: workspaceId } = blocksuiteWorkspace;
assert(workspaceId, 'Blocksuite Workspace without room(workspaceId).');
const updates = await this._apis.downloadWorkspace(workspaceId);
const updates = await this._apis.downloadWorkspace(workspaceId, published);
if (updates && updates.byteLength) {
await new Promise(resolve => {
doc.once('update', resolve);
@@ -117,7 +120,7 @@ export class AffineProvider extends BaseProvider {
}
override async loadPublicWorkspace(blocksuiteWorkspace: BlocksuiteWorkspace) {
await this._applyCloudUpdates(blocksuiteWorkspace);
await this._applyCloudUpdates(blocksuiteWorkspace, true);
return blocksuiteWorkspace;
}

View File

@@ -169,7 +169,11 @@ export async function leaveWorkspace({ id }: LeaveWorkspaceParams) {
}
export async function downloadWorkspace(
workspaceId: string
workspaceId: string,
published = false
): Promise<ArrayBuffer> {
if (published) {
return bareClient.get(`api/workspace/${workspaceId}/doc`).arrayBuffer();
}
return client.get(`api/workspace/${workspaceId}/doc`).arrayBuffer();
}