Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Jul 24, 2018
1 parent 35d20ed commit b6dd980
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
21 changes: 14 additions & 7 deletions src/vs/platform/actions/common/offlineMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

'use strict';

import { Action } from 'vs/base/common/actions';
import { localize } from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { Action } from 'vs/base/common/actions';
import { TPromise } from 'vs/base/common/winjs.base';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
Expand All @@ -25,14 +25,18 @@ export class EnableOfflineMode extends Action {
@IConfigurationService private configurationService: IConfigurationService
) {
super(id, label);
this.enabled = this.configurationService.getValue(offlineModeSetting) !== true;
this.updateEnabled();
this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(offlineModeSetting)) {
this.enabled = this.configurationService.getValue(offlineModeSetting) !== true;
this.updateEnabled();
}
});
}

private updateEnabled() {
this.enabled = this.configurationService.getValue(offlineModeSetting) !== true;
}

run(): TPromise<any> {
return this.configurationService.updateValue(offlineModeSetting, true);
}
Expand All @@ -48,20 +52,23 @@ export class DisableOfflineMode extends Action {
@IConfigurationService private configurationService: IConfigurationService
) {
super(id, label);
this.enabled = this.configurationService.getValue(offlineModeSetting) === true;
this.updateEnabled();
this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(offlineModeSetting)) {
this.enabled = this.configurationService.getValue(offlineModeSetting) === true;
this.updateEnabled();
}
});
}

private updateEnabled() {
this.enabled = this.configurationService.getValue(offlineModeSetting) === true;
}

run(): TPromise<any> {
return this.configurationService.updateValue(offlineModeSetting, false);
}
}


export class NotifyUnsupportedFeatureInOfflineMode extends Action {
static readonly ID = 'workbench.action.notifyUnsupportedFeatureInOfflineMode';

Expand Down
8 changes: 6 additions & 2 deletions src/vs/platform/update/electron-main/abstractUpdateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export abstract class AbstractUpdateService implements IUpdateService {
}

const quality = this.getProductQuality();
const offlineMode = this.configurationService.getValue(offlineModeSetting);
if (!quality || offlineMode === true) {
if (!quality) {
this.logService.info('update#ctor - updates are disabled');
return;
}
Expand All @@ -75,6 +74,11 @@ export abstract class AbstractUpdateService implements IUpdateService {

this.setState(State.Idle(this.getUpdateType()));

if (this.configurationService.getValue(offlineModeSetting) === true) {
this.logService.info('update#ctor - updates are disabled due to offline mode');
return;
}

// Start checking for updates after 30 seconds
this.scheduleCheckForUpdates(30 * 1000)
.done(null, err => this.logService.error(err));
Expand Down

0 comments on commit b6dd980

Please sign in to comment.