feat: modify statusbar icon instead of showing a message on successful connect
This commit is contained in:
parent
8033bc4284
commit
90a255069e
3 changed files with 19 additions and 21 deletions
|
@ -43,12 +43,10 @@ export default class RPCClient implements Disposable {
|
||||||
Logger.log('Logging into RPC.');
|
Logger.log('Logging into RPC.');
|
||||||
this._rpc.once('ready', () => {
|
this._rpc.once('ready', () => {
|
||||||
Logger.log('Successfully connected to Discord.');
|
Logger.log('Successfully connected to Discord.');
|
||||||
if (!this.config.get<boolean>('silent')) window.showInformationMessage('Successfully connected to Discord RPC');
|
this.statusBarIcon.text = '$(globe) Connected to Discord';
|
||||||
|
this.statusBarIcon.tooltip = 'Connected to Discord';
|
||||||
|
|
||||||
this.statusBarIcon.hide();
|
setTimeout(() => this.statusBarIcon.text = '$(globe)', 5000);
|
||||||
|
|
||||||
this.statusBarIcon.text = '$(plug) Reconnect to Discord';
|
|
||||||
this.statusBarIcon.command = 'discord.reconnect';
|
|
||||||
|
|
||||||
if (activityTimer) clearInterval(activityTimer);
|
if (activityTimer) clearInterval(activityTimer);
|
||||||
this.setActivity();
|
this.setActivity();
|
||||||
|
@ -56,7 +54,8 @@ export default class RPCClient implements Disposable {
|
||||||
this._rpc.transport.once('close', async () => {
|
this._rpc.transport.once('close', async () => {
|
||||||
if (!this.config.get<boolean>('enabled')) return;
|
if (!this.config.get<boolean>('enabled')) return;
|
||||||
await this.dispose();
|
await this.dispose();
|
||||||
this.statusBarIcon.show();
|
this.statusBarIcon.text = '$(plug) Reconnect to Discord';
|
||||||
|
this.statusBarIcon.command = 'discord.reconnect';
|
||||||
});
|
});
|
||||||
|
|
||||||
activityTimer = setInterval(() => {
|
activityTimer = setInterval(() => {
|
||||||
|
@ -74,5 +73,6 @@ export default class RPCClient implements Disposable {
|
||||||
this._rpc = null;
|
this._rpc = null;
|
||||||
}
|
}
|
||||||
clearInterval(activityTimer);
|
clearInterval(activityTimer);
|
||||||
|
this.statusBarIcon.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import RPCClient from './client/RPCClient';
|
||||||
import Logger from './structures/Logger';
|
import Logger from './structures/Logger';
|
||||||
|
|
||||||
const statusBarIcon: StatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left);
|
const statusBarIcon: StatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left);
|
||||||
statusBarIcon.text = '$(pulse) Connecting...';
|
statusBarIcon.text = '$(pulse) Connecting to Discord...';
|
||||||
statusBarIcon.command = 'discord.reconnect';
|
statusBarIcon.command = 'discord.reconnect';
|
||||||
|
|
||||||
const config = workspace.getConfiguration('discord');
|
const config = workspace.getConfiguration('discord');
|
||||||
|
@ -29,9 +29,8 @@ export async function activate(context: ExtensionContext) {
|
||||||
if (error.message.includes('ENOENT')) window.showErrorMessage('No Discord Client detected!');
|
if (error.message.includes('ENOENT')) window.showErrorMessage('No Discord Client detected!');
|
||||||
else window.showErrorMessage(`Couldn't connect to Discord via RPC: ${error.toString()}`);
|
else window.showErrorMessage(`Couldn't connect to Discord via RPC: ${error.toString()}`);
|
||||||
}
|
}
|
||||||
rpc.statusBarIcon.text = '$(pulse) Reconnect';
|
rpc.statusBarIcon.text = '$(pulse) Reconnect to Discord';
|
||||||
rpc.statusBarIcon.command = 'discord.reconnect';
|
rpc.statusBarIcon.command = 'discord.reconnect';
|
||||||
rpc.statusBarIcon.show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +38,7 @@ export async function activate(context: ExtensionContext) {
|
||||||
await rpc.dispose();
|
await rpc.dispose();
|
||||||
config.update('enabled', true);
|
config.update('enabled', true);
|
||||||
rpc.config = workspace.getConfiguration('discord');
|
rpc.config = workspace.getConfiguration('discord');
|
||||||
rpc.statusBarIcon.text = '$(pulse) Connecting...';
|
rpc.statusBarIcon.text = '$(pulse) Connecting to Discord...';
|
||||||
rpc.statusBarIcon.show();
|
|
||||||
await rpc.login();
|
await rpc.login();
|
||||||
window.showInformationMessage('Enabled Discord Rich Presence for this workspace.');
|
window.showInformationMessage('Enabled Discord Rich Presence for this workspace.');
|
||||||
});
|
});
|
||||||
|
@ -56,7 +54,7 @@ export async function activate(context: ExtensionContext) {
|
||||||
await rpc.dispose();
|
await rpc.dispose();
|
||||||
await rpc.login();
|
await rpc.login();
|
||||||
if (!config.get('silent')) window.showInformationMessage('Reconnecting to Discord RPC...');
|
if (!config.get('silent')) window.showInformationMessage('Reconnecting to Discord RPC...');
|
||||||
rpc.statusBarIcon.text = '$(pulse) Reconnecting...';
|
rpc.statusBarIcon.text = '$(pulse) Reconnecting to Discord...';
|
||||||
rpc.statusBarIcon.command = undefined;
|
rpc.statusBarIcon.command = undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
18
yarn.lock
18
yarn.lock
|
@ -943,9 +943,9 @@ flagged-respawn@^1.0.0:
|
||||||
integrity sha1-Tnmumy6zi/hrO7Vr8+ClaqX8q9c=
|
integrity sha1-Tnmumy6zi/hrO7Vr8+ClaqX8q9c=
|
||||||
|
|
||||||
flatmap-stream@^0.1.0:
|
flatmap-stream@^0.1.0:
|
||||||
version "0.1.1"
|
version "0.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/flatmap-stream/-/flatmap-stream-0.1.1.tgz#d34f39ef3b9aa5a2fc225016bd3adf28ac5ae6ea"
|
resolved "https://registry.yarnpkg.com/flatmap-stream/-/flatmap-stream-0.1.2.tgz#b1da359a93f24f6d96e46f948552d997e3c2863d"
|
||||||
integrity sha512-lAq4tLbm3sidmdCN8G3ExaxH7cUCtP5mgDvrYowsx84dcYkJJ4I28N7gkxA6+YlSXzaGLJYIDEi9WGfXzMiXdw==
|
integrity sha512-ucyr6WkLXjyMuHPtOUq4l+nSAxgWi7v4QO508eQ9resnGj+lSup26oIsUI5aH8k4Qfpjsxa8dDf9UCKkS2KHzQ==
|
||||||
|
|
||||||
flush-write-stream@^1.0.2:
|
flush-write-stream@^1.0.2:
|
||||||
version "1.0.3"
|
version "1.0.3"
|
||||||
|
@ -2228,9 +2228,9 @@ next-tick@1:
|
||||||
integrity sha1-yobR/ogoFpsBICCOPchCS524NCw=
|
integrity sha1-yobR/ogoFpsBICCOPchCS524NCw=
|
||||||
|
|
||||||
node-fetch@^2.1.2:
|
node-fetch@^2.1.2:
|
||||||
version "2.2.1"
|
version "2.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.2.1.tgz#1fe551e0ded6c45b3b3b937d0fb46f76df718d1e"
|
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.3.0.tgz#1a1d940bbfb916a1d3e0219f037e89e71f8c5fa5"
|
||||||
integrity sha512-ObXBpNCD3A/vYQiQtEWl7DuqjAXjfptYFuGHLdPl5U19/6kJuZV+8uMHLrkj3wJrJoyfg4nhgyFixZdaZoAiEQ==
|
integrity sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==
|
||||||
|
|
||||||
node.extend@^1.1.2:
|
node.extend@^1.1.2:
|
||||||
version "1.1.7"
|
version "1.1.7"
|
||||||
|
@ -3440,8 +3440,8 @@ yauzl@^2.2.1:
|
||||||
fd-slicer "~1.1.0"
|
fd-slicer "~1.1.0"
|
||||||
|
|
||||||
yazl@^2.2.1:
|
yazl@^2.2.1:
|
||||||
version "2.4.3"
|
version "2.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/yazl/-/yazl-2.4.3.tgz#ec26e5cc87d5601b9df8432dbdd3cd2e5173a071"
|
resolved "https://registry.yarnpkg.com/yazl/-/yazl-2.5.0.tgz#1ab8de8cd3c3c252986c7fa2f6562784d7288e49"
|
||||||
integrity sha1-7CblzIfVYBud+EMtvdPNLlFzoHE=
|
integrity sha512-rgptqKwX/f1/7bIRF1FHb4HGsP5k11QyxBpDl1etUDfNpTa7CNjDOYNPFnIaEzZ9dRq0c47IEJS+sy+T39JCLw==
|
||||||
dependencies:
|
dependencies:
|
||||||
buffer-crc32 "~0.2.3"
|
buffer-crc32 "~0.2.3"
|
||||||
|
|
Loading…
Reference in a new issue