Skip to content

Commit

Permalink
chore: fix tests failures
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega committed Jan 5, 2023
1 parent 63f7929 commit 8cb14d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 11 additions & 8 deletions blocks/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,8 @@ const procedureDefMutator = {
if (node.nodeName.toLowerCase() !== 'arg') continue;
this.getProcedureModel().insertParameter(
new ObservableParameterModel(
this.workspace, node.getAttribute('name')),
this.workspace, node.getAttribute('name'),
node.getAttribute('varid')),
i);
}

Expand Down Expand Up @@ -645,11 +646,13 @@ const procedureDefMutator = {
* statements.
*/
loadExtraState: function(state) {
for (let i = 0; i < state['params'].length; i++) {
const param = state['params'][i];
this.getProcedureModel().insertParameter(
new ObservableParameterModel(this.workspace, param.name, param.id),
i);
if (state['params']) {
for (let i = 0; i < state['params'].length; i++) {
const param = state['params'][i];
this.getProcedureModel().insertParameter(
new ObservableParameterModel(this.workspace, param.name, param.id),
i);
}
}

// TODO: Remove this data update code.
Expand Down Expand Up @@ -815,8 +818,8 @@ Extensions.registerMixin(
const procedureDefOnChangeMixin = {
onchange: function(e) {
if (e.type === Events.BLOCK_CHANGE && e.blockId === this.id &&
e.element == 'disabled') {
this.model.setEnabled(!e.newValue);
e.element === 'disabled') {
this.getProcedureModel().setEnabled(!e.newValue);
}
},
};
Expand Down
4 changes: 2 additions & 2 deletions core/procedures/observable_parameter_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export class ObservableParameterModel implements IParameterModel {
constructor(
private readonly workspace: Workspace, name: string, id?: string) {
this.id = id ?? genUid();
this.variable =
this.workspace.getVariable(name) ?? workspace.createVariable(name);
this.variable = this.workspace.getVariable(name) ??
workspace.createVariable(name, '', id);
}

/**
Expand Down

0 comments on commit 8cb14d4

Please sign in to comment.