fixbug: [issue76]when click activities button, throw error;

This commit is contained in:
mitsuha
2022-08-04 18:34:47 +08:00
parent c63d5da4df
commit 9ec41c013b
3 changed files with 36 additions and 36 deletions

View File

@@ -3,6 +3,7 @@ import { ServiceBaseClass } from '../base';
import { ObserveCallback, ReturnUnobserve } from '../database';
import { PageTree } from './page-tree';
import { PageConfigItem } from './types';
import { QueryIndexMetadata } from '@toeverything/datasource/jwt';
/** Operate the user configuration at the workspace level */
export class UserConfig extends ServiceBaseClass {
@@ -122,4 +123,20 @@ export class UserConfig extends ServiceBaseClass {
const workspaceDbBlock = await this.getWorkspaceDbBlock(workspace);
workspaceDbBlock.setDecoration(WORKSPACE_CONFIG, workspaceName);
}
async getRecentEditedPages(workspace: string) {
const db = await this.database.getDatabase(workspace);
const recentEditedPages =
(await db.queryBlocks({
$sort: 'lastUpdated',
$desc: false /* sort rule: true(default)(ASC), or false(DESC) */,
$limit: 4,
flavor: 'page',
} as QueryIndexMetadata)) || [];
return recentEditedPages.map(item => {
item['title'] = item.content || 'Untitled';
return item;
});
}
}