Skip to content

fix: remote sketch creation if tree is not active #1717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,12 @@ export class NewCloudSketch extends Contribution {
private treeModelFrom(
widget: SketchbookWidget
): CloudSketchbookTreeModel | undefined {
const treeWidget = widget.getTreeWidget();
if (treeWidget instanceof CloudSketchbookTreeWidget) {
const model = treeWidget.model;
if (model instanceof CloudSketchbookTreeModel) {
return model;
for (const treeWidget of widget.getTreeWidgets()) {
if (treeWidget instanceof CloudSketchbookTreeWidget) {
const model = treeWidget.model;
if (model instanceof CloudSketchbookTreeModel) {
return model;
}
}
}
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,28 @@ export class SketchbookWidget extends BaseWidget {
);
}

/**
* The currently selected sketchbook tree widget inside the view.
*/
getTreeWidget(): SketchbookTreeWidget {
return this.sketchbookCompositeWidget.treeWidget;
}

/**
* An array of all sketchbook tree widgets managed by the view.
*/
getTreeWidgets(): SketchbookTreeWidget[] {
return toArray(this.sketchbookTreesContainer.widgets()).reduce(
(acc, curr) => {
if (curr instanceof BaseSketchbookCompositeWidget) {
acc.push(curr.treeWidget);
}
return acc;
},
[] as SketchbookTreeWidget[]
);
}

activeTreeWidgetId(): string | undefined {
const selectedTreeWidgets = toArray(
this.sketchbookTreesContainer.selectedWidgets()
Expand Down