Skip to content

Commit

Permalink
fix: update Examples and Include Library menu after ZIP install
Browse files Browse the repository at this point in the history
Closes #659

Signed-off-by: Akos Kitta <[email protected]>
  • Loading branch information
Akos Kitta authored and kittaakos committed Jan 11, 2023
1 parent 287b2e3 commit b2bf368
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
6 changes: 4 additions & 2 deletions arduino-ide-extension/src/browser/notification-center.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 19 additions & 15 deletions arduino-ide-extension/src/node/library-service-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit b2bf368

Please sign in to comment.