Skip to content

Commit

Permalink
feat: add suppress notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardssh committed Aug 21, 2021
1 parent 010f617 commit 152ac93
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 33 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@
"type": "string",
"default": null,
"description": "The URL of the button when you are not editing a file in a Git repository. Set to null to disable."
},
"rpc.suppressNotifications": {
"type": "boolean",
"default": false,
"description": "Controls whether error messages should be shown to the user."
}
}
}
Expand Down
33 changes: 31 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
import { workspace } from 'vscode';
import { WorkspaceExtensionConfiguration } from './configuration';
import { workspace, WorkspaceConfiguration } from 'vscode';

export type WorkspaceExtensionConfiguration = WorkspaceConfiguration & {
id: string;
enabled: boolean;
detailsIdling: string;
detailsViewing: string;
detailsEditing: string;
detailsDebugging: string;
lowerDetailsIdling: string;
lowerDetailsViewing: string;
lowerDetailsEditing: string;
lowerDetailsDebugging: string;
lowerDetailsNoWorkspaceFound: string;
largeImageIdling: string;
largeImage: string;
smallImage: string;
removeElapsedTime: boolean;
ignoreWorkspaces: string[];
idleTimeout: number;
checkIdle: boolean;
idleText: string;
appName: string;
showProblems: boolean;
problemsText: string;
buttonEnabled: boolean;
buttonActiveLabel: string;
buttonInactiveLabel: string;
buttonInactiveUrl: string;
suppressNotifications: boolean;
};

export function getConfig(): WorkspaceExtensionConfiguration {
return workspace.getConfiguration('rpc') as WorkspaceExtensionConfiguration;
Expand Down
30 changes: 0 additions & 30 deletions src/configuration.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export const enum CONFIG_KEYS {
ButtonEnabled = 'buttonEnabled',
ButtonActiveLabel = 'buttonActiveLabel',
ButtonInactiveLabel = 'buttonInactiveLabel',
ButtonInactiveUrl = 'buttonInactiveUrl'
ButtonInactiveUrl = 'buttonInactiveUrl',
SuppressNotifications = 'suppressNotifications'
}

export const enum REPLACE_KEYS {
Expand Down
8 changes: 8 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ async function login() {

await rpc.destroy();

if (!config[CONFIG_KEYS.SuppressNotifications]) {
error?.message?.includes('ENOENT')
? void window.showErrorMessage('No Discord client detected')
: void window.showErrorMessage(
`Couldn't connect to Discord via RPC: ${error as string}`
);
}

statusBarIcon.text = '$(search-refresh) Reconnect to Discord Gateway';
statusBarIcon.command = 'rpc.reconnect';
}
Expand Down

0 comments on commit 152ac93

Please sign in to comment.