mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
feat: temporary support loading data for public workspace
This commit is contained in:
@@ -13,7 +13,7 @@ import assert from 'assert';
|
||||
import { getLogger } from './logger';
|
||||
import { createBlocksuiteWorkspace } from './utils/index.js';
|
||||
import { MessageCenter } from './message';
|
||||
import type { WorkspaceUnit } from './workspace-unit';
|
||||
import { WorkspaceUnit } from './workspace-unit';
|
||||
|
||||
/**
|
||||
* @class DataCenter
|
||||
@@ -175,6 +175,29 @@ export class DataCenter {
|
||||
return workspaceUnit;
|
||||
}
|
||||
|
||||
public async loadPublicWorkspace(workspaceId: string) {
|
||||
const workspaceUnit = this._workspaceUnitCollection.find(workspaceId);
|
||||
assert(workspaceUnit, 'Workspace not found');
|
||||
const provider = this.providerMap.get(workspaceUnit.provider);
|
||||
assert(provider);
|
||||
const blocksuiteWorkspace = this._getBlocksuiteWorkspace(workspaceId);
|
||||
await provider.loadPublicWorkspace(blocksuiteWorkspace);
|
||||
|
||||
const workspaceUnitForPublic = new WorkspaceUnit({
|
||||
id: workspaceUnit.id,
|
||||
name: workspaceUnit.name,
|
||||
avatar: workspaceUnit.avatar,
|
||||
owner: workspaceUnit.owner,
|
||||
published: workspaceUnit.published,
|
||||
provider: workspaceUnit.provider,
|
||||
memberCount: workspaceUnit.memberCount,
|
||||
syncMode: workspaceUnit.syncMode,
|
||||
});
|
||||
|
||||
workspaceUnitForPublic.setBlocksuiteWorkspace(blocksuiteWorkspace);
|
||||
return workspaceUnitForPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* get user info by provider id
|
||||
* @param {string} providerId the provider name of workspace
|
||||
|
||||
@@ -116,6 +116,11 @@ export class AffineProvider extends BaseProvider {
|
||||
}
|
||||
}
|
||||
|
||||
override async loadPublicWorkspace(blocksuiteWorkspace: BlocksuiteWorkspace) {
|
||||
await this._applyCloudUpdates(blocksuiteWorkspace);
|
||||
return blocksuiteWorkspace;
|
||||
}
|
||||
|
||||
override async warpWorkspace(workspace: BlocksuiteWorkspace) {
|
||||
await this._applyCloudUpdates(workspace);
|
||||
const { room } = workspace;
|
||||
|
||||
@@ -75,6 +75,15 @@ export class BaseProvider {
|
||||
return workspace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Temporary for public workspace
|
||||
* @param blocksuiteWorkspace
|
||||
* @returns
|
||||
*/
|
||||
public async loadPublicWorkspace(blocksuiteWorkspace: BlocksuiteWorkspace) {
|
||||
return blocksuiteWorkspace;
|
||||
}
|
||||
|
||||
/**
|
||||
* load workspaces
|
||||
**/
|
||||
|
||||
Reference in New Issue
Block a user