From fca165c672ad000c1504f41e66fb6aeff0c71da7 Mon Sep 17 00:00:00 2001 From: DiamondThree <857159145@qq.com> Date: Thu, 2 Feb 2023 18:30:36 +0800 Subject: [PATCH] fix: add gettoken on affine provider --- packages/data-center/src/datacenter.ts | 3 +-- packages/data-center/src/provider/affine/affine.ts | 4 ++++ packages/data-center/src/provider/affine/utils.ts | 6 +++--- packages/data-center/src/provider/base.ts | 4 ++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/data-center/src/datacenter.ts b/packages/data-center/src/datacenter.ts index 1cca635886..d843900073 100644 --- a/packages/data-center/src/datacenter.ts +++ b/packages/data-center/src/datacenter.ts @@ -17,7 +17,6 @@ import { getLogger } from './logger'; import { createBlocksuiteWorkspace } from './utils/index.js'; import { MessageCenter } from './message'; import { WorkspaceUnit } from './workspace-unit'; -import { token } from './provider/affine/apis/token'; /** * @class DataCenter * @classdesc Data center is made for managing different providers for business @@ -169,7 +168,7 @@ export class DataCenter { const params: StoreOptions = {}; if (provider.id === 'affine') { params.blobOptionsGetter = (k: string) => - ({ api: '/api/workspace', token: token.token }[k]); + ({ api: '/api/workspace', token: provider.getToken() }[k]); } else { params.blobOptionsGetter = (k: string) => undefined; } diff --git a/packages/data-center/src/provider/affine/affine.ts b/packages/data-center/src/provider/affine/affine.ts index d4c786f461..01ff6b0a78 100644 --- a/packages/data-center/src/provider/affine/affine.ts +++ b/packages/data-center/src/provider/affine/affine.ts @@ -360,6 +360,10 @@ export class AffineProvider extends BaseProvider { await this._apis.updateWorkspace({ id, public: isPublish }); } + public override getToken(): string { + return this._apis.token.token; + } + public override async getUserByEmail( workspace_id: string, email: string diff --git a/packages/data-center/src/provider/affine/utils.ts b/packages/data-center/src/provider/affine/utils.ts index 25e2127e50..6e4387f240 100644 --- a/packages/data-center/src/provider/affine/utils.ts +++ b/packages/data-center/src/provider/affine/utils.ts @@ -82,7 +82,7 @@ export const migrateBlobDB = async ( return [id, { id, blob }] as [string, PendingTask]; }); await newPendingDB.setMany(pendingEntries); - - await oldDB.deleteDB(); - await oldPendingDB.deleteDB(); + // FIXME: delete old db + // await oldDB.deleteDB(); + // await oldPendingDB.deleteDB(); }; diff --git a/packages/data-center/src/provider/base.ts b/packages/data-center/src/provider/base.ts index eb9a68d748..38d1cc4782 100644 --- a/packages/data-center/src/provider/base.ts +++ b/packages/data-center/src/provider/base.ts @@ -64,6 +64,10 @@ export class BaseProvider { return; } + public getToken(): string { + return ''; + } + /** * warp workspace with provider functions * @param workspace