mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
To support multiple instances, this PR removes some atoms and implements them using the new DI system. removed atom - `pageSettingsAtom` - `currentPageIdAtom` - `currentModeAtom`
32 lines
701 B
TypeScript
32 lines
701 B
TypeScript
import type {
|
|
GlobalState,
|
|
Workspace,
|
|
WorkspaceLocalState,
|
|
} from '@toeverything/infra';
|
|
|
|
export class WorkspaceLocalStateImpl implements WorkspaceLocalState {
|
|
constructor(
|
|
private readonly workspace: Workspace,
|
|
private readonly globalState: GlobalState
|
|
) {}
|
|
|
|
get<T>(key: string): T | null {
|
|
return this.globalState.get<T>(
|
|
`workspace-state:${this.workspace.id}:${key}`
|
|
);
|
|
}
|
|
|
|
watch<T>(key: string) {
|
|
return this.globalState.watch<T>(
|
|
`workspace-state:${this.workspace.id}:${key}`
|
|
);
|
|
}
|
|
|
|
set<T>(key: string, value: T | null): void {
|
|
return this.globalState.set<T>(
|
|
`workspace-state:${this.workspace.id}:${key}`,
|
|
value
|
|
);
|
|
}
|
|
}
|