Defer settings/certificates load until app ready.

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta 2022-08-05 16:24:52 +02:00 committed by Akos Kitta
parent 92bc5ecf7b
commit 7a3e6789d1
2 changed files with 15 additions and 7 deletions

View File

@ -19,6 +19,7 @@ import { CommandRegistry } from '@theia/core/lib/common/command';
import { certificateList, sanifyCertString } from './utils';
import { ArduinoFirmwareUploader } from '../../../common/protocol/arduino-firmware-uploader';
import { nls } from '@theia/core/lib/common';
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
@injectable()
export class UploadCertificateDialogWidget extends ReactWidget {
@ -37,6 +38,9 @@ export class UploadCertificateDialogWidget extends ReactWidget {
@inject(ArduinoFirmwareUploader)
protected readonly arduinoFirmwareUploader: ArduinoFirmwareUploader;
@inject(FrontendApplicationStateService)
private readonly appStateService: FrontendApplicationStateService;
protected certificates: string[] = [];
protected updatableFqbns: string[] = [];
protected availableBoards: AvailableBoard[] = [];
@ -66,10 +70,12 @@ export class UploadCertificateDialogWidget extends ReactWidget {
}
});
this.arduinoFirmwareUploader.updatableBoards().then((fqbns) => {
this.updatableFqbns = fqbns;
this.update();
});
this.appStateService.reachedState('ready').then(() =>
this.arduinoFirmwareUploader.updatableBoards().then((fqbns) => {
this.updatableFqbns = fqbns;
this.update();
})
);
this.boardsServiceClient.onAvailableBoardsChanged((availableBoards) => {
this.availableBoards = availableBoards;

View File

@ -111,9 +111,11 @@ export class SettingsService {
@postConstruct()
protected async init(): Promise<void> {
const settings = await this.loadSettings();
this._settings = deepClone(settings);
this.ready.resolve();
this.appStateService.reachedState('ready').then(async () => {
const settings = await this.loadSettings();
this._settings = deepClone(settings);
this.ready.resolve();
});
}
protected async loadSettings(): Promise<Settings> {