Commit 51cafd67 authored by Evan W. Patton's avatar Evan W. Patton

Reduce number of companion updates

Opening and closing a mutator or clicking a block would result in the
blocks code being resent to the companion because any workspace event
would force a YAIL update. This change adds a isUi method to check
whether a Blockly event is a UI event, which doesn't change the
semantics of the program, and ignores such events for the purpose of
updating the companion.

Change-Id: Id80d1d094e585cc7182fe3987f8e0adc2b45b872
parent bd9758c1
...@@ -296,7 +296,9 @@ public final class YaBlocksEditor extends FileEditor ...@@ -296,7 +296,9 @@ public final class YaBlocksEditor extends FileEditor
if (!EventHelper.isTransient(event)) { if (!EventHelper.isTransient(event)) {
Ode.getInstance().getEditorManager().scheduleAutoSave(this); Ode.getInstance().getEditorManager().scheduleAutoSave(this);
} }
sendComponentData(); if (!EventHelper.isUi(event)) {
sendComponentData();
}
} }
@Override @Override
......
...@@ -13,7 +13,7 @@ public final class EventHelper { ...@@ -13,7 +13,7 @@ public final class EventHelper {
} }
/** /**
* Determine whether an event from the native JavaScript (e.g., Blockly). * Determine whether an event from the native JavaScript (e.g., Blockly) is transient.
* *
* @param event Native JavaScript event * @param event Native JavaScript event
* @return true if the event can be determined to be transient, otherwise false. * @return true if the event can be determined to be transient, otherwise false.
...@@ -33,4 +33,14 @@ public final class EventHelper { ...@@ -33,4 +33,14 @@ public final class EventHelper {
} }
return false; return false;
}-*/; }-*/;
/**
* Determine whether an event from the native JavaScript (e.g., Blockly) is a UI event.
*
* @param event Native JavaScript event
* @return true if the event can be determined to be user interface event, otherwise false.
*/
public static native boolean isUi(JavaScriptObject event)/*-{
return event && event.type === 'ui';
}-*/;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment