feat(infra): framework
This commit is contained in:
@@ -1 +1,15 @@
|
||||
export * from './service';
|
||||
export { CollectionService } from './services/collection';
|
||||
|
||||
import {
|
||||
type Framework,
|
||||
WorkspaceScope,
|
||||
WorkspaceService,
|
||||
} from '@toeverything/infra';
|
||||
|
||||
import { CollectionService } from './services/collection';
|
||||
|
||||
export function configureCollectionModule(framework: Framework) {
|
||||
framework
|
||||
.scope(WorkspaceScope)
|
||||
.service(CollectionService, [WorkspaceService]);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ import type {
|
||||
DeleteCollectionInfo,
|
||||
DeletedCollection,
|
||||
} from '@affine/env/filter';
|
||||
import type { Workspace } from '@toeverything/infra';
|
||||
import { LiveData } from '@toeverything/infra';
|
||||
import type { WorkspaceService } from '@toeverything/infra';
|
||||
import { LiveData, Service } from '@toeverything/infra';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Array as YArray } from 'yjs';
|
||||
|
||||
@@ -13,15 +13,19 @@ const SETTING_KEY = 'setting';
|
||||
const COLLECTIONS_KEY = 'collections';
|
||||
const COLLECTIONS_TRASH_KEY = 'collections_trash';
|
||||
|
||||
export class CollectionService {
|
||||
constructor(private readonly workspace: Workspace) {}
|
||||
export class CollectionService extends Service {
|
||||
constructor(private readonly workspaceService: WorkspaceService) {
|
||||
super();
|
||||
}
|
||||
|
||||
private get doc() {
|
||||
return this.workspace.docCollection.doc;
|
||||
return this.workspaceService.workspace.docCollection.doc;
|
||||
}
|
||||
|
||||
private get setting() {
|
||||
return this.workspace.docCollection.doc.getMap(SETTING_KEY);
|
||||
return this.workspaceService.workspace.docCollection.doc.getMap(
|
||||
SETTING_KEY
|
||||
);
|
||||
}
|
||||
|
||||
private get collectionsYArray(): YArray<Collection> | undefined {
|
||||
@@ -105,7 +109,7 @@ export class CollectionService {
|
||||
return;
|
||||
}
|
||||
const set = new Set(ids);
|
||||
this.workspace.docCollection.doc.transact(() => {
|
||||
this.workspaceService.workspace.docCollection.doc.transact(() => {
|
||||
const indexList: number[] = [];
|
||||
const list: Collection[] = [];
|
||||
collectionsYArray.forEach((collection, i) => {
|
||||
Reference in New Issue
Block a user