Add locked note's rename handling

Signed-off-by: Felvesthe <23108389+Felvesthe@users.noreply.github.com>
This commit is contained in:
Felvesthe 2025-03-24 20:18:40 +01:00
parent 8c1788f259
commit 9012fba28f

13
main.ts
View file

@ -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() {