Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Button #1855

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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"
}
}
}
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions src/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@ export const enum CONFIG_KEYS {
RemoveTimestamp = 'removeTimestamp',
RemoveRemoteRepository = 'removeRemoteRepository',
IdleTimeout = 'idleTimeout',
GitHubButtonURL = 'gitHubButtonURL',
GitHubButton = 'gitHubButton',
RemoveGitHubButton = 'removeGitHubButton',
}
3 changes: 3 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type WorkspaceExtensionConfiguration = WorkspaceConfiguration & {
removeTimestamp: boolean;
removeRemoteRepository: boolean;
idleTimeout: number;
gitHubButtonURL: string;
gitHubButton: string;
removeGitHubButton: boolean;
};

export function getConfig() {
Expand Down