Skip to content

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.

chore: improve docs

DarkSky4b5e209eccf5
diff --git a/packages/data-center/src/datacenter.ts b/packages/data-center/src/datacenter.ts
index b43a7c7b61..fc836c19ac 100644
--- a/packages/data-center/src/datacenter.ts
+++ b/packages/data-center/src/datacenter.ts
@@ -83,7 +83,7 @@ export class DataCenter {
return provider;
}
- async setConfig(workspace: string, config: Record<string, any>) {
+ private async _setConfig(workspace: string, config: Record<string, any>) {
const values = Object.entries(config);
if (values.length) {
const configure = getKVConfigure(workspace);
@@ -101,7 +101,7 @@ export class DataCenter {
if (!this._workspaces.has(workspaceId)) {
this._workspaces.set(
workspaceId,
- this.setConfig(workspaceId, config).then(() =>
+ this._setConfig(workspaceId, config).then(() =>
this._getWorkspace(workspaceId, providerId)
)
);
@@ -122,6 +122,7 @@ export class DataCenter {
}
}
+ // reload new workspace instance to memory to refresh config
async reload(
workspaceId: string,
config: LoadConfig = {}
diff --git a/packages/data-center/src/provider/affine/index.ts b/packages/data-center/src/provider/affine/index.ts
index e203606d2b..fef7a4d0a9 100644
--- a/packages/data-center/src/provider/affine/index.ts
+++ b/packages/data-center/src/provider/affine/index.ts
@@ -51,9 +51,7 @@ export class AffineProvider extends LocalProvider {
if (this._onTokenRefresh) {
token.offChange(this._onTokenRefresh);
}
- if (this._ws) {
- this._ws.disconnect();
- }
+ this._ws?.disconnect();
}
async initData() {
@@ -72,9 +70,8 @@ export class AffineProvider extends LocalProvider {
doc.once('update', resolve);
applyUpdate(doc, new Uint8Array(updates));
});
- // TODO: wait util data loaded
- this._ws = new WebsocketProvider('/', workspace.room, doc);
// Wait for ws synchronization to complete, otherwise the data will be modified in reverse, which can be optimized later
+ this._ws = new WebsocketProvider('/', workspace.room, doc);
await new Promise<void>((resolve, reject) => {
// TODO: synced will also be triggered on reconnection after losing sync
// There needs to be an event mechanism to emit the synchronization state to the upper layer
diff --git a/packages/data-center/src/provider/local/index.ts b/packages/data-center/src/provider/local/index.ts
index 5c3a89f23a..363b50b89e 100644
--- a/packages/data-center/src/provider/local/index.ts
+++ b/packages/data-center/src/provider/local/index.ts
@@ -36,14 +36,12 @@ export class LocalProvider extends BaseProvider {
async clear() {
await super.clear();
await this._blobs.clear();
- this._idb?.clearData();
+ await this._idb?.clearData();
}
async destroy(): Promise<void> {
super.destroy();
- if (this._idb) {
- await this._idb.destroy();
- }
+ await this._idb?.destroy();
}
async getBlob(id: string): Promise<string | null> {