Add setting for note lock/unlock notifications

Signed-off-by: Felvesthe <23108389+Felvesthe@users.noreply.github.com>
This commit is contained in:
Felvesthe 2025-05-11 01:38:32 +02:00
parent 09a6673606
commit 688142f84e
3 changed files with 19 additions and 5 deletions

View file

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

View file

@ -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
};

View file

@ -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')