feat: workspace list by provider

This commit is contained in:
DarkSky
2023-01-03 22:22:37 +08:00
parent 4b5e209ecc
commit 43e52fffe7
6 changed files with 138 additions and 47 deletions
@@ -1,7 +1,7 @@
import type { BlobStorage } from '@blocksuite/store';
import assert from 'assert';
import type { InitialParams } from '../index.js';
import type { ConfigStore, InitialParams } from '../index.js';
import { BaseProvider } from '../base.js';
import { IndexedDBProvider } from './indexeddb.js';
@@ -31,12 +31,15 @@ export class LocalProvider extends BaseProvider {
await this._idb.whenSynced;
this._logger('Local data loaded');
await this._globalConfig.set(this._workspace.room, true);
}
async clear() {
await super.clear();
await this._blobs.clear();
await this._idb?.clearData();
await this._globalConfig.delete(this._workspace.room!);
}
async destroy(): Promise<void> {
@@ -51,4 +54,11 @@ export class LocalProvider extends BaseProvider {
async setBlob(blob: Blob): Promise<string> {
return this._blobs.set(blob);
}
static async list(
config: Readonly<ConfigStore<boolean>>
): Promise<Map<string, boolean> | undefined> {
const entries = await config.entries();
return new Map(entries);
}
}