feat: modify statusbar icon instead of showing a message on successful connect

This commit is contained in:
Crawl 2018-11-20 05:26:48 +01:00
parent 8033bc4284
commit 90a255069e
No known key found for this signature in database
GPG key ID: E41A6DB922EC2CFE
3 changed files with 19 additions and 21 deletions

View file

@ -43,12 +43,10 @@ export default class RPCClient implements Disposable {
Logger.log('Logging into RPC.');
this._rpc.once('ready', () => {
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();
this.statusBarIcon.text = '$(plug) Reconnect to Discord';
this.statusBarIcon.command = 'discord.reconnect';
setTimeout(() => this.statusBarIcon.text = '$(globe)', 5000);
if (activityTimer) clearInterval(activityTimer);
this.setActivity();
@ -56,7 +54,8 @@ export default class RPCClient implements Disposable {
this._rpc.transport.once('close', async () => {
if (!this.config.get<boolean>('enabled')) return;
await this.dispose();
this.statusBarIcon.show();
this.statusBarIcon.text = '$(plug) Reconnect to Discord';
this.statusBarIcon.command = 'discord.reconnect';
});
activityTimer = setInterval(() => {
@ -74,5 +73,6 @@ export default class RPCClient implements Disposable {
this._rpc = null;
}
clearInterval(activityTimer);
this.statusBarIcon.hide();
}
}

View file

@ -10,7 +10,7 @@ import RPCClient from './client/RPCClient';
import Logger from './structures/Logger';
const statusBarIcon: StatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left);
statusBarIcon.text = '$(pulse) Connecting...';
statusBarIcon.text = '$(pulse) Connecting to Discord...';
statusBarIcon.command = 'discord.reconnect';
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!');
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.show();
}
}
@ -39,8 +38,7 @@ export async function activate(context: ExtensionContext) {
await rpc.dispose();
config.update('enabled', true);
rpc.config = workspace.getConfiguration('discord');
rpc.statusBarIcon.text = '$(pulse) Connecting...';
rpc.statusBarIcon.show();
rpc.statusBarIcon.text = '$(pulse) Connecting to Discord...';
await rpc.login();
window.showInformationMessage('Enabled Discord Rich Presence for this workspace.');
});
@ -56,7 +54,7 @@ export async function activate(context: ExtensionContext) {
await rpc.dispose();
await rpc.login();
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;
});

View file

@ -943,9 +943,9 @@ flagged-respawn@^1.0.0:
integrity sha1-Tnmumy6zi/hrO7Vr8+ClaqX8q9c=
flatmap-stream@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/flatmap-stream/-/flatmap-stream-0.1.1.tgz#d34f39ef3b9aa5a2fc225016bd3adf28ac5ae6ea"
integrity sha512-lAq4tLbm3sidmdCN8G3ExaxH7cUCtP5mgDvrYowsx84dcYkJJ4I28N7gkxA6+YlSXzaGLJYIDEi9WGfXzMiXdw==
version "0.1.2"
resolved "https://registry.yarnpkg.com/flatmap-stream/-/flatmap-stream-0.1.2.tgz#b1da359a93f24f6d96e46f948552d997e3c2863d"
integrity sha512-ucyr6WkLXjyMuHPtOUq4l+nSAxgWi7v4QO508eQ9resnGj+lSup26oIsUI5aH8k4Qfpjsxa8dDf9UCKkS2KHzQ==
flush-write-stream@^1.0.2:
version "1.0.3"
@ -2228,9 +2228,9 @@ next-tick@1:
integrity sha1-yobR/ogoFpsBICCOPchCS524NCw=
node-fetch@^2.1.2:
version "2.2.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.2.1.tgz#1fe551e0ded6c45b3b3b937d0fb46f76df718d1e"
integrity sha512-ObXBpNCD3A/vYQiQtEWl7DuqjAXjfptYFuGHLdPl5U19/6kJuZV+8uMHLrkj3wJrJoyfg4nhgyFixZdaZoAiEQ==
version "2.3.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.3.0.tgz#1a1d940bbfb916a1d3e0219f037e89e71f8c5fa5"
integrity sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==
node.extend@^1.1.2:
version "1.1.7"
@ -3440,8 +3440,8 @@ yauzl@^2.2.1:
fd-slicer "~1.1.0"
yazl@^2.2.1:
version "2.4.3"
resolved "https://registry.yarnpkg.com/yazl/-/yazl-2.4.3.tgz#ec26e5cc87d5601b9df8432dbdd3cd2e5173a071"
integrity sha1-7CblzIfVYBud+EMtvdPNLlFzoHE=
version "2.5.0"
resolved "https://registry.yarnpkg.com/yazl/-/yazl-2.5.0.tgz#1ab8de8cd3c3c252986c7fa2f6562784d7288e49"
integrity sha512-rgptqKwX/f1/7bIRF1FHb4HGsP5k11QyxBpDl1etUDfNpTa7CNjDOYNPFnIaEzZ9dRq0c47IEJS+sy+T39JCLw==
dependencies:
buffer-crc32 "~0.2.3"