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