Skip to content
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
28 changes: 27 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,33 @@
"vscord.status.showElapsedTime": {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this field is still used throughout the code base and is not deprecated. It is also used in your switch case block you made here: https://github.com/narcisbugeag/vscord/pull/410/changes#diff-25b8815d592fb665b70c36526091c1dfc73d09988d9199d21c228f825a1a1a75R109

"type": "boolean",
"default": true,
"description": "Should elapsed time be shown?"
"description": "Should elapsed time be shown?",
"deprecationMessage": "Deprecated: Please use vscord.status.time.mode instead.",
"markdownDeprecationMessage": "**Deprecated**: Please use `#vscord.status.time.mode#` instead."
},
"vscord.status.time.mode": {
"type": "string",
"enum": [
"Hidden",
"Elapsed",
"Current Interface",
"Custom",
"Fixed"
],
"default": "Elapsed",
"description": "Choose the time mode.",
"enumDescriptions": [
"Hide the timestamp.",
"Show the elapsed time.",
"Show the elapsed time since the start of the day (Local Time).",
"Show the elapsed time since the custom timestamp.",
"Show a fixed timestamp (00:00)."
]
},
"vscord.status.time.customTimestamp": {
"type": "number",
"default": 0,
"description": "The custom timestamp to use when `mode` is set to `Custom`."
},
"vscord.status.resetElapsedTimePerFile": {
"type": "boolean",
Expand Down
83 changes: 83 additions & 0 deletions src/README.md
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file should be deleted it serves no purpose

Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<div align="center">

# VSCord - Developer Guide

Development documentation for the [VSCord](https://github.com/LeonardSSH/vscord) extension.

</div>

<br />

## 🚀 Getting Started

This guide covers how to set up your environment, build, and run the extension locally.

## 🛠️ Prerequisites

- [Node.js](https://nodejs.org/)
- [npm](https://www.npmjs.com/) (Node Package Manager)

## 📥 Installation

1. Clone the repository:

```bash
git clone https://github.com/LeonardSSH/vscord.git
cd vscord
```

2. Install dependencies:
```bash
npm install
```

## 💻 Running in Development Mode

To run the extension in development mode with hot-reloading (watch mode):

1. Open the project in **Visual Studio Code**.
2. Press **F5** to start debugging. This will compile the extension and open a new **Extension Development Host** window.

Alternatively, you can run the watch script manually in your terminal if you prefer:

```bash
npm run watch
```

## 🏗️ Building the Extension

To compile the source code:

```bash
npm run compile
```

This runs type checking, linting, and builds the project using `esbuild`.

## 📦 Packaging

To create a `.vsix` package for distribution or manual installation:

```bash
npm run package
```

or

```bash
vsce package
```

## 🧪 Testing

We recommend running lint checks before pushing changes:

```bash
npm run lint
```

## 🔍 Development Notes

- **Source Code**: All source code is located in the `src` directory.
- **Entry Point**: `src/extension.ts` is the main entry point of the extension.
- **Configuration**: Settings are defined in `package.json` under `contributes.configuration` and handled in `src/config.ts`.
44 changes: 38 additions & 6 deletions src/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,44 @@ export const activity = async (

if (isIdling && !config.get(CONFIG_KEYS.Status.Idle.Enabled)) return {};

if (config.get(CONFIG_KEYS.Status.ShowElapsedTime)) {
presence.startTimestamp = config.get(CONFIG_KEYS.Status.ResetElapsedTimePerFile)
? Date.now()
: (previous.startTimestamp ?? Date.now());
} else {
delete presence.startTimestamp;
const timeMode = config.get(CONFIG_KEYS.Status.Time.Mode);

switch (timeMode) {
case "Hidden":
delete presence.startTimestamp;
delete presence.endTimestamp;
break;
case "Elapsed":
if (config.get(CONFIG_KEYS.Status.ShowElapsedTime)) {
presence.startTimestamp = config.get(CONFIG_KEYS.Status.ResetElapsedTimePerFile)
? Date.now()
: (previous.startTimestamp ?? Date.now());
} else {
delete presence.startTimestamp;
}
break;
case "Current Interface": {
const now = new Date();
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
presence.startTimestamp = midnight.getTime();
break;
}
Comment on lines +108 to +122
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also duplicated from the default statement. Should just be the same code path in the switch

case "Custom":
presence.startTimestamp = config.get(CONFIG_KEYS.Status.Time.CustomTimestamp);
break;
case "Fixed":
delete presence.startTimestamp;
delete presence.endTimestamp;
break;
Comment on lines +126 to +129
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does the same thing as "hidden"

default:
if (config.get(CONFIG_KEYS.Status.ShowElapsedTime)) {
presence.startTimestamp = config.get(CONFIG_KEYS.Status.ResetElapsedTimePerFile)
? Date.now()
: (previous.startTimestamp ?? Date.now());
} else {
delete presence.startTimestamp;
}
break;
}

const detailsEnabled = config.get(CONFIG_KEYS.Status.Details.Enabled);
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export interface ExtensionConfigurationType {
"status.idle.disconnectOnIdle": boolean;
"status.idle.resetElapsedTime": boolean;
"status.idle.timeout": number;
"status.time.mode": "Hidden" | "Elapsed" | "Current Interface" | "Custom" | "Fixed";
"status.time.customTimestamp": number;
"status.showElapsedTime": boolean;
"status.resetElapsedTimePerFile": boolean;
"ignore.workspaces": Array<string>;
Expand Down
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ export const CONFIG_KEYS = {
ResetElapsedTime: "status.idle.resetElapsedTime" as const,
Timeout: "status.idle.timeout" as const
} as const,
Time: {
Mode: "status.time.mode" as const,
CustomTimestamp: "status.time.customTimestamp" as const
} as const,
ShowElapsedTime: "status.showElapsedTime" as const,
ResetElapsedTimePerFile: "status.resetElapsedTimePerFile" as const
} as const,
Expand Down