mirror of
https://github.com/felvesthe/Note-Locker.git
synced 2026-07-22 05:44:06 +00:00
Add file existence check & fix an issue that allowed notifications to show even if disabled for strict lock
Signed-off-by: Felvesthe <23108389+Felvesthe@users.noreply.github.com>
This commit is contained in:
parent
cd4ecd7821
commit
7d377dc99d
1 changed files with 17 additions and 6 deletions
23
src/main.ts
23
src/main.ts
|
|
@ -409,15 +409,26 @@ export default class NoteLockerPlugin extends Plugin {
|
|||
async toggleStrictLock(notePath: string) {
|
||||
const isStrictLocked = this.settings.strictLockedNotes.has(notePath);
|
||||
|
||||
if (isStrictLocked) {
|
||||
this.settings.strictLockedNotes.delete(notePath);
|
||||
} else {
|
||||
this.settings.strictLockedNotes.add(notePath);
|
||||
}
|
||||
isStrictLocked
|
||||
? this.settings.strictLockedNotes.delete(notePath)
|
||||
: this.settings.strictLockedNotes.add(notePath);
|
||||
|
||||
await this.saveSettings();
|
||||
|
||||
new Notice(`${isStrictLocked ? '🔓 Strictly unlocked' : '🔒 Strictly locked'}: ${notePath}`);
|
||||
const file = this.app.vault.getAbstractFileByPath(notePath);
|
||||
|
||||
if (!file) {
|
||||
new Notice("Error: Note not found");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.settings.showNotifications) {
|
||||
const fileName = file instanceof TFile ? file.basename :
|
||||
notePath.split('/').pop()?.replace(/\..+$/, '') || notePath;
|
||||
const displayName = this.truncateFileName(fileName);
|
||||
|
||||
new Notice(`${isStrictLocked ? '🔓 Strictly unlocked' : '🔒 Strictly locked'}: ${displayName}`);
|
||||
}
|
||||
|
||||
this.updateAllNoteInstances(notePath);
|
||||
this.statusBarUI.updateStatusBarButton();
|
||||
|
|
|
|||
Loading…
Reference in a new issue