workaround for non-unique names.

Fine tuned the port unnselection when attached boards change.

This should make sure we do not have to `await` for the attached boards
from the backend.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta
2019-07-31 11:49:26 +02:00
committed by jbicker
parent 0dc45daf01
commit 66f429c478
3 changed files with 78 additions and 26 deletions

View File

@@ -7,6 +7,21 @@ export interface AttachedBoardsChangeEvent {
readonly oldState: Readonly<{ boards: Board[] }>;
readonly newState: Readonly<{ boards: Board[] }>;
}
export namespace AttachedBoardsChangeEvent {
export function diff(event: AttachedBoardsChangeEvent): Readonly<{ attached: Board[], detached: Board[] }> {
const diff = <T>(left: T[], right: T[]) => {
return left.filter(item => right.indexOf(item) === -1);
}
const { boards: newBoards } = event.newState;
const { boards: oldBoards } = event.oldState;
return {
detached: diff(oldBoards, newBoards),
attached: diff(newBoards, oldBoards)
};
}
}
export interface BoardInstalledEvent {
readonly pkg: Readonly<BoardPackage>;
@@ -34,10 +49,6 @@ export interface Board {
fqbn?: string
}
export interface Port {
port?: string;
}
export namespace Board {
export function is(board: any): board is Board {