mirror of https://github.com/espruino/BangleApps
Fix error in 'Install Default Apps' if Flash storage is full enough that erasing takes a while
parent
50a2df66d9
commit
57d89d3534
|
@ -21,3 +21,4 @@ Changed for individual apps are listed in `apps/appname/ChangeLog`
|
||||||
* Improve upload of binary files
|
* Improve upload of binary files
|
||||||
* App description can now be markdown
|
* App description can now be markdown
|
||||||
* Fix `marked is not defined` error (and include in repo, just in case)
|
* Fix `marked is not defined` error (and include in repo, just in case)
|
||||||
|
* Fix error in 'Install Default Apps' if Flash storage is full enough that erasing takes a while
|
||||||
|
|
24
js/comms.js
24
js/comms.js
|
@ -145,14 +145,28 @@ const Comms = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
removeAllApps : () => {
|
removeAllApps : () => {
|
||||||
|
console.log("<COMMS> removeAllApps start");
|
||||||
Progress.show({title:"Removing all apps",progess:"animate",sticky:true});
|
Progress.show({title:"Removing all apps",progess:"animate",sticky:true});
|
||||||
return new Promise((resolve,reject) => {
|
return new Promise((resolve,reject) => {
|
||||||
|
var timeout = 5;
|
||||||
|
function handleResult(result,err) {
|
||||||
|
console.log("<COMMS> removeAllApps: received "+JSON.stringify(result));
|
||||||
|
if (result=="" && (timeout--)) {
|
||||||
|
console.log("<COMMS> removeAllApps: no result - waiting some more ("+timeout+").");
|
||||||
|
// send space and delete - so it's something, but it should just cancel out
|
||||||
|
Puck.write(" \u0008", handleResult, true /* wait for newline */);
|
||||||
|
} else {
|
||||||
|
Progress.hide({sticky:true});
|
||||||
|
if (!result || result.trim()!="OK") {
|
||||||
|
if (!result) result = "No response";
|
||||||
|
else result = "Got "+JSON.stringify(result.trim());
|
||||||
|
return reject(err || result);
|
||||||
|
} else resolve();
|
||||||
|
}
|
||||||
|
}
|
||||||
// Use write with newline here so we wait for it to finish
|
// Use write with newline here so we wait for it to finish
|
||||||
Puck.write('\x10E.showMessage("Erasing...");require("Storage").eraseAll();Bluetooth.println("OK");reset()\n', (result,err) => {
|
var cmd = '\x10E.showMessage("Erasing...");require("Storage").eraseAll();Bluetooth.println("OK");reset()\n';
|
||||||
Progress.hide({sticky:true});
|
Puck.write(cmd, handleResult, true /* wait for newline */);
|
||||||
if (!result || result.trim()!="OK") return reject(err || "");
|
|
||||||
resolve();
|
|
||||||
}, true /* wait for newline */);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setTime : () => {
|
setTime : () => {
|
||||||
|
|
Loading…
Reference in New Issue