diff --git a/package.json b/package.json index 0145bd43a4..91de4208c8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "discord-vscode", "displayName": "Discord Presence", - "version": "5.8.0", + "version": "5.8.1", "description": "Update your discord status with a rich presence.", "private": true, "author": { @@ -153,6 +153,21 @@ "type": "number", "default": 0, "description": "Time (in seconds) to clear the presence when idling. 0 (the default) means no clearing" + }, + "discord.gitHubButtonURL": { + "type": "string", + "default": "https://github.com/", + "description": "Custom string URL for the github button" + }, + "discord.gitHubButton": { + "type": "string", + "default": "GitHub", + "description": "Custom string for the github button name" + }, + "discord.removeGitHubButton": { + "type": "boolean", + "default": false, + "description": "Adds a button to the rich presence that opens your github" } } } @@ -186,6 +201,7 @@ "bufferutil": "^4.0.6", "dayjs": "^1.11.3", "discord-rpc": "^4.0.1", + "generator-code": "^1.7.3", "lodash-es": "^4.17.21", "tslib": "^2.4.0", "utf-8-validate": "^5.0.9" diff --git a/src/activity.ts b/src/activity.ts index a3544565ec..3f5e651bf3 100644 --- a/src/activity.ts +++ b/src/activity.ts @@ -171,6 +171,9 @@ export async function activity(previous: ActivityPayload = {}) { const removeDetails = config[CONFIG_KEYS.RemoveDetails]; const removeLowerDetails = config[CONFIG_KEYS.RemoveLowerDetails]; const removeRemoteRepository = config[CONFIG_KEYS.RemoveRemoteRepository]; + const gitHubButtonURL = config[CONFIG_KEYS.GitHubButtonURL]; + const gitHubButton = config[CONFIG_KEYS.GitHubButton]; + const removeGitHubButton = config[CONFIG_KEYS.RemoveGitHubButton]; const git = await getGit(); @@ -212,6 +215,15 @@ export async function activity(previous: ActivityPayload = {}) { } } +// enable or disable GitHub button + if(!removeGitHubButton){ + state = { + ...state, + buttons: [{ label: gitHubButton, url: gitHubButtonURL }], + }; + } + + if (window.activeTextEditor) { const largeImageKey = resolveFileIcon(window.activeTextEditor.document); const largeImageText = config[CONFIG_KEYS.LargeImage] diff --git a/src/constants.ts b/src/constants.ts index 84ddb8b0ff..7156a47099 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -58,4 +58,7 @@ export const enum CONFIG_KEYS { RemoveTimestamp = 'removeTimestamp', RemoveRemoteRepository = 'removeRemoteRepository', IdleTimeout = 'idleTimeout', + GitHubButtonURL = 'gitHubButtonURL', + GitHubButton = 'gitHubButton', + RemoveGitHubButton = 'removeGitHubButton', } diff --git a/src/util.ts b/src/util.ts index 9bd24dfd22..e881dad692 100644 --- a/src/util.ts +++ b/src/util.ts @@ -27,6 +27,9 @@ type WorkspaceExtensionConfiguration = WorkspaceConfiguration & { removeTimestamp: boolean; removeRemoteRepository: boolean; idleTimeout: number; + gitHubButtonURL: string; + gitHubButton: string; + removeGitHubButton: boolean; }; export function getConfig() {