mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
fix: add param for download public workspace
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user