Skip to content

Commit

Permalink
feat: add setting to disable 'No changes...' popups (#676)
Browse files Browse the repository at this point in the history
* Added setting to disable 'No changes...' popups

When notifications aren't disabled this new setting
will be displayed. Enabling this setting, will prevent
the "No changes to push" and "No changes to commit"
messages from displaying. This doesn't prevent
these notifcations from appearing in the status bar.

* Update src/main.ts

Co-authored-by: Vinzent <vinzentwitte@gmail.com>

* style: format

---------

Co-authored-by: Vinzent <vinzentwitte@gmail.com>
Co-authored-by: Vinzent <vinzent03@proton.me>
  • Loading branch information
3 people committed Jan 28, 2024
1 parent cd1d932 commit bfd6de9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const DEFAULT_SETTINGS: Omit<ObsidianGitSettings, "autoCommitMessage"> =
disablePush: false,
pullBeforePush: true,
disablePopups: false,
disablePopupsForNoChanges: false,
listChangedFilesInMessageBody: false,
showStatusBar: true,
updateSubmodules: false,
Expand Down
7 changes: 6 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,12 @@ I strongly recommend to use "Source mode" for viewing the conflicted files. For
this.statusBar?.displayMessage(message.toLowerCase(), timeout);

if (!this.settings.disablePopups) {
new Notice(message, 5 * 1000);
if (
!this.settings.disablePopupsForNoChanges ||
!message.startsWith("No changes")
) {
new Notice(message, 5 * 1000);
}
}

console.log(`git obsidian message: ${message}`);
Expand Down
16 changes: 16 additions & 0 deletions src/setting/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,26 @@ export class ObsidianGitSettingsTab extends PluginSettingTab {
.setValue(plugin.settings.disablePopups)
.onChange((value) => {
plugin.settings.disablePopups = value;
this.display();
plugin.saveSettings();
})
);

if (!plugin.settings.disablePopups)
new Setting(containerEl)
.setName("Hide notifications for no changes")
.setDesc(
"Don't show notifications when there are no changes to commit/push"
)
.addToggle((toggle) =>
toggle
.setValue(plugin.settings.disablePopupsForNoChanges)
.onChange((value) => {
plugin.settings.disablePopupsForNoChanges = value;
plugin.saveSettings();
})
);

new Setting(containerEl)
.setName("Show status bar")
.setDesc(
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface ObsidianGitSettings {
disablePush: boolean;
pullBeforePush: boolean;
disablePopups: boolean;
disablePopupsForNoChanges: boolean;
listChangedFilesInMessageBody: boolean;
showStatusBar: boolean;
updateSubmodules: boolean;
Expand Down

0 comments on commit bfd6de9

Please sign in to comment.