Skip to content

Commit

Permalink
ability to hide status bar icon
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed May 13, 2017
1 parent c98e7df commit fd22756
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
36 changes: 35 additions & 1 deletion extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export function activate(ctx: vscode.ExtensionContext) {
wakatime.promptForDebug();
}));

ctx.subscriptions.push(vscode.commands.registerCommand('wakatime.status_bar_icon', function (args) {
wakatime.promptStatusBarIcon();
}));

// add to a list of disposables which are disposed when this extension
// is deactivated again.
ctx.subscriptions.push(wakatime);
Expand Down Expand Up @@ -69,7 +73,12 @@ export class WakaTime {
this.dependencies = new Dependencies(this.options);
this.dependencies.checkAndInstall(function() {
this.statusBar.text = '$(clock) WakaTime Initialized';
this.statusBar.show();
this.options.getSetting('settings', 'status_bar_icon', function(err, val) {
if (val && val.trim() !== 'false')

This comment has been minimized.

Copy link
@lkytal

lkytal May 18, 2017

Seems like you code it wrong? Shouldn't it be val.trim() == 'false instead?

This comment has been minimized.

Copy link
@alanhamlett

alanhamlett May 18, 2017

Author Member

No, this is checking if val from the config file is a string "false".

This comment has been minimized.

Copy link
@lkytal

lkytal May 18, 2017

However this will only hide statusbar icon when the status_bar_icon config is NOT false, is that wrong or at least confusing?

This comment has been minimized.

Copy link
@alanhamlett

alanhamlett May 18, 2017

Author Member

That's what we want, because by default we show the status bar icon. The only time we want to hide it is when the status_bar_icon config exists and is false.

This comment has been minimized.

Copy link
@lkytal

lkytal Jun 12, 2017

Seems you finally figue it out lol.

This comment has been minimized.

Copy link
@alanhamlett

alanhamlett Jun 13, 2017

Author Member

Yep, my bad I said The only time we want to hide it is when the status_bar_icon config exists and is false but then the code said is not false. Glad it's fixed now though 👍

this.statusBar.hide();
else
this.statusBar.show();
}.bind(this));
}.bind(this));

this._setupEventListeners();
Expand Down Expand Up @@ -155,6 +164,31 @@ export class WakaTime {
}.bind(this));
}

public promptStatusBarIcon(): void {
this.options.getSetting('settings', 'status_bar_icon', function(err, defaultVal) {
if (!defaultVal || defaultVal.trim() !== 'false')
defaultVal = 'true';
let items:string[] = ['true', 'false'];
let promptOptions = {
placeHolder: 'true or false (Currently ' + defaultVal + ')',
value: defaultVal,
ignoreFocusOut: true,
};
vscode.window.showQuickPick(items, promptOptions).then(function(newVal) {
if (newVal == null)
return;
this.options.setSetting('settings', 'status_bar_icon', newVal);
if (newVal === 'true') {
this.statusBar.show();
logger.debug('Status bar icon enabled');
} else {
this.statusBar.hide();
logger.debug('Status bar icon disabled');
}
}.bind(this));
}.bind(this));
}

private _checkApiKey() {
this.hasApiKey(function(hasApiKey) {
if (!hasApiKey) this.promptForApiKey();
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
{
"command": "wakatime.debug",
"title": "WakaTime Debug"
},
{
"command": "wakatime.status_bar_icon",
"title": "WakaTime Status Bar Icon"
}
]
},
Expand Down

0 comments on commit fd22756

Please sign in to comment.