mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 10:36:22 +08:00
refactor: rename BlocksuiteWorkspace and WorkspaceInfo
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
import { Observable } from 'lib0/observable';
|
||||
import type { Workspace, WorkspaceMeta } from '../types';
|
||||
import type { WorkspaceInfo, WorkspaceMeta } from '../types';
|
||||
|
||||
export interface WorkspacesScope {
|
||||
get: (workspaceId: string) => Workspace | undefined;
|
||||
list: () => Workspace[];
|
||||
add: (workspace: Workspace) => void;
|
||||
get: (workspaceId: string) => WorkspaceInfo | undefined;
|
||||
list: () => WorkspaceInfo[];
|
||||
add: (workspace: WorkspaceInfo) => void;
|
||||
remove: (workspaceId: string) => boolean;
|
||||
clear: () => void;
|
||||
update: (workspaceId: string, workspaceMeta: Partial<WorkspaceMeta>) => void;
|
||||
}
|
||||
|
||||
export interface WorkspacesChangeEvent {
|
||||
added?: Workspace;
|
||||
deleted?: Workspace;
|
||||
updated?: Workspace;
|
||||
added?: WorkspaceInfo;
|
||||
deleted?: WorkspaceInfo;
|
||||
updated?: WorkspaceInfo;
|
||||
}
|
||||
|
||||
export class Workspaces extends Observable<'change'> {
|
||||
private _workspacesMap = new Map<string, Workspace>();
|
||||
private _workspacesMap = new Map<string, WorkspaceInfo>();
|
||||
|
||||
get workspaces(): Workspace[] {
|
||||
get workspaces(): WorkspaceInfo[] {
|
||||
return Array.from(this._workspacesMap.values());
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export class Workspaces extends Observable<'change'> {
|
||||
return this._workspacesMap.get(workspaceId);
|
||||
};
|
||||
|
||||
const add = (workspace: Workspace) => {
|
||||
const add = (workspace: WorkspaceInfo) => {
|
||||
if (this._workspacesMap.has(workspace.id)) {
|
||||
throw new Error(`Duplicate workspace id.`);
|
||||
}
|
||||
@@ -105,7 +105,7 @@ export class Workspaces extends Observable<'change'> {
|
||||
|
||||
// TODO: need to optimize
|
||||
const list = () => {
|
||||
const workspaces: Workspace[] = [];
|
||||
const workspaces: WorkspaceInfo[] = [];
|
||||
scopedWorkspaceIds.forEach(id => {
|
||||
const workspace = this._workspacesMap.get(id);
|
||||
if (workspace) {
|
||||
|
||||
Reference in New Issue
Block a user