From fb450e4c2357f028ca8a866bc765a5c1cd0892d9 Mon Sep 17 00:00:00 2001 From: johackim Date: Wed, 7 Dec 2022 15:35:56 +0100 Subject: [PATCH] refactor: add native obsidian api functions --- src/views/chapters.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/chapters.js b/src/views/chapters.js index fd8d308..aea4b98 100644 --- a/src/views/chapters.js +++ b/src/views/chapters.js @@ -50,9 +50,9 @@ export default class ChaptersView extends ItemView { }); navFile.addEventListener('click', async () => { - const targetFile = this.app.vault.getMarkdownFiles().find((f) => f.path === `${chapter}.md`) + const targetFile = this.app.vault.getAbstractFileByPath(`${chapter}.md`) || await this.app.vault.create(`${chapter}.md`, ''); - const leaf = this.app.workspace.getMostRecentLeaf(); + const leaf = this.app.workspace.getLeaf(); leaf.openFile(targetFile); }); }