Skip to content

Commit 6b4e00d

Browse files
Akos KittaAlberto Iannaccone
authored andcommitted
minimized scope of hacky code.
Signed-off-by: Akos Kitta <[email protected]>
1 parent bd62680 commit 6b4e00d

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

arduino-ide-extension/src/browser/widgets/sketchbook/sketchbook-widget.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,19 @@ export class SketchbookWidget extends BaseWidget {
7373
console.warn(`Could not find tree widget with ID: ${widget}`);
7474
return;
7575
}
76-
const treeWidget = this.treeWidget(
76+
// TODO: remove this when the remote/local sketchbooks and their widgets are cleaned up.
77+
const findTreeWidget = (
78+
widget: Widget | undefined
79+
): TreeWidget | undefined => {
80+
if (widget instanceof TreeWidget) {
81+
return widget;
82+
}
83+
if (widget instanceof CloudSketchbookCompositeWidget) {
84+
return widget.getTreeWidget();
85+
}
86+
return undefined;
87+
};
88+
const treeWidget = findTreeWidget(
7789
toArray(this.sketchbookTreesContainer.widgets())
7890
.filter(({ id }) => id === treeWidgetId)
7991
.shift()
@@ -95,16 +107,6 @@ export class SketchbookWidget extends BaseWidget {
95107
treeWidget.model.selectNode(treeNode);
96108
}
97109

98-
private treeWidget(widget: Widget | undefined): TreeWidget | undefined {
99-
if (widget instanceof TreeWidget) {
100-
return widget;
101-
}
102-
if (widget instanceof CloudSketchbookCompositeWidget) {
103-
return widget.getTreeWidget();
104-
}
105-
return undefined;
106-
}
107-
108110
protected override onActivateRequest(message: Message): void {
109111
super.onActivateRequest(message);
110112

0 commit comments

Comments
 (0)