fix: add gettoken on affine provider

This commit is contained in:
DiamondThree 2023-02-02 18:30:36 +08:00
parent 82c261767f
commit fca165c672
4 changed files with 12 additions and 5 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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();
};

View File

@ -64,6 +64,10 @@ export class BaseProvider {
return;
}
public getToken(): string {
return '';
}
/**
* warp workspace with provider functions
* @param workspace