1
- import { injectable , inject , postConstruct } from 'inversify' ;
1
+ import { injectable , inject } from 'inversify' ;
2
2
import { Emitter } from '@theia/core/lib/common/event' ;
3
3
import { ILogger } from '@theia/core/lib/common/logger' ;
4
+ import { MessageService } from '@theia/core/lib/common/message-service' ;
4
5
import { LocalStorageService } from '@theia/core/lib/browser/storage-service' ;
6
+ import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application' ;
5
7
import { RecursiveRequired } from '../../common/types' ;
6
8
import { BoardsServiceClient , AttachedBoardsChangeEvent , BoardInstalledEvent , AttachedSerialBoard , Board , Port , BoardUninstalledEvent } from '../../common/protocol/boards-service' ;
7
9
import { BoardsConfig } from './boards-config' ;
8
- import { MessageService } from '@theia/core' ;
9
10
10
11
@injectable ( )
11
- export class BoardsServiceClientImpl implements BoardsServiceClient {
12
+ export class BoardsServiceClientImpl implements BoardsServiceClient , FrontendApplicationContribution {
12
13
13
14
@inject ( ILogger )
14
15
protected logger : ILogger ;
@@ -39,9 +40,8 @@ export class BoardsServiceClientImpl implements BoardsServiceClient {
39
40
readonly onBoardUninstalled = this . onBoardUninstalledEmitter . event ;
40
41
readonly onBoardsConfigChanged = this . onSelectedBoardsConfigChangedEmitter . event ;
41
42
42
- @postConstruct ( )
43
- protected init ( ) : void {
44
- this . loadState ( ) ;
43
+ async onStart ( ) : Promise < void > {
44
+ return this . loadState ( ) ;
45
45
}
46
46
47
47
notifyAttachedBoardsChanged ( event : AttachedBoardsChangeEvent ) : void {
@@ -124,7 +124,7 @@ export class BoardsServiceClientImpl implements BoardsServiceClient {
124
124
125
125
if ( ! config . selectedBoard ) {
126
126
if ( ! options . silent ) {
127
- this . messageService . warn ( 'No boards selected.' ) ;
127
+ this . messageService . warn ( 'No boards selected.' , { timeout : 3000 } ) ;
128
128
}
129
129
return false ;
130
130
}
@@ -146,14 +146,14 @@ export class BoardsServiceClientImpl implements BoardsServiceClient {
146
146
const { name } = config . selectedBoard ;
147
147
if ( ! config . selectedPort ) {
148
148
if ( ! options . silent ) {
149
- this . messageService . warn ( `No ports selected for board: '${ name } '.` ) ;
149
+ this . messageService . warn ( `No ports selected for board: '${ name } '.` , { timeout : 3000 } ) ;
150
150
}
151
151
return false ;
152
152
}
153
153
154
154
if ( ! config . selectedBoard . fqbn ) {
155
155
if ( ! options . silent ) {
156
- this . messageService . warn ( `The FQBN is not available for the selected board ${ name } . Do you have the corresponding core installed?` ) ;
156
+ this . messageService . warn ( `The FQBN is not available for the selected board ${ name } . Do you have the corresponding core installed?` , { timeout : 3000 } ) ;
157
157
}
158
158
return false ;
159
159
}
@@ -169,6 +169,9 @@ export class BoardsServiceClientImpl implements BoardsServiceClient {
169
169
const storedValidBoardsConfig = await this . storageService . getData < RecursiveRequired < BoardsConfig . Config > > ( 'latest-valid-boards-config' ) ;
170
170
if ( storedValidBoardsConfig ) {
171
171
this . latestValidBoardsConfig = storedValidBoardsConfig ;
172
+ if ( this . canUploadTo ( this . latestValidBoardsConfig ) ) {
173
+ this . boardsConfig = this . latestValidBoardsConfig ;
174
+ }
172
175
}
173
176
}
174
177
0 commit comments