From 0ef6ece62cbfb310efacc09af9f31e74b3e2fa09 Mon Sep 17 00:00:00 2001 From: Lost Paul <70213368+LostPaul@users.noreply.github.com> Date: Fri, 9 Jun 2023 17:25:57 +0200 Subject: [PATCH] Fixed folder note delete button --- src/folderNoteFunctions.ts | 6 ++++-- src/modals/deleteConfirmation.ts | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/folderNoteFunctions.ts b/src/folderNoteFunctions.ts index 0516512..365a465 100644 --- a/src/folderNoteFunctions.ts +++ b/src/folderNoteFunctions.ts @@ -90,9 +90,11 @@ export async function openFolderNote(plugin: FolderNotesPlugin, file: TAbstractF export async function deleteFolderNote(plugin: FolderNotesPlugin, file: TFile) { if (plugin.settings.showDeleteConfirmation) { - return new DeleteConfirmationModal(plugin.app, this, file).open(); + return new DeleteConfirmationModal(plugin.app, plugin, file).open(); } - plugin.removeCSSClassFromEL(file.parent.path, 'has-folder-note'); + const folder = getFolder(plugin, file); + if (!folder) return; + plugin.removeCSSClassFromEL(folder.path, 'has-folder-note'); await plugin.app.vault.delete(file); } diff --git a/src/modals/deleteConfirmation.ts b/src/modals/deleteConfirmation.ts index f2ee93b..884bd16 100644 --- a/src/modals/deleteConfirmation.ts +++ b/src/modals/deleteConfirmation.ts @@ -1,5 +1,6 @@ import { App, Modal, Setting, TFile, Platform } from 'obsidian'; import FolderNotesPlugin from '../main'; +import { getFolder } from 'src/folderNoteFunctions'; export default class DeleteConfirmationModal extends Modal { plugin: FolderNotesPlugin; app: App; @@ -28,7 +29,9 @@ export default class DeleteConfirmationModal extends Modal { this.plugin.settings.showDeleteConfirmation = false; this.plugin.saveSettings(); this.close(); - this.plugin.removeCSSClassFromEL(this.file.parent.path, 'has-folder-note'); + const folder = getFolder(this.plugin, this.file); + if (!folder) return; + this.plugin.removeCSSClassFromEL(folder?.path, 'has-folder-note'); this.app.vault.delete(this.file); }); } else {