Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c0488d1

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
fix: remote sketch creation if tree is not active
Closes #1715 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 8119543 commit c0488d1

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

‎arduino-ide-extension/src/browser/contributions/new-cloud-sketch.ts‎

Lines changed: 6 additions & 5 deletions
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;

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

Lines changed: 18 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /