Replace reference to deleted variable with specific variable info needed.

This commit is contained in:
Karishma Chadha 2018-11-21 11:45:16 -05:00 committed by GitHub
parent abbce00203
commit 63c4b53b09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -319,11 +319,13 @@ class Target extends EventEmitter {
*/ */
deleteVariable (id) { deleteVariable (id) {
if (this.variables.hasOwnProperty(id)) { if (this.variables.hasOwnProperty(id)) {
const variable = this.variables[id]; // Get info about the variable before deleting it
const deletedVariableName = this.variables[id].name;
const deletedVariableWasCloud = this.variables[id].isCloud;
delete this.variables[id]; delete this.variables[id];
if (this.runtime) { if (this.runtime) {
if (variable.isCloud && this.isStage) { if (deletedVariableWasCloud && this.isStage) {
this.runtime.ioDevices.cloud.requestDeleteVariable(variable.name); this.runtime.ioDevices.cloud.requestDeleteVariable(deletedVariableName);
} }
this.runtime.monitorBlocks.deleteBlock(id); this.runtime.monitorBlocks.deleteBlock(id);
this.runtime.requestRemoveMonitor(id); this.runtime.requestRemoveMonitor(id);