mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
refactor(core): use new backlink indexer (#7296)
This commit is contained in:
@@ -29,6 +29,23 @@ export class DocRecordList extends Entity {
|
||||
[]
|
||||
);
|
||||
|
||||
public readonly trashDocs$ = LiveData.from<DocRecord[]>(
|
||||
this.store.watchTrashDocIds().pipe(
|
||||
map(ids =>
|
||||
ids.map(id => {
|
||||
const exists = this.pool.get(id);
|
||||
if (exists) {
|
||||
return exists;
|
||||
}
|
||||
const record = this.framework.createEntity(DocRecord, { id });
|
||||
this.pool.set(id, record);
|
||||
return record;
|
||||
})
|
||||
)
|
||||
),
|
||||
[]
|
||||
);
|
||||
|
||||
public readonly isReady$ = LiveData.from(
|
||||
this.store.watchDocListReady(),
|
||||
false
|
||||
|
||||
@@ -58,5 +58,6 @@ export class DocRecord extends Entity<{ id: string }> {
|
||||
}
|
||||
|
||||
title$ = this.meta$.map(meta => meta.title ?? '');
|
||||
|
||||
trash$ = this.meta$.map(meta => meta.trash ?? false);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,29 @@ export class DocsStore extends Store {
|
||||
return () => {
|
||||
dispose();
|
||||
};
|
||||
}).pipe(distinctUntilChanged((p, c) => isEqual(p, c)));
|
||||
});
|
||||
}
|
||||
|
||||
watchTrashDocIds() {
|
||||
return new Observable<string[]>(subscriber => {
|
||||
const emit = () => {
|
||||
subscriber.next(
|
||||
this.workspaceService.workspace.docCollection.meta.docMetas
|
||||
.map(v => (v.trash ? v.id : null))
|
||||
.filter(Boolean) as string[]
|
||||
);
|
||||
};
|
||||
|
||||
emit();
|
||||
|
||||
const dispose =
|
||||
this.workspaceService.workspace.docCollection.meta.docMetaUpdated.on(
|
||||
emit
|
||||
).dispose;
|
||||
return () => {
|
||||
dispose();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
watchDocMeta(id: string) {
|
||||
|
||||
@@ -233,7 +233,6 @@ export class IndexedDBJobQueue<J> implements JobQueue<J> {
|
||||
fromPromise(async () => {
|
||||
const trx = this.database.transaction(['jobs'], 'readonly');
|
||||
const remaining = await trx.objectStore('jobs').count();
|
||||
console.log(remaining);
|
||||
return { remaining };
|
||||
})
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user