diff --git a/src/main.ts b/src/main.ts index cd21d85..029f9ea 100644 --- a/src/main.ts +++ b/src/main.ts @@ -147,11 +147,13 @@ export default class NoteLockerPlugin extends Plugin { return; } - const fileName = file instanceof TFile ? file.basename : - notePath.split('/').pop()?.replace(/\..+$/, '') || notePath; - const displayName = this.truncateFileName(fileName); + if (this.settings.showNotifications) { + const fileName = file instanceof TFile ? file.basename : + notePath.split('/').pop()?.replace(/\..+$/, '') || notePath; + const displayName = this.truncateFileName(fileName); - new Notice(`${isLocked ? '🔓 Unlocked' : '🔒 Locked'}: ${displayName}`); + new Notice(`${isLocked ? '🔓 Unlocked' : '🔒 Locked'}: ${displayName}`); + } this.updateAllNoteInstances(notePath); this.statusBarUI.updateStatusBarButton(); diff --git a/src/models/types.ts b/src/models/types.ts index 283d288..ff5cd88 100644 --- a/src/models/types.ts +++ b/src/models/types.ts @@ -4,6 +4,7 @@ export interface NoteLockerSettings { desktopNotificationMaxLength: number; showFileExplorerIcons: boolean; showStatusBarButton: boolean; + showNotifications: boolean; } export const DEFAULT_SETTINGS: NoteLockerSettings = { @@ -11,5 +12,6 @@ export const DEFAULT_SETTINGS: NoteLockerSettings = { mobileNotificationMaxLength: 18, desktopNotificationMaxLength: 22, showFileExplorerIcons: true, - showStatusBarButton: true + showStatusBarButton: true, + showNotifications: true }; diff --git a/src/settings.ts b/src/settings.ts index d34c2db..d9f20df 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -31,6 +31,16 @@ export class NoteLockerSettingTab extends PluginSettingTab { await this.plugin.updateStatusBarVisibility(value); })); + new Setting(containerEl) + .setName('Show notifications') + .setDesc('Show notifications when locking or unlocking notes') + .addToggle(toggle => toggle + .setValue(this.plugin.settings.showNotifications) + .onChange(async (value) => { + this.plugin.settings.showNotifications = value; + await this.plugin.saveSettings(); + })); + const mobileNotificationSetting = new Setting(containerEl) .setName('Mobile notification max length') .setDesc('Maximum length of file names in notifications on mobile devices')