Skip to content

Commit

Permalink
feat: ✨ Option to disable notifications trigger by commands (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Nov 5, 2021
1 parent 58cd3e1 commit 44de09c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
20 changes: 17 additions & 3 deletions main.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/SettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ export class ACSettingTab extends PluginSettingTab {
});
});

new Setting(containerEl)
.setName("Show Command Notifications")
.setDesc(
"If off, disables all notifications that are not caused by errors or changing settings."
)
.addToggle((toggle) => {
toggle
.setValue(plugin.settings.showFunctionNotifications)
.onChange(async (value) => {
plugin.settings.showFunctionNotifications = value;
await plugin.saveSettings();
});
});

// SECTION Changelog

addRenderedMarkdownButton(
Expand Down
1 change: 1 addition & 0 deletions src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const DEFAULT_SETTINGS: ACSettings = {
savedQViewSide: "right",
lastQ: { name: "", query: "", flags: "", regexQ: true },
openViewOnload: true,
showFunctionNotifications: true,
};

export const VIEW_TYPE_AC = "Saved Queries View";
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface ACSettings {
savedQViewSide: "left" | "right";
lastQ: Query;
openViewOnload: boolean;
showFunctionNotifications: boolean;
}

export type Mode = typeof MODES[number];
Expand Down
10 changes: 6 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ export default class ACPlugin extends Plugin {
}
const nextSels = matches.map((m) => this.matchToSel(ed, m, offset));
this.setSels(appendQ, ed, ...nextSels);
new Notice(`${matches.length} matches found.`);
this.settings.showFunctionNotifications &&
new Notice(`${matches.length} matches found.`);
return;
}

Expand All @@ -376,9 +377,10 @@ export default class ACPlugin extends Plugin {
this.setSels(appendQ, ed, nextSel);
this.scrollNicely(ed, nextSel);
} else {
new Notice(
`No instance of '${toSelect}' found anywhere in note (that isn't already selected).`
);
this.settings.showFunctionNotifications &&
new Notice(
`No instance of '${toSelect}' found anywhere in note (that isn't already selected).`
);
}
}

Expand Down

0 comments on commit 44de09c

Please sign in to comment.