@@ -12,11 +12,11 @@ import { StatusBarControl } from './util/statusBar';
1212import { NavTreeView } from './views/navTreeView' ;
1313import { GCodeUnitsController } from './gcodeUnits' ;
1414import { StatsView } from './views/statsView' ;
15- import { constants , Contexts , GlobalState , PIcon , VSBuiltInCommands } from './util/constants' ;
15+ import { constants , Contexts , PIcon , VSBuiltInCommands } from './util/constants' ;
1616import { Commands } from './util/commands' ;
17- import { LocalStorageService } from './util/localStorageService' ;
18- import { IVersion , Version } from './util/version' ;
17+ import { Version } from './util/version' ;
1918import { Messages } from './util/messages' ;
19+ import { StateControl } from './util/stateControl' ;
2020
2121export class Control {
2222 private static _config : Config | undefined ;
@@ -26,7 +26,7 @@ export class Control {
2626 // Controllers
2727 private static _statusBarControl : StatusBarControl ;
2828 private static _unitsController : GCodeUnitsController | undefined ;
29- private static _storageManager : LocalStorageService ;
29+ private static _stateController : StateControl ;
3030
3131 // Views
3232 private static _statsView : StatsView | undefined ;
@@ -36,8 +36,8 @@ export class Control {
3636 this . _context = context ;
3737 this . _config = config ;
3838
39- // Load GlobalState Storage Manager
40- this . _storageManager = new LocalStorageService ( context ) ;
39+ // Load State Controller
40+ this . _stateController = new StateControl ( context ) ;
4141
4242 // Load StatusBars
4343 context . subscriptions . push ( ( this . _statusBarControl = new StatusBarControl ( this . _context ) ) ) ;
@@ -121,23 +121,19 @@ export class Control {
121121 private static async checkVersion ( ) {
122122 const gcodeVersion = new Version ( constants . extension . version ) ;
123123
124- const prevVer = new Version (
125- this . _storageManager . getValue < IVersion > ( GlobalState . PreviousVersion , 'global' ) ?? '0.0.0' ,
126- ) ;
124+ const prevVer = this . _stateController . getVersion ( ) ;
127125
128126 const newVer = gcodeVersion . compareWith ( prevVer . getVersion ( ) ) === 1 ? true : false ;
129127
130128 if ( newVer ) {
131129 // Extension has been updated
132- Logger . log ( `G-Code upgraded from ${ prevVer . getVersionAsString ( ) } to ${ gcodeVersion . getVersionAsString ( ) } ` ) ;
133- await this . showWhatsNew ( gcodeVersion ) ;
134130
135131 // Update globalState version
136- void this . _storageManager . setValue < IVersion > (
137- GlobalState . PreviousVersion ,
138- gcodeVersion . getVersion ( ) ,
139- 'global' ,
140- ) ;
132+ Logger . log ( 'Updating...' ) ;
133+ void this . _stateController . updateVer ( gcodeVersion ) ;
134+
135+ Logger . log ( `G-Code upgraded from ${ prevVer . getVersionAsString ( ) } to ${ gcodeVersion . getVersionAsString ( ) } ` ) ;
136+ await this . showWhatsNew ( gcodeVersion ) ;
141137 } else {
142138 return ;
143139 }
@@ -183,4 +179,8 @@ export class Control {
183179 static get gcodeUnitsController ( ) {
184180 return this . _unitsController ;
185181 }
182+
183+ static get stateController ( ) {
184+ return this . _stateController ;
185+ }
186186}
0 commit comments