fix: update Examples and Include Library menu after ZIP install

Closes #659

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta 2023-01-09 08:09:24 +01:00 committed by Akos Kitta
parent 287b2e3f41
commit b2bf368db9
4 changed files with 29 additions and 19 deletions

View File

@ -56,7 +56,7 @@ export class NotificationCenter
item: BoardsPackage;
}>();
private readonly libraryDidInstallEmitter = new Emitter<{
item: LibraryPackage;
item: LibraryPackage | 'zip-install';
}>();
private readonly libraryDidUninstallEmitter = new Emitter<{
item: LibraryPackage;
@ -156,7 +156,9 @@ export class NotificationCenter
this.platformDidUninstallEmitter.fire(event);
}
notifyLibraryDidInstall(event: { item: LibraryPackage }): void {
notifyLibraryDidInstall(event: {
item: LibraryPackage | 'zip-install';
}): void {
this.libraryDidInstallEmitter.fire(event);
}

View File

@ -62,7 +62,9 @@ export interface NotificationServiceClient {
notifyPlatformDidUninstall(event: { item: BoardsPackage }): void;
// Libraries
notifyLibraryDidInstall(event: { item: LibraryPackage }): void;
notifyLibraryDidInstall(event: {
item: LibraryPackage | 'zip-install';
}): void;
notifyLibraryDidUninstall(event: { item: LibraryPackage }): void;
// Boards discovery

View File

@ -373,22 +373,26 @@ export class LibraryServiceImpl
// stop the board discovery
await this.boardDiscovery.stop();
const resp = client.zipLibraryInstall(req);
resp.on(
'data',
ExecuteWithProgress.createDataCallback({
progressId,
responseService: this.responseService,
})
);
await new Promise<void>((resolve, reject) => {
resp.on('end', () => {
this.boardDiscovery.start(); // TODO: remove discovery dependency from boards service. See https://github.com/arduino/arduino-ide/pull/1107 why this is here.
resolve();
try {
const resp = client.zipLibraryInstall(req);
resp.on(
'data',
ExecuteWithProgress.createDataCallback({
progressId,
responseService: this.responseService,
})
);
await new Promise<void>((resolve, reject) => {
resp.on('end', resolve);
resp.on('error', reject);
});
resp.on('error', reject);
});
await this.refresh(); // let the CLI re-scan the libraries
this.notificationServer.notifyLibraryDidInstall({
item: 'zip-install',
});
} finally {
this.boardDiscovery.start(); // TODO: remove discovery dependency from boards service. See https://github.com/arduino/arduino-ide/pull/1107 why this is here.
}
}
async uninstall(options: {

View File

@ -59,7 +59,9 @@ export class NotificationServiceServerImpl
this.clients.forEach((client) => client.notifyPlatformDidUninstall(event));
}
notifyLibraryDidInstall(event: { item: LibraryPackage }): void {
notifyLibraryDidInstall(event: {
item: LibraryPackage | 'zip-install';
}): void {
this.clients.forEach((client) => client.notifyLibraryDidInstall(event));
}