feat: add query members

This commit is contained in:
MingLiang Wang 2023-01-11 12:34:57 +08:00
parent cdf07fd7c2
commit 48264edf91
3 changed files with 30 additions and 1 deletions

View File

@ -384,6 +384,20 @@ export class DataCenter {
return (await blobStorage?.set(blob)) || '';
}
/**
* get members of a workspace
* @param workspaceId
*/
async getMembers(workspaceId: string) {
const workspaceInfo = this._workspaceUnitCollection.find(workspaceId);
assert(workspaceInfo, 'Workspace not found');
const provider = this.providerMap.get(workspaceInfo.provider);
if (provider) {
return await provider.getWorkspaceMembers(workspaceId);
}
return [];
}
onMessage(cb: (message: Message) => void) {
return this._messageCenter.onMessage(cb);
}

View File

@ -12,7 +12,7 @@ import { storage } from './storage.js';
import assert from 'assert';
import { WebsocketProvider } from './sync.js';
// import { IndexedDBProvider } from '../local/indexeddb';
import { getApis } from './apis/index.js';
import { getApis, Member } from './apis/index.js';
import type { Apis, WorkspaceDetail, Callback } from './apis';
import { setDefaultAvatar } from '../utils.js';
import { MessageCode } from '../../message';
@ -365,4 +365,8 @@ export class AffineProvider extends BaseProvider {
token.clear();
storage.removeItem('token');
}
public override async getWorkspaceMembers(id: string) {
return this._apis.getWorkspaceMembers({ id });
}
}

View File

@ -3,6 +3,7 @@ import { MessageCenter } from '../message';
import { Logger, User } from '../types';
import type { WorkspaceUnitCollectionScope } from '../workspace-unit-collection';
import type { WorkspaceUnitCtorParams } from '../workspace-unit';
import { Member } from './affine/apis';
const defaultLogger = () => {
return;
@ -213,4 +214,14 @@ export class BaseProvider {
from;
return to;
}
/**
* get workspace members
* @param {string} workspaceId
* @returns
*/
public getWorkspaceMembers(workspaceId: string): Promise<Member[]> {
workspaceId;
return Promise.resolve([]);
}
}