From c59f59b7934b4550eba159bf72888da23f70cdba Mon Sep 17 00:00:00 2001 From: Lost Paul <70213368+LostPaul@users.noreply.github.com> Date: Fri, 16 Jun 2023 22:05:07 +0200 Subject: [PATCH] Check if note is already a folder note --- src/commands.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index aaeaf4b..c912294 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -64,6 +64,9 @@ export class Commands { })); this.plugin.registerEvent(this.app.workspace.on('file-menu', (menu: Menu, file: TAbstractFile) => { if (file instanceof TFile) { + const folder = file.parent; + const folderNote = getFolderNote(this.plugin, folder.path); + if (folderNote?.path === file.path) { return; } menu.addItem((item) => { item.setTitle('Create folder note') .setIcon('edit') @@ -82,10 +85,7 @@ export class Commands { }); }); if (this.plugin.getFolderPathFromString(file.path) === '') return; - const folder = file.parent; if (!(folder instanceof TFolder)) return; - const folderNote = getFolderNote(this.plugin, folder.path); - if (folderNote?.path === file.path) { return; } menu.addItem((item) => { item.setTitle('Turn into folder note') .setIcon('edit')