Ensure we run transfers one after the other rather that potentially having them overlap if the user clicks around https://github.com/espruino/EspruinoAppLoaderCore/issues/67
parent
9d84683505
commit
700a9f9f4a
10
backup.js
10
backup.js
|
|
@ -7,7 +7,7 @@ function bangleDownload() {
|
|||
Progress.show({title:"Scanning...",sticky:true});
|
||||
var normalFiles, storageFiles;
|
||||
console.log("Listing normal files...");
|
||||
Comms.reset()
|
||||
return Comms.reset()
|
||||
.then(() => Comms.showMessage("Backing up..."))
|
||||
.then(() => Comms.listFiles({sf:false}))
|
||||
.then(f => {
|
||||
|
|
@ -66,6 +66,7 @@ function bangleDownload() {
|
|||
}
|
||||
|
||||
function bangleUpload() {
|
||||
return new Promise(resolve =>
|
||||
Espruino.Core.Utils.fileOpenDialog({
|
||||
id:"backup",
|
||||
type:"arraybuffer",
|
||||
|
|
@ -116,20 +117,23 @@ function bangleUpload() {
|
|||
.then(() => {
|
||||
Progress.hide({sticky:true});
|
||||
showToast('Restore complete!', 'success');
|
||||
resolve();
|
||||
})
|
||||
.catch(err => {
|
||||
Progress.hide({sticky:true});
|
||||
showToast('Restore failed, ' + err, 'error');
|
||||
resolve();
|
||||
});
|
||||
return promise;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('load', (event) => {
|
||||
document.getElementById("downloadallapps").addEventListener("click",event=>{
|
||||
bangleDownload();
|
||||
startOperation({name:"Backup Apps"}, () => bangleDownload);
|
||||
});
|
||||
document.getElementById("uploadallapps").addEventListener("click",event=>{
|
||||
bangleUpload();
|
||||
startOperation({name:"Restore Apps"}, () => bangleUpload);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
2
core
2
core
|
|
@ -1 +1 @@
|
|||
Subproject commit ef99424a9fbd01be504841a6c759ba4292a542f7
|
||||
Subproject commit 7e7475ba3ab253099481a81e487aaacb9384f974
|
||||
13
loader.js
13
loader.js
|
|
@ -212,7 +212,7 @@ window.addEventListener('load', (event) => {
|
|||
el = document.getElementById("reinstallall");
|
||||
if (el) el.addEventListener("click",event=>{
|
||||
var promise = showPrompt("Reinstall","Really re-install all apps?").then(() => {
|
||||
Comms.reset().then(_ =>
|
||||
startOperation({name:"Reinstall All Apps"}, () => Comms.reset().then(_ =>
|
||||
getInstalledApps()
|
||||
).then(installedapps => {
|
||||
console.log(installedapps);
|
||||
|
|
@ -232,14 +232,14 @@ window.addEventListener('load', (event) => {
|
|||
).catch(err=>{
|
||||
Progress.hide({sticky:true});
|
||||
showToast("App re-install failed, "+err,"error");
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
// Button to install all default apps in one go
|
||||
el = document.getElementById("installdefault");
|
||||
if (el) el.addEventListener("click", event=>{
|
||||
getInstalledApps().then(() => {
|
||||
startOperation({name:"Install Default Apps"}, () => getInstalledApps().then(() => {
|
||||
if (device.id == "BANGLEJS")
|
||||
return httpGet("defaultapps_banglejs1.json");
|
||||
if (device.id == "BANGLEJS2")
|
||||
|
|
@ -250,15 +250,16 @@ window.addEventListener('load', (event) => {
|
|||
}).catch(err=>{
|
||||
Progress.hide({sticky:true});
|
||||
showToast("App Install failed, "+err,"error");
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
// Button to reset the Bangle's settings
|
||||
el = document.getElementById("defaultbanglesettings");
|
||||
if (el) el.addEventListener("click", event=>{
|
||||
showPrompt("Reset Settings","Really reset Bangle.js settings?").then(() => {
|
||||
Comms.write("\x10require('Storage').erase('setting.json');load()\n");
|
||||
showToast("Settings reset!", "success");
|
||||
startOperation({name:"Reset Settings"}, () =>
|
||||
Comms.write("\x10require('Storage').erase('setting.json');load()\n").then(() =>
|
||||
showToast("Settings reset!", "success")));
|
||||
}, function() { /* cancelled */ });
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue