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

Fix #296

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Fix #296

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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"theme": "dark"
},
"activationEvents": [
"onStartupFinished"
"onDidChangeConfiguration"
],
"scripts": {
"vscode:prepublish": "pnpm tsup",
Expand Down Expand Up @@ -116,7 +116,7 @@
"VSCodium",
"Custom"
],
"default": "Code",
"default": "code",
"description": "Choose the name you want the application to use.\nChoosing \"Custom\" will make it so it use the \"rpc.id\" as application id",
"order": 2
},
Expand Down
22 changes: 16 additions & 6 deletions src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class RPCController {
}

private onReady() {
logInfo("Successfully connected to Discord");
logInfo("Successfully connected to Discord");
this.cleanUp();

if (this.enabled) void this.enable();
Expand Down Expand Up @@ -178,16 +178,26 @@ export class RPCController {
logInfo("[004] Debug:", `Logging in with client ID "${clientId}"`);
logInfo("[004] Debug:", "Login - isConnected", this.client.isConnected, "isReady", this.client.clientId);
logInfo("[004] Debug:", `Login - ${this.client}`);

if (this.client.isConnected && this.client.clientId === clientId) return;

editor.statusBarItem.text = "$(search-refresh) Connecting to Discord Gateway...";
editor.statusBarItem.tooltip = "Connecting to Discord Gateway...";

if (this.client.clientId !== clientId) await this.updateClientId(clientId);
else if (!this.client.isConnected) await this.client.login();

if (!this.client.isConnected) {
try {
await this.client.login();
} catch (error) {
// Handle login error
//console.error("Failed to login:", error);
editor.statusBarItem.text = "$(error) Failed to connect to Discord Gateway";
editor.statusBarItem.tooltip = "Failed to connect to Discord Gateway";
}
}
}

async sendActivity(isViewing = false, isIdling = false): Promise<SetActivityResponse | undefined> {
if (!this.enabled) return;
this.checkCanSend();
Expand Down