mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-17 14:19:29 +00:00
fix 180: prevent erroneous "auto-reconnect"(s) in board selector (#1328)
* ensure auto-select doesn't select wrong port prevent auto-select of unattached boards Co-authored-by: Francesco Spissu <francescospissu@users.noreply.github.com> * clean up * add "uploadInProgress" prop to boards change event * remove unused methods and deps * [WIP]: leverage upload event to derived new port * remove timeout * refine port selection logic * clean up naming * refine port selection logic & add delayed clean up * renaming & refactoring * method syntax & remove unnecessary methods
This commit is contained in:
@@ -54,6 +54,8 @@ export class BoardDiscovery
|
||||
private readonly onStreamDidCancelEmitter = new Emitter<void>(); // when the watcher is canceled by the IDE2
|
||||
private readonly toDisposeOnStopWatch = new DisposableCollection();
|
||||
|
||||
private uploadInProgress = false;
|
||||
|
||||
/**
|
||||
* Keys are the `address` of the ports.
|
||||
*
|
||||
@@ -123,6 +125,10 @@ export class BoardDiscovery
|
||||
});
|
||||
}
|
||||
|
||||
setUploadInProgress(uploadAttemptInProgress: boolean): void {
|
||||
this.uploadInProgress = uploadAttemptInProgress;
|
||||
}
|
||||
|
||||
private createTimeout(
|
||||
after: number,
|
||||
onTimeout: (error: Error) => void
|
||||
@@ -318,6 +324,7 @@ export class BoardDiscovery
|
||||
ports: newAvailablePorts,
|
||||
boards: newAttachedBoards,
|
||||
},
|
||||
uploadInProgress: this.uploadInProgress,
|
||||
};
|
||||
|
||||
this._availablePorts = newState;
|
||||
|
||||
@@ -34,6 +34,7 @@ import { Instance } from './cli-protocol/cc/arduino/cli/commands/v1/common_pb';
|
||||
import { firstToUpperCase, notEmpty } from '../common/utils';
|
||||
import { ServiceError } from './service-error';
|
||||
import { ExecuteWithProgress, ProgressResponse } from './grpc-progressible';
|
||||
import { BoardDiscovery } from './board-discovery';
|
||||
|
||||
namespace Uploadable {
|
||||
export type Request = UploadRequest | UploadUsingProgrammerRequest;
|
||||
@@ -51,6 +52,9 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
|
||||
@inject(CommandService)
|
||||
private readonly commandService: CommandService;
|
||||
|
||||
@inject(BoardDiscovery)
|
||||
private readonly boardDiscovery: BoardDiscovery;
|
||||
|
||||
async compile(options: CoreService.Options.Compile): Promise<void> {
|
||||
const coreClient = await this.coreClient;
|
||||
const { client, instance } = coreClient;
|
||||
@@ -378,6 +382,7 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
|
||||
fqbn?: string | undefined;
|
||||
port?: Port | undefined;
|
||||
}): Promise<void> {
|
||||
this.boardDiscovery.setUploadInProgress(true);
|
||||
return this.monitorManager.notifyUploadStarted(fqbn, port);
|
||||
}
|
||||
|
||||
@@ -388,6 +393,7 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
|
||||
fqbn?: string | undefined;
|
||||
port?: Port | undefined;
|
||||
}): Promise<Status> {
|
||||
this.boardDiscovery.setUploadInProgress(false);
|
||||
return this.monitorManager.notifyUploadFinished(fqbn, port);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user