Clean up optRuntime checks in blocklyListen

This commit is contained in:
Karishma Chadha 2018-06-05 15:13:03 -04:00
parent 2171cb69d0
commit d58bb8bcfb

View file

@ -358,14 +358,14 @@ class Blocks {
stage.deleteVariable(e.varId); stage.deleteVariable(e.varId);
break; break;
case 'comment_create': case 'comment_create':
if (optRuntime.getEditingTarget()) { if (optRuntime && optRuntime.getEditingTarget()) {
const currTarget = optRuntime.getEditingTarget(); const currTarget = optRuntime.getEditingTarget();
currTarget.createComment(e.commentId, e.blockId, e.text, currTarget.createComment(e.commentId, e.blockId, e.text,
e.xy.x, e.xy.y, e.width, e.height, e.minimized); e.xy.x, e.xy.y, e.width, e.height, e.minimized);
} }
break; break;
case 'comment_change': case 'comment_change':
if (optRuntime) { if (optRuntime && optRuntime.getEditingTarget()) {
const currTarget = optRuntime.getEditingTarget(); const currTarget = optRuntime.getEditingTarget();
if (!currTarget.comments.hasOwnProperty(e.commentId)) { if (!currTarget.comments.hasOwnProperty(e.commentId)) {
log.warn(`Cannot change comment with id ${e.commentId} because it does not exist.`); log.warn(`Cannot change comment with id ${e.commentId} because it does not exist.`);
@ -392,9 +392,9 @@ class Blocks {
} }
break; break;
case 'comment_move': case 'comment_move':
if (optRuntime) { if (optRuntime && optRuntime.getEditingTarget()) {
const currTarget = optRuntime.getEditingTarget(); const currTarget = optRuntime.getEditingTarget();
if (!currTarget.comments.hasOwnProperty(e.commentId)) { if (currTarget && !currTarget.comments.hasOwnProperty(e.commentId)) {
log.warn(`Cannot change comment with id ${e.commentId} because it does not exist.`); log.warn(`Cannot change comment with id ${e.commentId} because it does not exist.`);
return; return;
} }
@ -405,7 +405,7 @@ class Blocks {
} }
break; break;
case 'comment_delete': case 'comment_delete':
if (optRuntime) { if (optRuntime && optRuntime.getEditingTarget()) {
const currTarget = optRuntime.getEditingTarget(); const currTarget = optRuntime.getEditingTarget();
if (!currTarget.comments.hasOwnProperty(e.commentId)) { if (!currTarget.comments.hasOwnProperty(e.commentId)) {
// If we're in this state, we have probably received // If we're in this state, we have probably received