mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +08:00
refactor(core): refactor atom to use di (#5831)
To support multiple instances, this PR removes some atoms and implements them using the new DI system. removed atom - `pageSettingsAtom` - `currentPageIdAtom` - `currentModeAtom`
This commit is contained in:
@@ -6,13 +6,14 @@ export * from './list';
|
||||
export * from './manager';
|
||||
export * from './metadata';
|
||||
export * from './service-scope';
|
||||
export * from './storage';
|
||||
export * from './testing';
|
||||
export * from './upgrade';
|
||||
export * from './workspace';
|
||||
|
||||
import { type ServiceCollection, ServiceProvider } from '../di';
|
||||
import { CleanupService } from '../lifecycle';
|
||||
import { GlobalCache, GlobalState } from '../storage';
|
||||
import { GlobalCache, GlobalState, MemoryMemento } from '../storage';
|
||||
import {
|
||||
BlockSuiteWorkspaceContext,
|
||||
RootYDocContext,
|
||||
@@ -33,6 +34,7 @@ import { WorkspaceFactory } from './factory';
|
||||
import { WorkspaceListProvider, WorkspaceListService } from './list';
|
||||
import { WorkspaceManager } from './manager';
|
||||
import { WorkspaceScope } from './service-scope';
|
||||
import { WorkspaceLocalState } from './storage';
|
||||
import {
|
||||
TestingLocalWorkspaceFactory,
|
||||
TestingLocalWorkspaceListProvider,
|
||||
@@ -83,5 +85,7 @@ export function configureTestingWorkspaceServices(services: ServiceCollection) {
|
||||
)
|
||||
.override(WorkspaceFactory('local'), TestingLocalWorkspaceFactory, [
|
||||
GlobalState,
|
||||
]);
|
||||
])
|
||||
.scope(WorkspaceScope)
|
||||
.override(WorkspaceLocalState, MemoryMemento);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { createIdentifier } from '../di';
|
||||
import type { Memento } from '../storage';
|
||||
|
||||
export interface WorkspaceLocalState extends Memento {}
|
||||
|
||||
export const WorkspaceLocalState = createIdentifier<WorkspaceLocalState>(
|
||||
'WorkspaceLocalState'
|
||||
);
|
||||
@@ -10,6 +10,8 @@ import { type WorkspaceMetadata } from './metadata';
|
||||
import type { WorkspaceUpgradeController } from './upgrade';
|
||||
import { type WorkspaceUpgradeStatus } from './upgrade';
|
||||
|
||||
export type { Workspace as BlockSuiteWorkspace } from '@blocksuite/store';
|
||||
|
||||
const logger = new DebugLogger('affine:workspace');
|
||||
|
||||
export type WorkspaceStatus = {
|
||||
|
||||
Reference in New Issue
Block a user