Skip to content

Commit 91860b8

Browse files
moves over Arduino libs based on types field
1 parent b980215 commit 91860b8

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

arduino-ide-extension/src/browser/library/library-list-widget.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,21 @@ export class LibraryListWidget extends ListWidget<
190190
);
191191
}
192192

193-
protected override filterableListSort(
193+
protected override filterableListSort = (
194194
items: LibraryPackage[]
195-
): LibraryPackage[] {
196-
const isArduinoMaintainedComparator = (
195+
): LibraryPackage[] => {
196+
const isArduinoTypeComparator = (
197197
left: LibraryPackage,
198198
right: LibraryPackage
199199
) => {
200-
if (left.isArduinoMaintained && !right.isArduinoMaintained) {
200+
const aIsArduinoType = left.types.includes('Arduino');
201+
const bIsArduinoType = right.types.includes('Arduino');
202+
203+
if (aIsArduinoType && !bIsArduinoType) {
201204
return -1;
202205
}
203206

204-
if (!left.isArduinoMaintained && right.isArduinoMaintained) {
207+
if (!aIsArduinoType && bIsArduinoType) {
205208
return 1;
206209
}
207210

@@ -210,11 +213,11 @@ export class LibraryListWidget extends ListWidget<
210213

211214
return items.sort((left, right) => {
212215
return (
213-
isArduinoMaintainedComparator(left, right) ||
216+
isArduinoTypeComparator(left, right) ||
214217
this.defaultSortComparator(left, right)
215218
);
216219
});
217-
}
220+
};
218221
}
219222

220223
class MessageBoxDialog extends AbstractDialog<MessageBoxDialog.Result> {

arduino-ide-extension/src/browser/widgets/component-list/list-widget.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ export abstract class ListWidget<
7474

7575
return itemLabel(left).localeCompare(itemLabel(right));
7676
};
77-
78-
this.filterableListSort = this.filterableListSort.bind(this);
7977
}
8078

8179
@postConstruct()
8280
protected init(): void {
8381
this.toDispose.pushAll([
84-
this.notificationCenter.onIndexUpdateDidComplete(() => this.refresh(undefined)),
82+
this.notificationCenter.onIndexUpdateDidComplete(() =>
83+
this.refresh(undefined)
84+
),
8585
this.notificationCenter.onDaemonDidStart(() => this.refresh(undefined)),
8686
this.notificationCenter.onDaemonDidStop(() => this.refresh(undefined)),
8787
]);
@@ -141,9 +141,9 @@ export abstract class ListWidget<
141141
return this.options.installable.uninstall({ item, progressId });
142142
}
143143

144-
protected filterableListSort(items: T[]): T[] {
144+
protected filterableListSort = (items: T[]): T[] => {
145145
return items.sort(this.defaultSortComparator);
146-
}
146+
};
147147

148148
render(): React.ReactNode {
149149
return (

arduino-ide-extension/src/common/protocol/arduino-component.ts

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export interface ArduinoComponent {
1010
readonly availableVersions: Installable.Version[];
1111
readonly installable: boolean;
1212
readonly installedVersion?: Installable.Version;
13-
readonly isArduinoMaintained?: boolean;
1413
/**
1514
* This is the `Type` in IDE (1.x) UI.
1615
*/

arduino-ide-extension/src/node/library-service-impl.ts

-1
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,5 @@ function toLibrary(
456456
summary: lib.getParagraph(),
457457
category: lib.getCategory(),
458458
types: lib.getTypesList(),
459-
isArduinoMaintained: lib.getAuthor() === 'Arduino', // TODO check if .getMaintainer is more appropriate
460459
};
461460
}

0 commit comments

Comments
 (0)