55
66'use strict' ;
77
8- import { Disposable , ExtensionContext } from 'vscode' ;
8+ import { commands , Disposable , ExtensionContext } from 'vscode' ;
99import { Config , configuration } from './util/config' ;
1010import { Logger } from './util/logger' ;
1111import { StatusBarControl } from './util/statusBar' ;
1212import { NavTreeView } from './views/navTreeView' ;
1313import { GCodeUnitsController } from './gcodeUnits' ;
1414import { StatsView } from './views/statsView' ;
15- import { PIcon } from './util/constants' ;
15+ import { constants , Contexts , GlobalState , PIcon , VSBuiltInCommands } from './util/constants' ;
1616import { Commands } from './util/commands' ;
17+ import { LocalStorageService } from './util/localStorageService' ;
18+ import { Version } from './util/version' ;
1719
1820export class Control {
1921 private static _config : Config | undefined ;
@@ -23,6 +25,7 @@ export class Control {
2325 // Controllers
2426 private static _statusBarControl : StatusBarControl ;
2527 private static _unitsController : GCodeUnitsController | undefined ;
28+ private static _storageManager : LocalStorageService ;
2629
2730 // Views
2831 private static _statsView : StatsView | undefined ;
@@ -32,6 +35,9 @@ export class Control {
3235 this . _context = context ;
3336 this . _config = config ;
3437
38+ // Load GlobalState Storage Manager
39+ this . _storageManager = new LocalStorageService ( context ) ;
40+
3541 // Load StatusBars
3642 context . subscriptions . push ( ( this . _statusBarControl = new StatusBarControl ( this . _context ) ) ) ;
3743
@@ -88,7 +94,7 @@ export class Control {
8894
8995 // Load Support Heart to Statusbar
9096 this . _statusBarControl . updateStatusBar (
91- PIcon . HEART ,
97+ PIcon . Heart ,
9298 'support' ,
9399 'Support G-Code Syntax ❤' ,
94100 undefined ,
@@ -108,6 +114,28 @@ export class Control {
108114 return secs * 1000 + nanosecs / 1000000 ;
109115 }
110116
117+ static checkVersion ( ) {
118+ const localVer = new Version ( constants . extension . version ) ;
119+
120+ const prevVer = this . _storageManager . getValue < Version > ( GlobalState . PreviousVersion , 'global' ) ?? localVer ;
121+
122+ const newVer = localVer . compareWith ( prevVer . getVersion ( ) ) === 1 ? true : false ;
123+
124+ if ( newVer ) {
125+ // Extension has been updated
126+ } else {
127+ return ;
128+ }
129+ }
130+
131+ static showWhatsNew ( ) {
132+ // Show Whats New Message
133+ }
134+
135+ static setContext ( key : Contexts | string , value : any ) {
136+ return commands . executeCommand ( VSBuiltInCommands . SetContext , key , value ) ;
137+ }
138+
111139 static get context ( ) {
112140 return this . _context ;
113141 }
0 commit comments