Files
AFFiNE/packages/frontend/core/src/modules/services.ts
pengx17 5490944d04 refactor(core): favorite adapter (#6285)
1. abstraction over favourites that supports different type of resources
2. sorting abstraction
2024-03-29 04:04:08 +00:00

45 lines
1.3 KiB
TypeScript

import type { ServiceCollection } from '@toeverything/infra';
import {
GlobalCache,
GlobalState,
PageRecordList,
Workspace,
WorkspaceScope,
} from '@toeverything/infra';
import { CollectionService } from './collection';
import {
LocalStorageGlobalCache,
LocalStorageGlobalState,
} from './infra-web/storage';
import { Navigator } from './navigation';
import { RightSidebar } from './right-sidebar/entities/right-sidebar';
import { TagService } from './tag';
import { Workbench } from './workbench';
import {
CurrentWorkspaceService,
FavoriteItemsAdapter,
WorkspaceLegacyProperties,
WorkspacePropertiesAdapter,
} from './workspace';
export function configureBusinessServices(services: ServiceCollection) {
services.add(CurrentWorkspaceService);
services
.scope(WorkspaceScope)
.add(Workbench)
.add(Navigator, [Workbench])
.add(RightSidebar, [GlobalState])
.add(WorkspacePropertiesAdapter, [Workspace])
.add(FavoriteItemsAdapter, [WorkspacePropertiesAdapter])
.add(CollectionService, [Workspace])
.add(WorkspaceLegacyProperties, [Workspace])
.add(TagService, [WorkspaceLegacyProperties, PageRecordList]);
}
export function configureWebInfraServices(services: ServiceCollection) {
services
.addImpl(GlobalCache, LocalStorageGlobalCache)
.addImpl(GlobalState, LocalStorageGlobalState);
}