mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-10-27 20:18:35 +00:00
Fix boards listing (#1520)
* Fix boards listing * use arduio-cli sorting fix * re-use code to handle board list response * change `handleListBoards` visibility to `private` * pad menu items order with leading zeros to fix alphanumeric order
This commit is contained in:
committed by
GitHub
parent
e577de4e8e
commit
960a2d0634
@@ -32,6 +32,8 @@ import { CoreClientAware } from './core-client-provider';
|
||||
import {
|
||||
BoardDetailsRequest,
|
||||
BoardDetailsResponse,
|
||||
BoardListAllRequest,
|
||||
BoardListAllResponse,
|
||||
BoardSearchRequest,
|
||||
} from './cli-protocol/cc/arduino/cli/commands/v1/board_pb';
|
||||
import {
|
||||
@@ -199,8 +201,28 @@ export class BoardsServiceImpl
|
||||
const req = new BoardSearchRequest();
|
||||
req.setSearchArgs(query || '');
|
||||
req.setInstance(instance);
|
||||
return this.handleListBoards(client.boardSearch.bind(client), req);
|
||||
}
|
||||
|
||||
async getInstalledBoards(): Promise<BoardWithPackage[]> {
|
||||
const { instance, client } = await this.coreClient;
|
||||
const req = new BoardListAllRequest();
|
||||
req.setInstance(instance);
|
||||
return this.handleListBoards(client.boardListAll.bind(client), req);
|
||||
}
|
||||
|
||||
private async handleListBoards(
|
||||
getBoards: (
|
||||
request: BoardListAllRequest | BoardSearchRequest,
|
||||
callback: (
|
||||
error: ServiceError | null,
|
||||
response: BoardListAllResponse
|
||||
) => void
|
||||
) => void,
|
||||
request: BoardListAllRequest | BoardSearchRequest
|
||||
): Promise<BoardWithPackage[]> {
|
||||
const boards = await new Promise<BoardWithPackage[]>((resolve, reject) => {
|
||||
client.boardSearch(req, (error, resp) => {
|
||||
getBoards(request, (error, resp) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user