Skip to content

Commit 54f0541

Browse files
committed
feat: add setting to hide error notifications
close #870
1 parent 655d171 commit 54f0541

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const DEFAULT_SETTINGS: ObsidianGitSettings = {
1919
disablePush: false,
2020
pullBeforePush: true,
2121
disablePopups: false,
22+
showErrorNotices: true,
2223
disablePopupsForNoChanges: false,
2324
listChangedFilesInMessageBody: false,
2425
showStatusBar: true,

src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,9 @@ I strongly recommend to use "Source mode" for viewing the conflicted files. For
14281428
}
14291429

14301430
this.setPluginState({ gitAction: CurrentGitAction.idle });
1431-
new Notice(error.message, timeout);
1431+
if (this.settings.showErrorNotices) {
1432+
new Notice(error.message, timeout);
1433+
}
14321434
console.error(`${this.manifest.id}:`, error.stack);
14331435
this.statusBar?.displayMessage(error.message.toLowerCase(), timeout);
14341436
}

src/setting/settings.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ export class ObsidianGitSettingsTab extends PluginSettingTab {
532532
}
533533

534534
new Setting(containerEl)
535-
.setName("Disable notifications")
535+
.setName("Disable informative notifications")
536536
.setDesc(
537-
"Disable notifications for git operations to minimize distraction (refer to status bar for updates). Errors are still shown as notifications even if you enable this setting."
537+
"Disable informative notifications for git operations to minimize distraction (refer to status bar for updates)."
538538
)
539539
.addToggle((toggle) =>
540540
toggle
@@ -546,6 +546,20 @@ export class ObsidianGitSettingsTab extends PluginSettingTab {
546546
})
547547
);
548548

549+
new Setting(containerEl)
550+
.setName("Disable error notifications")
551+
.setDesc(
552+
"Disable errror notifications of any kind to minimize distraction (refer to status bar for updates)."
553+
)
554+
.addToggle((toggle) =>
555+
toggle
556+
.setValue(!plugin.settings.showErrorNotices)
557+
.onChange(async (value) => {
558+
plugin.settings.showErrorNotices = !value;
559+
await plugin.saveSettings();
560+
})
561+
);
562+
549563
if (!plugin.settings.disablePopups)
550564
new Setting(containerEl)
551565
.setName("Hide notifications for no changes")

src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ export interface ObsidianGitSettings {
2020
* Whether to pull on commit-and-sync
2121
*/
2222
pullBeforePush: boolean;
23+
/**
24+
* Whether messages from {@link ObsidianGit.displayMessage} should be shown
25+
*/
2326
disablePopups: boolean;
27+
/**
28+
* Whether messages from {@link ObsidianGit.displayError} should be shown
29+
*/
30+
showErrorNotices: boolean;
2431
disablePopupsForNoChanges: boolean;
2532
listChangedFilesInMessageBody: boolean;
2633
showStatusBar: boolean;

0 commit comments

Comments
 (0)