mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-05 08:28:32 +00:00
ATL-469: Fixed various serial-monitor issues.
- Fixed a monitor reconnecting issue after upload. - Serial monitor connection was not disposed when the widget was closed from the toolbar with the magnifier (🔍) icon. It worked only iff the user closed the view with the `X`. - This commit also fixes a warning that was related to the incorrect focus handling of the widget. - Switched to `board list -w` instead of polling. - Added a singleton for the board discovery to spare the CPU. - Fixed DI scopes on the backend. Each frontend gets its own service. - Switched to the `20201112` nightly CLI. - Fixed the Monitor view's image when the view is on the side-bar. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
@@ -265,6 +265,29 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
|
||||
return this._availableBoards;
|
||||
}
|
||||
|
||||
async waitUntilAvailable(what: Board & { port: Port }, timeout?: number): Promise<void> {
|
||||
const find = (needle: Board & { port: Port }, haystack: AvailableBoard[]) =>
|
||||
haystack.find(board => Board.equals(needle, board) && Port.equals(needle.port, board.port));
|
||||
const timeoutTask = !!timeout && timeout > 0
|
||||
? new Promise<void>((_, reject) => setTimeout(() => reject(new Error(`Timeout after ${timeout} ms.`)), timeout))
|
||||
: new Promise<void>(() => { /* never */ });
|
||||
const waitUntilTask = new Promise<void>(resolve => {
|
||||
let candidate = find(what, this.availableBoards);
|
||||
if (candidate) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
const disposable = this.onAvailableBoardsChanged(availableBoards => {
|
||||
candidate = find(what, availableBoards);
|
||||
if (candidate) {
|
||||
disposable.dispose();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
return await Promise.race([waitUntilTask, timeoutTask]);
|
||||
}
|
||||
|
||||
protected async reconcileAvailableBoards(): Promise<void> {
|
||||
const attachedBoards = this._attachedBoards;
|
||||
const availablePorts = this._availablePorts;
|
||||
|
||||
Reference in New Issue
Block a user