Skip to content

Commit 1e72056

Browse files
author
Akos Kitta
committed
fix: remote sketch creation if view is not active
Closes #1715 Signed-off-by: Akos Kitta <[email protected]>
1 parent fe3fbb1 commit 1e72056

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

Diff for: arduino-ide-extension/src/browser/contributions/new-cloud-sketch.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,12 @@ export class NewCloudSketch extends Contribution {
202202
private treeModelFrom(
203203
widget: SketchbookWidget
204204
): CloudSketchbookTreeModel | undefined {
205-
const treeWidget = widget.getTreeWidget();
206-
if (treeWidget instanceof CloudSketchbookTreeWidget) {
207-
const model = treeWidget.model;
208-
if (model instanceof CloudSketchbookTreeModel) {
209-
return model;
205+
for (const treeWidget of widget.getTreeWidgets()) {
206+
if (treeWidget instanceof CloudSketchbookTreeWidget) {
207+
const model = treeWidget.model;
208+
if (model instanceof CloudSketchbookTreeModel) {
209+
return model;
210+
}
210211
}
211212
}
212213
return undefined;

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

+18
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,28 @@ export class SketchbookWidget extends BaseWidget {
5353
);
5454
}
5555

56+
/**
57+
* The currently selected sketchbook tree widget inside the view.
58+
*/
5659
getTreeWidget(): SketchbookTreeWidget {
5760
return this.sketchbookCompositeWidget.treeWidget;
5861
}
5962

63+
/**
64+
* An array of all sketchbook tree widgets managed by the view.
65+
*/
66+
getTreeWidgets(): SketchbookTreeWidget[] {
67+
return toArray(this.sketchbookTreesContainer.widgets()).reduce(
68+
(acc, curr) => {
69+
if (curr instanceof BaseSketchbookCompositeWidget) {
70+
acc.push(curr.treeWidget);
71+
}
72+
return acc;
73+
},
74+
[] as SketchbookTreeWidget[]
75+
);
76+
}
77+
6078
activeTreeWidgetId(): string | undefined {
6179
const selectedTreeWidgets = toArray(
6280
this.sketchbookTreesContainer.selectedWidgets()

0 commit comments

Comments
 (0)