11import  {  injectable ,  inject ,  named  }  from  'inversify' ; 
22import  {  ILogger  }  from  '@theia/core/lib/common/logger' ; 
33import  {  deepClone  }  from  '@theia/core/lib/common/objects' ; 
4- import  {  MaybePromise  }  from  '@theia/core/lib/common/types' ; 
54import  {  Event ,  Emitter  }  from  '@theia/core/lib/common/event' ; 
65import  { 
76  FrontendApplicationContribution , 
@@ -11,7 +10,6 @@ import { notEmpty } from '../../common/utils';
1110import  { 
1211  BoardsService , 
1312  ConfigOption , 
14-   Installable , 
1513  BoardDetails , 
1614  Programmer , 
1715}  from  '../../common/protocol' ; 
@@ -36,16 +34,12 @@ export class BoardsDataStore implements FrontendApplicationContribution {
3634
3735  onStart ( ) : void { 
3836    this . notificationCenter . onPlatformInstalled ( async  ( {  item } )  =>  { 
39-       const  {  installedVersion : version  }  =  item ; 
40-       if  ( ! version )  { 
41-         return ; 
42-       } 
4337      let  shouldFireChanged  =  false ; 
4438      for  ( const  fqbn  of  item . boards 
4539        . map ( ( {  fqbn } )  =>  fqbn ) 
4640        . filter ( notEmpty ) 
4741        . filter ( ( fqbn )  =>  ! ! fqbn ) )  { 
48-         const  key  =  this . getStorageKey ( fqbn ,   version ) ; 
42+         const  key  =  this . getStorageKey ( fqbn ) ; 
4943        let  data  =  await  this . storageService . getData < 
5044          ConfigOption [ ]  |  undefined 
5145        > ( key ) ; 
@@ -72,33 +66,20 @@ export class BoardsDataStore implements FrontendApplicationContribution {
7266
7367  async  appendConfigToFqbn ( 
7468    fqbn : string  |  undefined , 
75-     boardsPackageVersion : MaybePromise < 
76-       Installable . Version  |  undefined 
77-     >  =  this . getBoardsPackageVersion ( fqbn ) 
7869  ) : Promise < string  |  undefined >  { 
7970    if  ( ! fqbn )  { 
8071      return  undefined ; 
8172    } 
82- 
83-     const  {  configOptions }  =  await  this . getData ( fqbn ,  boardsPackageVersion ) ; 
73+     const  {  configOptions }  =  await  this . getData ( fqbn ) ; 
8474    return  ConfigOption . decorate ( fqbn ,  configOptions ) ; 
8575  } 
8676
87-   async  getData ( 
88-     fqbn : string  |  undefined , 
89-     boardsPackageVersion : MaybePromise < 
90-       Installable . Version  |  undefined 
91-     >  =  this . getBoardsPackageVersion ( fqbn ) 
92-   ) : Promise < BoardsDataStore . Data >  { 
77+   async  getData ( fqbn : string  |  undefined ) : Promise < BoardsDataStore . Data >  { 
9378    if  ( ! fqbn )  { 
9479      return  BoardsDataStore . Data . EMPTY ; 
9580    } 
9681
97-     const  version  =  await  boardsPackageVersion ; 
98-     if  ( ! version )  { 
99-       return  BoardsDataStore . Data . EMPTY ; 
100-     } 
101-     const  key  =  this . getStorageKey ( fqbn ,  version ) ; 
82+     const  key  =  this . getStorageKey ( fqbn ) ; 
10283    let  data  =  await  this . storageService . getData < 
10384      BoardsDataStore . Data  |  undefined 
10485    > ( key ,  undefined ) ; 
@@ -124,25 +105,16 @@ export class BoardsDataStore implements FrontendApplicationContribution {
124105      fqbn, 
125106      selectedProgrammer, 
126107    } : {  fqbn : string ;  selectedProgrammer : Programmer  } , 
127-     boardsPackageVersion : MaybePromise < 
128-       Installable . Version  |  undefined 
129-     >  =  this . getBoardsPackageVersion ( fqbn ) 
130108  ) : Promise < boolean >  { 
131-     const  data  =  deepClone ( await  this . getData ( fqbn ,   boardsPackageVersion ) ) ; 
109+     const  data  =  deepClone ( await  this . getData ( fqbn ) ) ; 
132110    const  {  programmers }  =  data ; 
133111    if  ( ! programmers . find ( ( p )  =>  Programmer . equals ( selectedProgrammer ,  p ) ) )  { 
134112      return  false ; 
135113    } 
136114
137-     const  version  =  await  boardsPackageVersion ; 
138-     if  ( ! version )  { 
139-       return  false ; 
140-     } 
141- 
142115    await  this . setData ( { 
143116      fqbn, 
144117      data : {  ...data ,  selectedProgrammer } , 
145-       version, 
146118    } ) ; 
147119    this . fireChanged ( ) ; 
148120    return  true ; 
@@ -153,12 +125,9 @@ export class BoardsDataStore implements FrontendApplicationContribution {
153125      fqbn, 
154126      option, 
155127      selectedValue, 
156-     } : {  fqbn : string ;  option : string ;  selectedValue : string  } , 
157-     boardsPackageVersion : MaybePromise < 
158-       Installable . Version  |  undefined 
159-     >  =  this . getBoardsPackageVersion ( fqbn ) 
128+     } : {  fqbn : string ;  option : string ;  selectedValue : string  } 
160129  ) : Promise < boolean >  { 
161-     const  data  =  deepClone ( await  this . getData ( fqbn ,   boardsPackageVersion ) ) ; 
130+     const  data  =  deepClone ( await  this . getData ( fqbn ) ) ; 
162131    const  {  configOptions }  =  data ; 
163132    const  configOption  =  configOptions . find ( ( c )  =>  c . option  ===  option ) ; 
164133    if  ( ! configOption )  { 
@@ -176,31 +145,24 @@ export class BoardsDataStore implements FrontendApplicationContribution {
176145    if  ( ! updated )  { 
177146      return  false ; 
178147    } 
179-     const  version  =  await  boardsPackageVersion ; 
180-     if  ( ! version )  { 
181-       return  false ; 
182-     } 
183- 
184-     await  this . setData ( {  fqbn,  data,  version } ) ; 
148+     await  this . setData ( {  fqbn,  data } ) ; 
185149    this . fireChanged ( ) ; 
186150    return  true ; 
187151  } 
188152
189153  protected  async  setData ( { 
190154    fqbn, 
191155    data, 
192-     version, 
193156  } : { 
194157    fqbn : string ; 
195158    data : BoardsDataStore . Data ; 
196-     version : Installable . Version ; 
197159  } ) : Promise < void >  { 
198-     const  key  =  this . getStorageKey ( fqbn ,   version ) ; 
160+     const  key  =  this . getStorageKey ( fqbn ) ; 
199161    return  this . storageService . setData ( key ,  data ) ; 
200162  } 
201163
202-   protected  getStorageKey ( fqbn : string ,   version :  Installable . Version ) : string  { 
203-     return  `.arduinoIDE-configOptions-${ version } - ${ fqbn }  ; 
164+   protected  getStorageKey ( fqbn : string ) : string  { 
165+     return  `.arduinoIDE-configOptions-${ fqbn }  ; 
204166  } 
205167
206168  protected  async  getBoardDetailsSafe ( 
@@ -231,21 +193,6 @@ export class BoardsDataStore implements FrontendApplicationContribution {
231193  protected  fireChanged ( ) : void { 
232194    this . onChangedEmitter . fire ( ) ; 
233195  } 
234- 
235-   protected  async  getBoardsPackageVersion ( 
236-     fqbn : string  |  undefined 
237-   ) : Promise < Installable . Version  |  undefined >  { 
238-     if  ( ! fqbn )  { 
239-       return  undefined ; 
240-     } 
241-     const  boardsPackage  =  await  this . boardsService . getContainerBoardPackage ( { 
242-       fqbn, 
243-     } ) ; 
244-     if  ( ! boardsPackage )  { 
245-       return  undefined ; 
246-     } 
247-     return  boardsPackage . installedVersion ; 
248-   } 
249196} 
250197
251198export  namespace  BoardsDataStore  { 
0 commit comments