at first ide startup invoke installation of arduino:avr (#497)

This commit is contained in:
Alberto Iannaccone 2021-09-02 11:50:26 +01:00 committed by GitHub
parent 658c19f55b
commit bfb90a8b4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@ import {
ContextMenuRenderer, ContextMenuRenderer,
FrontendApplication, FrontendApplication,
FrontendApplicationContribution, FrontendApplicationContribution,
LocalStorageService,
OpenerService, OpenerService,
StatusBar, StatusBar,
StatusBarAlignment, StatusBarAlignment,
@ -79,6 +80,8 @@ import { FileChangeType } from '@theia/filesystem/lib/browser';
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state'; import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
import { SketchbookWidgetContribution } from './widgets/sketchbook/sketchbook-widget-contribution'; import { SketchbookWidgetContribution } from './widgets/sketchbook/sketchbook-widget-contribution';
const INIT_AVR_PACKAGES = 'initializedAvrPackages';
@injectable() @injectable()
export class ArduinoFrontendContribution export class ArduinoFrontendContribution
implements implements
@ -199,6 +202,9 @@ export class ArduinoFrontendContribution
@inject(FrontendApplicationStateService) @inject(FrontendApplicationStateService)
protected readonly appStateService: FrontendApplicationStateService; protected readonly appStateService: FrontendApplicationStateService;
@inject(LocalStorageService)
protected readonly localStorageService: LocalStorageService;
protected invalidConfigPopup: protected invalidConfigPopup:
| Promise<void | 'No' | 'Yes' | undefined> | Promise<void | 'No' | 'Yes' | undefined>
| undefined; | undefined;
@ -206,6 +212,16 @@ export class ArduinoFrontendContribution
@postConstruct() @postConstruct()
protected async init(): Promise<void> { protected async init(): Promise<void> {
const notFirstStartup = await this.localStorageService.getData(
INIT_AVR_PACKAGES
);
if (!notFirstStartup) {
await this.localStorageService.setData(INIT_AVR_PACKAGES, true);
const avrPackage = await this.boardsService.getBoardPackage({
id: 'arduino:avr',
});
avrPackage && (await this.boardsService.install({ item: avrPackage }));
}
if (!window.navigator.onLine) { if (!window.navigator.onLine) {
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
this.messageService.warn( this.messageService.warn(