Skip to content

Commit

Permalink
Fixed missing core client in the monitor service.
Browse files Browse the repository at this point in the history
Restored monitor service creation state before a36524e:
Pass core client provider into new instances as a field.

Closes arduino#1161

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
  • Loading branch information
Akos Kitta authored and kittaakos committed Jul 11, 2022
1 parent 7d96153 commit f4a68e7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion arduino-ide-extension/src/node/arduino-ide-backend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,15 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
const webSocketProvider =
container.get<WebSocketProvider>(WebSocketProvider);

const { board, port, monitorID } = options;
const { board, port, coreClientProvider, monitorID } = options;

return new MonitorService(
logger,
monitorSettingsProvider,
webSocketProvider,
board,
port,
coreClientProvider,
monitorID
);
}
Expand Down
2 changes: 1 addition & 1 deletion arduino-ide-extension/src/node/core-client-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export namespace CoreClientProvider {
@injectable()
export abstract class CoreClientAware {
@inject(CoreClientProvider)
private readonly coreClientProvider: CoreClientProvider;
protected readonly coreClientProvider: CoreClientProvider; // TODO: should be `private`, fix injection in subclasses. (https://github.com/arduino/arduino-ide/issues/1161)
/**
* Returns with a promise that resolves when the core client is initialized and ready.
*/
Expand Down
3 changes: 2 additions & 1 deletion arduino-ide-extension/src/node/monitor-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class MonitorManager extends CoreClientAware {
* @param board board connected to port
* @param port port to monitor
* @returns true if the monitor is currently monitoring the board/port
* combination specifed, false in all other cases.
* combination specified, false in all other cases.
*/
isStarted(board: Board, port: Port): boolean {
const monitorID = this.monitorID(board, port);
Expand Down Expand Up @@ -317,6 +317,7 @@ export class MonitorManager extends CoreClientAware {
board,
port,
monitorID,
coreClientProvider: this.coreClientProvider,
});
this.monitorServices.set(monitorID, monitor);
monitor.onDispose(
Expand Down
9 changes: 8 additions & 1 deletion arduino-ide-extension/src/node/monitor-service-factory.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { Board, Port } from '../common/protocol';
import { CoreClientProvider } from './core-client-provider';
import { MonitorService } from './monitor-service';

export const MonitorServiceFactory = Symbol('MonitorServiceFactory');
export interface MonitorServiceFactory {
(options: { board: Board; port: Port; monitorID: string }): MonitorService;
(options: {
board: Board;
port: Port;
monitorID: string;
coreClientProvider: CoreClientProvider;
}): MonitorService;
}

export interface MonitorServiceFactoryOptions {
board: Board;
port: Port;
monitorID: string;
coreClientProvider: CoreClientProvider;
}
3 changes: 2 additions & 1 deletion arduino-ide-extension/src/node/monitor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
MonitorRequest,
MonitorResponse,
} from './cli-protocol/cc/arduino/cli/commands/v1/monitor_pb';
import { CoreClientAware } from './core-client-provider';
import { CoreClientAware, CoreClientProvider } from './core-client-provider';
import { WebSocketProvider } from './web-socket/web-socket-provider';
import { Port as gRPCPort } from 'arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/port_pb';
import {
Expand Down Expand Up @@ -77,6 +77,7 @@ export class MonitorService extends CoreClientAware implements Disposable {

private readonly board: Board,
private readonly port: Port,
protected override readonly coreClientProvider: CoreClientProvider,
private readonly monitorID: string
) {
super();
Expand Down

0 comments on commit f4a68e7

Please sign in to comment.