From 9012fba28fc23206aa58565d6b495b04ddae38e1 Mon Sep 17 00:00:00 2001 From: Felvesthe <23108389+Felvesthe@users.noreply.github.com> Date: Mon, 24 Mar 2025 20:18:40 +0100 Subject: [PATCH] Add locked note's rename handling Signed-off-by: Felvesthe <23108389+Felvesthe@users.noreply.github.com> --- main.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.ts b/main.ts index a431477..dc04da3 100644 --- a/main.ts +++ b/main.ts @@ -39,6 +39,19 @@ export default class NoteLockerPlugin extends Plugin { this.updateLeafMode(leaf) ) ); + + this.registerEvent( + this.app.vault.on("rename", async (file, oldPath) => { + if (this.settings.lockedNotes.delete(oldPath)) { + if (!this.settings.lockedNotes.has(file.path)) { + this.settings.lockedNotes.add(file.path); + } else { + new Notice(`⚠️ Lock skipped: "${file.name}" was already locked`); + } + await this.saveSettings(); + } + }) + ); } private initializeExistingLeaves() {