mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-15 00:56:26 +08:00
Merge branch 'feat/cloud-sync-saika' into feat/datacenter-dev
This commit is contained in:
@@ -122,8 +122,8 @@ export class DataCenter {
|
||||
* @param {string} workspaceId workspace id
|
||||
*/
|
||||
private _getBlocksuiteWorkspace(workspaceId: string) {
|
||||
const workspaceInfo = this._workspaceUnitCollection.find(workspaceId);
|
||||
assert(workspaceInfo, 'Workspace not found');
|
||||
// const workspaceInfo = this._workspaceUnitCollection.find(workspaceId);
|
||||
// assert(workspaceInfo, 'Workspace not found');
|
||||
return (
|
||||
// this._workspaceInstances.get(workspaceId) ||
|
||||
createBlocksuiteWorkspace(workspaceId)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,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