From f72bb986c93beb0a052aaefe3118a5c59f18c9e3 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 31 Mar 2020 15:13:25 +0100 Subject: [PATCH] Ensure upgrade of a custom app re-runs the customiser (fix #160) --- js/index.js | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/js/index.js b/js/index.js index bfdabc22f..b21fc907d 100644 --- a/js/index.js +++ b/js/index.js @@ -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;