Skip to content

Commit

Permalink
feat: update the config + hot fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xhayper committed Mar 15, 2023
1 parent 24aad84 commit 817fa07
Show file tree
Hide file tree
Showing 5 changed files with 260 additions and 103 deletions.
217 changes: 176 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -463,47 +463,182 @@
{
"title": "Buttons",
"properties": {
"vscord.status.buttons": {
"type": "object",
"markdownDescription": "The buttons to show in the rich presence. You can have to buttons 1 & 2. The valid config for the buttons are active, inactive, idle. Git has its own idle and active buttons **Example**: \n```js\n\"vscord.buttons\": {\n \"button1\": {\n \"enabled\": true,\n \"active\": {\n \"enabled\": true,\n \"label\": \"Active Label Button 1\",\n \"url\": \"\" // The url to open when the button is clicked.\n },\n \"git\": {\n \"enabled\": true,\n \"active\": {\n \"enabled\": true,\n \"label\": \"View Repository\",\n \"url\": \"{git_url}\" // The url to open when the button is clicked.\n }\n }\n }...cont\n```",
"default": {
"button1": {
"enabled": true,
"active": {
"enabled": true,
"label": "Active Label Button 1",
"url": "https://github.com/leonardssh/vscord"
},
"inactive": {
"enabled": true,
"label": "Inactive Label Button 1",
"url": "https://github.com/leonardssh/vscord"
},
"idle": {
"enabled": true,
"label": "Idle Label Button 1",
"url": "https://github.com/leonardssh/vscord"
},
"git": {
"enabled": true,
"active": {
"enabled": true,
"label": "View Repository",
"url": "{git_url}"
},
"inactive": {
"enabled": true,
"label": "View Repository",
"url": "{git_url}"
},
"idle": {
"enabled": true,
"label": "View Repository",
"url": "{git_url}"
}
}
}
}
"vscord.status.buttons.button1.enabled": {
"type": "boolean",
"default": true
},
"vscord.status.buttons.button1.active.enabled": {
"type": "boolean",
"default": true
},
"vscord.status.buttons.button1.active.label": {
"type": "string",
"default": "Active Label Button 1",
"minLength": 1
},
"vscord.status.buttons.button1.active.url": {
"type": "string",
"default": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"minLength": 1
},
"vscord.status.buttons.button1.inactive.enabled": {
"type": "boolean",
"default": false
},
"vscord.status.buttons.button1.inactive.label": {
"type": "string",
"default": "Inactive Label Button 1",
"minLength": 1
},
"vscord.status.buttons.button1.inactive.url": {
"type": "string",
"default": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"minLength": 1
},
"vscord.status.buttons.button1.idle.enabled": {
"type": "boolean",
"default": false
},
"vscord.status.buttons.button1.idle.label": {
"type": "string",
"default": "Idle Label Button 1",
"minLength": 1
},
"vscord.status.buttons.button1.idle.url": {
"type": "string",
"default": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"minLength": 1
},
"vscord.status.buttons.button1.git.active.enabled": {
"type": "boolean",
"default": false
},
"vscord.status.buttons.button1.git.active.label": {
"type": "string",
"default": "View Repository",
"minLength": 1
},
"vscord.status.buttons.button1.git.active.url": {
"type": "string",
"default": "{git_url}",
"minLength": 1
},
"vscord.status.buttons.button1.git.inactive.enabled": {
"type": "boolean",
"default": true
},
"vscord.status.buttons.button1.git.inactive.label": {
"type": "string",
"default": "View Repository",
"minLength": 1
},
"vscord.status.buttons.button1.git.inactive.url": {
"type": "string",
"default": "{git_url}",
"minLength": 1
},
"vscord.status.buttons.button1.git.idle.enabled": {
"type": "boolean",
"default": true,
"minLength": 1
},
"vscord.status.buttons.button1.git.idle.label": {
"type": "string",
"default": "View Repository",
"minLength": 1
},
"vscord.status.buttons.button1.git.idle.url": {
"type": "string",
"default": "{git_url}",
"minLength": 1
},
"vscord.status.buttons.button2.enabled": {
"type": "boolean",
"default": false
},
"vscord.status.buttons.button2.active.enabled": {
"type": "boolean",
"default": false
},
"vscord.status.buttons.button2.active.label": {
"type": "string",
"default": "Active Label Button 2",
"minLength": 1
},
"vscord.status.buttons.button2.active.url": {
"type": "string",
"default": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"minLength": 1
},
"vscord.status.buttons.button2.inactive.enabled": {
"type": "boolean",
"default": false
},
"vscord.status.buttons.button2.inactive.label": {
"type": "string",
"default": "Inactive Label Button 2",
"minLength": 1
},
"vscord.status.buttons.button2.inactive.url": {
"type": "string",
"default": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"minLength": 1
},
"vscord.status.buttons.button2.idle.enabled": {
"type": "boolean",
"default": false
},
"vscord.status.buttons.button2.idle.label": {
"type": "string",
"default": "Idle Label Button 2",
"minLength": 1
},
"vscord.status.buttons.button2.idle.url": {
"type": "string",
"default": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"minLength": 1
},
"vscord.status.buttons.button2.git.active.enabled": {
"type": "boolean",
"default": false
},
"vscord.status.buttons.button2.git.active.label": {
"type": "string",
"default": "Git Active Label Button 2",
"minLength": 1
},
"vscord.status.buttons.button2.git.active.url": {
"type": "string",
"default": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"minLength": 1
},
"vscord.status.buttons.button2.git.inactive.enabled": {
"type": "boolean",
"default": false
},
"vscord.status.buttons.button2.git.inactive.label": {
"type": "string",
"default": "Git Inactive Label Button 2",
"minLength": 1
},
"vscord.status.buttons.button2.git.inactive.url": {
"type": "string",
"default": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"minLength": 1
},
"vscord.status.buttons.button2.git.idle.enabled": {
"type": "boolean",
"default": false
},
"vscord.status.buttons.button2.git.idle.label": {
"type": "string",
"default": "Git Idle Label Button 2",
"minLength": 1
},
"vscord.status.buttons.button2.git.idle.url": {
"type": "string",
"default": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"minLength": 1
}
}
},
Expand Down
28 changes: 13 additions & 15 deletions src/activity.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import {
type Selection,
type TextDocument,
debug,
DiagnosticSeverity,
env,
languages,
workspace,
window
} from "vscode";
import { resolveLangName, toLower, toTitle, toUpper } from "./helpers/resolveLangName";
import { type GatewayActivityButton } from "discord-api-types/v10";
import { type SetActivity } from "@xhayper/discord-rpc";
import { CONFIG_KEYS, FAKE_EMPTY } from "./constants";
import { getFileSize } from "./helpers/getFileSize";
import { isExcluded } from "./helpers/isExcluded";
import { isObject } from "./helpers/isObject";
import gitUrlParse from "git-url-parse";
import { getConfig } from "./config";
import { dataClass } from "./data";
import { sep } from "node:path";
import gitUrlParse from "git-url-parse";
import {
type Selection,
type TextDocument,
debug,
DiagnosticSeverity,
env,
languages,
workspace,
window
} from "vscode";

export enum CURRENT_STATUS {
IDLE = "idle",
Expand Down Expand Up @@ -277,12 +277,10 @@ async function createButton(

return {
label: await replaceAllText(
config.get(
isGit && state != "Inactive" ? currentState.Git[state].Label : currentState[state].Label
) as string
config.get(isGit && state != "Inactive" ? currentState.Git[state].Label : currentState[state].Label)!
),
url: await replaceAllText(
config.get(isGit && state != "Inactive" ? currentState.Git[state].Url : currentState[state].Url) as string
config.get(isGit && state != "Inactive" ? currentState.Git[state].Url : currentState[state].Url)!
)
};
}
Expand Down
62 changes: 38 additions & 24 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,6 @@ import { type filesize } from "filesize";
export type FileSizeConfig = Parameters<typeof filesize>["1"];
export type FileSizeStandard = "iec" | "jedec";

interface buttonStatus {
enabled: boolean;
label: string;
url: string;
}

interface button {
enabled: boolean;
active: buttonStatus;
idle: buttonStatus;
inactive: buttonStatus;
git: {
active: buttonStatus;
idle: buttonStatus;
inactive: buttonStatus;
};
}

interface buttons {
button1: button;
button2: button;
}

export interface ExtensionConfigurationType {
"app.id": string;
"app.name": "Code" | "Visual Studio Code" | "VSCodium" | "Custom";
Expand All @@ -51,7 +28,44 @@ export interface ExtensionConfigurationType {
"status.state.text.debugging": string;
"status.state.text.notInFile": string;
"status.state.text.noWorkspaceFound": string;
"status.buttons": buttons;
"status.buttons.button1.enabled": boolean;
"status.buttons.button1.active.enabled": boolean;
"status.buttons.button1.active.label": string;
"status.buttons.button1.active.url": string;
"status.buttons.button1.inactive.enabled": boolean;
"status.buttons.button1.inactive.label": string;
"status.buttons.button1.inactive.url": string;
"status.buttons.button1.idle.enabled": boolean;
"status.buttons.button1.idle.label": string;
"status.buttons.button1.idle.url": string;
"status.buttons.button1.git.active.enabled": boolean;
"status.buttons.button1.git.active.label": string;
"status.buttons.button1.git.active.url": string;
"status.buttons.button1.git.inactive.enabled": boolean;
"status.buttons.button1.git.inactive.label": string;
"status.buttons.button1.git.inactive.url": string;
"status.buttons.button1.git.idle.enabled": boolean;
"status.buttons.button1.git.idle.label": string;
"status.buttons.button1.git.idle.url": string;
"status.buttons.button2.enabled": boolean;
"status.buttons.button2.active.enabled": boolean;
"status.buttons.button2.active.label": string;
"status.buttons.button2.active.url": string;
"status.buttons.button2.inactive.enabled": boolean;
"status.buttons.button2.inactive.label": string;
"status.buttons.button2.inactive.url": string;
"status.buttons.button2.idle.enabled": boolean;
"status.buttons.button2.idle.label": string;
"status.buttons.button2.idle.url": string;
"status.buttons.button2.git.active.enabled": boolean;
"status.buttons.button2.git.active.label": string;
"status.buttons.button2.git.active.url": string;
"status.buttons.button2.git.inactive.enabled": boolean;
"status.buttons.button2.git.inactive.label": string;
"status.buttons.button2.git.inactive.url": string;
"status.buttons.button2.git.idle.enabled": boolean;
"status.buttons.button2.git.idle.label": string;
"status.buttons.button2.git.idle.url": string;
"status.image.large.idle.key": string;
"status.image.large.idle.text": string;
"status.image.large.viewing.key": string;
Expand Down
Loading

0 comments on commit 817fa07

Please sign in to comment.