mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
feat(core): edit and delete pinned collections in all docs (#12296)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added the ability to edit and remove pinned collections directly from the workspace UI. - Improved filter management with clearer handling of temporary filters and editing workflows. - Enhanced synchronization and readiness tracking for collections and pinned collections, resulting in more responsive and reliable updates. - **Style** - Updated pinned collection item styles for better interaction feedback, including new edit and remove button visuals. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -19,6 +19,11 @@ export class CollectionService extends Service {
|
||||
},
|
||||
});
|
||||
|
||||
readonly collectionDataReady$ = LiveData.from(
|
||||
this.store.watchCollectionDataReady(),
|
||||
false
|
||||
);
|
||||
|
||||
// collection metas used in collection list, only include `id` and `name`, without `rules` and `allowList`
|
||||
readonly collectionMetas$ = LiveData.from(
|
||||
this.store.watchCollectionMetas(),
|
||||
|
||||
@@ -14,6 +14,11 @@ export class PinnedCollectionService extends Service {
|
||||
super();
|
||||
}
|
||||
|
||||
pinnedCollectionDataReady$ = LiveData.from(
|
||||
this.pinnedCollectionStore.watchPinnedCollectionDataReady(),
|
||||
false
|
||||
);
|
||||
|
||||
pinnedCollections$ = LiveData.from<PinnedCollectionRecord[]>(
|
||||
this.pinnedCollectionStore.watchPinnedCollections(),
|
||||
[]
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from '@toeverything/infra';
|
||||
import dayjs from 'dayjs';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { map, type Observable, switchMap } from 'rxjs';
|
||||
import { distinctUntilChanged, map, type Observable, switchMap } from 'rxjs';
|
||||
import { Array as YArray } from 'yjs';
|
||||
|
||||
import type { FilterParams } from '../../collection-rules';
|
||||
@@ -35,6 +35,17 @@ export class CollectionStore extends Store {
|
||||
return this.rootYDoc.getMap('setting');
|
||||
}
|
||||
|
||||
watchCollectionDataReady() {
|
||||
return this.workspaceService.workspace.engine.doc
|
||||
.docState$(this.workspaceService.workspace.id)
|
||||
.pipe(
|
||||
map(docState => {
|
||||
return docState.ready;
|
||||
}),
|
||||
distinctUntilChanged()
|
||||
);
|
||||
}
|
||||
|
||||
watchCollectionMetas() {
|
||||
return yjsGetPath(this.workspaceSettingYMap, 'collections').pipe(
|
||||
switchMap(yjsObserveDeep),
|
||||
|
||||
@@ -13,6 +13,10 @@ export class PinnedCollectionStore extends Store {
|
||||
super();
|
||||
}
|
||||
|
||||
watchPinnedCollectionDataReady() {
|
||||
return this.workspaceDBService.db.pinnedCollections.isReady$;
|
||||
}
|
||||
|
||||
watchPinnedCollections(): Observable<PinnedCollectionRecord[]> {
|
||||
return this.workspaceDBService.db.pinnedCollections.find$();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import type {
|
||||
TableSchemaBuilder,
|
||||
} from '@toeverything/infra';
|
||||
import { Entity, LiveData } from '@toeverything/infra';
|
||||
import { map } from 'rxjs';
|
||||
import { distinctUntilChanged, map } from 'rxjs';
|
||||
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
|
||||
@@ -19,10 +19,23 @@ export class WorkspaceDBTable<
|
||||
super();
|
||||
}
|
||||
|
||||
isReady$ = LiveData.from(
|
||||
this.workspaceService.workspace.engine.doc
|
||||
.docState$(this.props.storageDocId)
|
||||
.pipe(
|
||||
map(docState => docState.ready),
|
||||
distinctUntilChanged()
|
||||
),
|
||||
false
|
||||
);
|
||||
|
||||
isSyncing$ = LiveData.from(
|
||||
this.workspaceService.workspace.engine.doc
|
||||
.docState$(this.props.storageDocId)
|
||||
.pipe(map(docState => docState.syncing)),
|
||||
.pipe(
|
||||
map(docState => docState.syncing),
|
||||
distinctUntilChanged()
|
||||
),
|
||||
false
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user