Commit 9ae9b122 authored by Evan W. Patton's avatar Evan W. Patton Committed by Jeffrey Schiller

Send code after asset refresh, not before (#1959)

If someone changes the image of a button by using the upload file
feature, we will send the code with the new image property before the
asset is sent to the device. This results in the button not getting
the appropriate image. This change moves the operation to build the
YAIL into the callback of refreshAssets. It also makes sure that the
callback is called regardless of whether there are new assets to be
sent so that YAIL generation doesn't break in the absense of assets.

Change-Id: I14520d8a7945902aa4a9b345d3f9d164a3a9448e
parent d172490d
...@@ -222,8 +222,10 @@ public final class AssetManager implements ProjectChangeListener { ...@@ -222,8 +222,10 @@ public final class AssetManager implements ProjectChangeListener {
} }
private void refreshAssets1() { private void refreshAssets1() {
boolean loadInProgress = false;
for (AssetInfo a : assets.values()) { for (AssetInfo a : assets.values()) {
if (!a.loaded) { if (!a.loaded) {
loadInProgress = true;
if (a.fileContent == null && !useWebRTC()) { // Need to fetch it from the server if (a.fileContent == null && !useWebRTC()) { // Need to fetch it from the server
retryCount = 3; retryCount = 3;
ConnectProgressBar.setProgress(100 * assetTransferProgress / (2 * assets.size()), ConnectProgressBar.setProgress(100 * assetTransferProgress / (2 * assets.size()),
...@@ -244,7 +246,7 @@ public final class AssetManager implements ProjectChangeListener { ...@@ -244,7 +246,7 @@ public final class AssetManager implements ProjectChangeListener {
} }
// If no assets are in the project, close the Progress Bar and // If no assets are in the project, close the Progress Bar and
// perform the callback immediately. // perform the callback immediately.
if (assets.values().size() == 0) { if (assets.values().size() == 0 || !loadInProgress) {
ConnectProgressBar.hide(); ConnectProgressBar.hide();
if (assetsTransferredCallback != null) { if (assetsTransferredCallback != null) {
doCallBack(assetsTransferredCallback); doCallBack(assetsTransferredCallback);
......
...@@ -269,11 +269,13 @@ Blockly.ReplMgr.pollYail = function(workspace, opt_force) { ...@@ -269,11 +269,13 @@ Blockly.ReplMgr.pollYail = function(workspace, opt_force) {
} catch (err) { // We get an error on FireFox when window is gone. } catch (err) { // We get an error on FireFox when window is gone.
return; return;
} }
var self = this;
if (top.ReplState.state == this.rsState.CONNECTED) { if (top.ReplState.state == this.rsState.CONNECTED) {
this.buildYail(workspace, opt_force); RefreshAssets(function() {
} if (top.ReplState.state == self.rsState.CONNECTED) {
if (top.ReplState.state == this.rsState.CONNECTED) { self.buildYail(workspace, opt_force);
RefreshAssets(function() {}); }
});
} }
}; };
......
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