Ensure upgrade of a custom app re-runs the customiser (fix #160)

pull/173/head
Gordon Williams 2020-03-31 15:13:25 +01:00
parent e588f31257
commit f72bb986c9
1 changed files with 21 additions and 17 deletions

View File

@ -351,22 +351,9 @@ function refreshLibrary() {
});
} else if (icon.classList.contains("icon-menu")) {
// custom HTML update
if (app.custom) {
icon.classList.remove("icon-menu");
icon.classList.add("loading");
handleCustomApp(app).then((appJSON) => {
if (appJSON) appsInstalled.push(appJSON);
showToast(app.name+" Uploaded!", "success");
icon.classList.remove("loading");
icon.classList.add("icon-delete");
refreshMyApps();
refreshLibrary();
}).catch(err => {
showToast("Customise failed, "+err, "error");
icon.classList.remove("loading");
icon.classList.add("icon-menu");
});
}
icon.classList.remove("icon-menu");
icon.classList.add("loading");
customApp(app);
} else if (icon.classList.contains("icon-delete")) {
// Remove app
icon.classList.remove("icon-delete");
@ -401,9 +388,23 @@ function removeApp(app) {
});
}
function customApp(app) {
return handleCustomApp(app).then((appJSON) => {
if (appJSON) appsInstalled.push(appJSON);
showToast(app.name+" Uploaded!", "success");
refreshMyApps();
refreshLibrary();
}).catch(err => {
showToast("Customise failed, "+err, "error");
refreshMyApps();
refreshLibrary();
});
}
function updateApp(app) {
if (app.custom) return customApp(app);
showProgress(`Upgrading ${app.name}`,undefined,"sticky");
Comms.removeApp(app).then(()=>{
return Comms.removeApp(app).then(()=>{
showToast(app.name+" removed successfully. Updating...",);
appsInstalled = appsInstalled.filter(a=>a.id!=app.id);
return Comms.uploadApp(app);
@ -416,10 +417,13 @@ function updateApp(app) {
}, err=>{
hideProgress("sticky");
showToast(app.name+" update failed, "+err,"error");
refreshMyApps();
refreshLibrary();
});
}
function appNameToApp(appName) {
var app = appJSON.find(app=>app.id==appName);
if (app) return app;