Skip to content

Commit 0c6acb3

Browse files
committed
Fix for registerCommands & added logging
1 parent a7d4627 commit 0c6acb3

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

src/control.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { CodesWebview } from './webviews/codesWebview';
2020
import { MachineTypeControl } from './util/machineType';
2121
import { GCodeHoverControl } from './hovers/gcodeHoverControl';
2222
import { defaults } from './util/configuration/defaults';
23-
import { registerCommands } from './util/commands/functions';
23+
import { registerCommands } from './util/commands';
2424

2525
const cfgUnits = 'general.units';
2626
const cfgAutoRef = {
@@ -48,28 +48,26 @@ export class Control {
4848
// Webviews
4949
private static _codesWebview: CodesWebview | undefined;
5050

51-
private static async checkVersion() {
52-
const gcodeVersion = new Version(constants.extension.version);
53-
51+
private static async _checkVersion() {
5452
const prevVer = this._stateController.getVersion();
5553

56-
const newVer = gcodeVersion.compareWith(prevVer.getVersion()) === 1 ? true : false;
54+
const newVer = this._version.compareWith(prevVer.getVersion()) === 1 ? true : false;
5755

5856
if (newVer) {
5957
// Extension has been updated
6058

6159
// Update globalState version
6260
Logger.log('Updating...');
63-
void this._stateController.updateVer(gcodeVersion);
61+
await this._stateController.updateVer(this._version);
6462

65-
Logger.log(`G-Code upgraded from ${prevVer.getVersionAsString()} to ${gcodeVersion.getVersionAsString()}`);
66-
await this.showWhatsNew(gcodeVersion);
63+
Logger.log(`G-Code upgraded from ${prevVer.getVersionAsString()} to ${this._version.getVersionAsString()}`);
64+
await this._showWhatsNew(this._version);
6765
} else {
6866
return;
6967
}
7068
}
7169

72-
private static async showWhatsNew(ver: Version) {
70+
private static async _showWhatsNew(ver: Version) {
7371
// Show Whats New Message
7472
await Messages.showWhatsNewMessage(ver);
7573
}
@@ -79,23 +77,33 @@ export class Control {
7977
// Initialize G-Code Extension
8078
this._context = context;
8179
this._config = config;
80+
this._version = new Version(constants.extension.version);
8281

8382
// Initialze Configuration
83+
Logger.log('Loading Configuration...');
8484
Config.initialize(this._context, this._config);
8585

86+
// Load State Controller
87+
Logger.log('Loading State Controller...');
88+
this._stateController = new StateControl(context);
89+
90+
// Check Version
91+
Logger.log('Checking Version...');
92+
void this._checkVersion();
93+
8694
// Register Commands
95+
Logger.log('Registering Commands...');
8796
context.subscriptions.push(...registerCommands());
8897

8998
// Load StatusBars
9099
context.subscriptions.push((this._statusBarControl = new StatusBarControl()));
91100

92101
// Load Machine Type
102+
Logger.log('Loading Machine Type Controller...');
93103
context.subscriptions.push((this._machineTypeControl = new MachineTypeControl()));
94104

95-
// Load State Controller
96-
this._stateController = new StateControl(context);
97-
98105
// Load Hover Controller
106+
Logger.log('Loading Hover Controller...');
99107
context.subscriptions.push((this._hoverController = new GCodeHoverControl()));
100108

101109
// Units
@@ -125,7 +133,6 @@ export class Control {
125133

126134
// Load Nav Tree
127135
Logger.log('Loading Nav Tree...');
128-
129136
context.subscriptions.push((this._navTree = new NavTreeView()));
130137

131138
Logger.log(
@@ -147,11 +154,10 @@ export class Control {
147154
GCommands.ShowSupportGCode,
148155
);
149156

150-
// Check Version
151-
void this.checkVersion();
152-
153157
// Set Up Webviews
154158
context.subscriptions.push((this._codesWebview = new CodesWebview()));
159+
160+
Logger.log('Done Initializing.');
155161
}
156162

157163
static terminate() {
@@ -186,6 +192,10 @@ export class Control {
186192
return this._config;
187193
}
188194

195+
static get version() {
196+
return this._version;
197+
}
198+
189199
static get machineType() {
190200
return this._machineTypeControl;
191201
}

0 commit comments

Comments
 (0)