@@ -15,7 +15,8 @@ import { StatsView } from './views/statsView';
1515import { constants , Contexts , GlobalState , PIcon , VSBuiltInCommands } from './util/constants' ;
1616import { Commands } from './util/commands' ;
1717import { LocalStorageService } from './util/localStorageService' ;
18- import { Version } from './util/version' ;
18+ import { IVersion , Version } from './util/version' ;
19+ import { Messages } from './util/messages' ;
1920
2021export class Control {
2122 private static _config : Config | undefined ;
@@ -100,6 +101,9 @@ export class Control {
100101 undefined ,
101102 Commands . GCSUPPORT ,
102103 ) ;
104+
105+ // Check Version
106+ void this . checkVersion ( ) ;
103107 }
104108
105109 static terminate ( ) {
@@ -114,22 +118,34 @@ export class Control {
114118 return secs * 1000 + nanosecs / 1000000 ;
115119 }
116120
117- static checkVersion ( ) {
118- const localVer = new Version ( constants . extension . version ) ;
121+ private static async checkVersion ( ) {
122+ const gcodeVersion = new Version ( constants . extension . version ) ;
119123
120- const prevVer = this . _storageManager . getValue < Version > ( GlobalState . PreviousVersion , 'global' ) ?? localVer ;
124+ const prevVer = new Version (
125+ this . _storageManager . getValue < IVersion > ( GlobalState . PreviousVersion , 'global' ) ?? '0.0.0' ,
126+ ) ;
121127
122- const newVer = localVer . compareWith ( prevVer . getVersion ( ) ) === 1 ? true : false ;
128+ const newVer = gcodeVersion . compareWith ( prevVer . getVersion ( ) ) === 1 ? true : false ;
123129
124130 if ( newVer ) {
125131 // Extension has been updated
132+ Logger . log ( `G-Code upgraded from ${ prevVer . getVersionAsString ( ) } to ${ gcodeVersion . getVersionAsString ( ) } ` ) ;
133+ await this . showWhatsNew ( gcodeVersion ) ;
134+
135+ // Update globalState version
136+ void this . _storageManager . setValue < IVersion > (
137+ GlobalState . PreviousVersion ,
138+ gcodeVersion . getVersion ( ) ,
139+ 'global' ,
140+ ) ;
126141 } else {
127142 return ;
128143 }
129144 }
130145
131- static showWhatsNew ( ) {
146+ private static async showWhatsNew ( ver : Version ) {
132147 // Show Whats New Message
148+ await Messages . showWhatsNewMessage ( ver ) ;
133149 }
134150
135151 static setContext ( key : Contexts | string , value : any ) {
0 commit comments