mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 04:43:20 +03:00
chore: improve docs
This commit is contained in:
parent
2ee99a37fb
commit
4b5e209ecc
@ -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 = {}
|
||||
|
@ -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
|
||||
|
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user