There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix: duplicate api call for cloud workspace (#928)
zuomeng wang5a93b26cc30b
diff --git a/packages/data-center/src/provider/affine/affine.ts b/packages/data-center/src/provider/affine/affine.tsindex ee596675c2..e8e564e090 100644--- a/packages/data-center/src/provider/affine/affine.ts+++ b/packages/data-center/src/provider/affine/affine.ts@@ -45,6 +45,7 @@ export class AffineProvider extends BaseProvider {private _apis: Apis;private _channel?: WebsocketClient;// private _idbMap: Map<string, IndexedDBProvider> = new Map();+ private _workspaceLoadingQueue: Set<string> = new Set();constructor({ apis, ...params }: AffineProviderConstructorParams) {super(params);@@ -145,11 +146,13 @@ export class AffineProvider extends BaseProvider {// update workspacesthis._workspaces.update(id, workspace);} else {- const workspaceUnit = await loadWorkspaceUnit(- { id, ...workspace },- this._apis- );- newlyCreatedWorkspaces.push(workspaceUnit);+ if (!this._workspaceLoadingQueue.has(id)) {+ const workspaceUnit = await loadWorkspaceUnit(+ { id, ...workspace },+ this._apis+ );+ newlyCreatedWorkspaces.push(workspaceUnit);+ }}} else {console.log(`[log warn] ${id} name is empty`);@@ -204,6 +207,7 @@ export class AffineProvider extends BaseProvider {}override async warpWorkspace(workspace: BlocksuiteWorkspace) {+ // FIXME: if add indexedDB cache in the future, can remove following line.await this._applyCloudUpdates(workspace);const { room } = workspace;assert(room);@@ -234,6 +238,7 @@ export class AffineProvider extends BaseProvider {const workspacesList = await this._apis.getWorkspaces();const workspaceUnits = await Promise.all(workspacesList.map(w => {+ this._workspaceLoadingQueue.add(w.id);return loadWorkspaceUnit({id: w.id,@@ -246,7 +251,9 @@ export class AffineProvider extends BaseProvider {syncMode: 'core',},this._apis- );+ ).finally(() => {+ this._workspaceLoadingQueue.delete(w.id);+ });}));this._workspaces.add(workspaceUnits);