mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-13 14:26:37 +00:00
Restart discovery after re-initializing client.
Otherwise, board discovery stops working after indexes update. Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
parent
c51b201362
commit
431c3bdf2b
@ -56,6 +56,11 @@ export class BoardDiscovery extends CoreClientAware {
|
||||
@postConstruct()
|
||||
protected async init(): Promise<void> {
|
||||
this.coreClient.then((client) => this.startBoardListWatch(client));
|
||||
this.onClientDidRefresh((client) =>
|
||||
this.stopBoardListWatch(client).then(() =>
|
||||
this.startBoardListWatch(client)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
stopBoardListWatch(coreClient: CoreClientProvider.Client): Promise<void> {
|
||||
@ -79,7 +84,7 @@ export class BoardDiscovery extends CoreClientAware {
|
||||
startBoardListWatch(coreClient: CoreClientProvider.Client): void {
|
||||
if (this.watching) {
|
||||
// We want to avoid starting the board list watch process multiple
|
||||
// times to meet unforseen consequences
|
||||
// times to meet unforeseen consequences
|
||||
return;
|
||||
}
|
||||
this.watching = true;
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
injectable,
|
||||
postConstruct,
|
||||
} from '@theia/core/shared/inversify';
|
||||
import { Emitter } from '@theia/core/lib/common/event';
|
||||
import { Emitter, Event } from '@theia/core/lib/common/event';
|
||||
import { ArduinoCoreServiceClient } from './cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb';
|
||||
import { Instance } from './cli-protocol/cc/arduino/cli/commands/v1/common_pb';
|
||||
import {
|
||||
@ -53,6 +53,8 @@ export class CoreClientProvider {
|
||||
private readonly onClientReadyEmitter =
|
||||
new Emitter<CoreClientProvider.Client>();
|
||||
private readonly onClientReady = this.onClientReadyEmitter.event;
|
||||
private readonly onClientDidRefreshEmitter =
|
||||
new Emitter<CoreClientProvider.Client>();
|
||||
|
||||
@postConstruct()
|
||||
protected init(): void {
|
||||
@ -88,6 +90,10 @@ export class CoreClientProvider {
|
||||
return this.pending.promise;
|
||||
}
|
||||
|
||||
get onClientDidRefresh(): Event<CoreClientProvider.Client> {
|
||||
return this.onClientDidRefreshEmitter.event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates both the gRPC core client creation (`CreateRequest`) and initialization (`InitRequest`).
|
||||
*/
|
||||
@ -253,6 +259,7 @@ export class CoreClientProvider {
|
||||
await this.initInstance(client);
|
||||
// notify clients about the index update only after the client has been "re-initialized" and the new content is available.
|
||||
progressHandler.reportEnd();
|
||||
this.onClientDidRefreshEmitter.fire(client);
|
||||
} catch (err) {
|
||||
console.error('Failed to update indexes', err);
|
||||
progressHandler.reportError(
|
||||
@ -404,6 +411,10 @@ export abstract class CoreClientAware {
|
||||
protected get coreClient(): Promise<CoreClientProvider.Client> {
|
||||
return this.coreClientProvider.client;
|
||||
}
|
||||
|
||||
protected get onClientDidRefresh(): Event<CoreClientProvider.Client> {
|
||||
return this.coreClientProvider.onClientDidRefresh;
|
||||
}
|
||||
}
|
||||
|
||||
class IndexUpdateRequiredBeforeInitError extends Error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user