mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-18 21:31:37 +03:00
feat: pageTreeName
This commit is contained in:
parent
78ef250ee1
commit
93c460f6a5
@ -1,5 +1,5 @@
|
|||||||
import type { BlockClientInstance } from '@toeverything/datasource/jwt';
|
import type { BlockClientInstance } from '@toeverything/datasource/jwt';
|
||||||
import { PAGE_TREE } from '../../utils';
|
import { PAGE_TREE as pageTreeName } from '../../utils';
|
||||||
import type { ReturnUnobserve } from '../database/observer';
|
import type { ReturnUnobserve } from '../database/observer';
|
||||||
import { ServiceBaseClass } from '../base';
|
import { ServiceBaseClass } from '../base';
|
||||||
import { TreeItem } from './types';
|
import { TreeItem } from './types';
|
||||||
@ -9,20 +9,20 @@ export type ObserveCallback = () => void;
|
|||||||
export class PageTree extends ServiceBaseClass {
|
export class PageTree extends ServiceBaseClass {
|
||||||
private async fetchPageTree<TreeItem>(workspace: string) {
|
private async fetchPageTree<TreeItem>(workspace: string) {
|
||||||
const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace);
|
const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace);
|
||||||
const PAGE_TREEConfig =
|
const pageTreeConfig =
|
||||||
workspaceDbBlock.getDecoration<TreeItem[]>(PAGE_TREE);
|
workspaceDbBlock.getDecoration<TreeItem[]>(pageTreeName);
|
||||||
return PAGE_TREEConfig;
|
return pageTreeConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPageTree<TreeItem>(workspace: string): Promise<TreeItem[]> {
|
async getPageTree<TreeItem>(workspace: string): Promise<TreeItem[]> {
|
||||||
try {
|
try {
|
||||||
const PAGE_TREE = await this.fetchPageTree(workspace);
|
const pageTree = await this.fetchPageTree(workspace);
|
||||||
if (PAGE_TREE && PAGE_TREE.length) {
|
if (pageTree && pageTree.length) {
|
||||||
const db = await this.database.getDatabase(workspace);
|
const db = await this.database.getDatabase(workspace);
|
||||||
|
|
||||||
const pages = await updateTreeItemsTitle(
|
const pages = await updateTreeItemsTitle(
|
||||||
db,
|
db,
|
||||||
PAGE_TREE as [],
|
pageTree as [],
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
return pages;
|
return pages;
|
||||||
@ -37,7 +37,7 @@ export class PageTree extends ServiceBaseClass {
|
|||||||
/** @deprecated should implement more fine-grained crud methods instead of replacing each time with a new array */
|
/** @deprecated should implement more fine-grained crud methods instead of replacing each time with a new array */
|
||||||
async setPageTree<TreeItem>(workspace: string, treeData: TreeItem[]) {
|
async setPageTree<TreeItem>(workspace: string, treeData: TreeItem[]) {
|
||||||
const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace);
|
const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace);
|
||||||
workspaceDbBlock.setDecoration(PAGE_TREE, treeData);
|
workspaceDbBlock.setDecoration(pageTreeName, treeData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async addPage<TreeItem>(workspace: string, treeData: TreeItem[] | string) {
|
async addPage<TreeItem>(workspace: string, treeData: TreeItem[] | string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user