Skip to content

Commit 3ec8e28

Browse files
committed
handle 'defaultconfig' app type for default configurations
1 parent bf08b48 commit 3ec8e28

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

js/appinfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ var AppInfo = {
253253
// filter out empty files
254254
fileContents = fileContents.filter(x=>x!==undefined);
255255
// if it's a 'ram' app, don't add any app JSON file
256-
if (app.type=="RAM") return fileContents;
256+
if (app.type=="RAM" || app.type=="defaultconfig") return fileContents;
257257
// Add app's info JSON
258258
return AppInfo.createAppJSON(app, fileContents);
259259
}).then(fileContents => {

js/comms.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ const Comms = {
158158
let appInfo = undefined;
159159
if (appInfoFile)
160160
appInfo = JSON.parse(appInfoFile.content);
161-
else if (app.type!="RAM")
161+
else if (app.type!="RAM" && app.type!="defaultconfig")
162162
reject(`${appInfoFileName} not found`);
163163

164164
// Upload each file one at a time

js/index.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -759,12 +759,25 @@ function showScreenshots(appId) {
759759

760760
// =========================================== My Apps
761761

762-
function uploadApp(app) {
762+
function uploadApp(app, options) {
763+
options = options||{};
764+
if (app.type == "defaultconfig" && !options.force) {
765+
return showPrompt("Default Configuration Install","<b>This will remove all apps and data from your Bangle</b> and will install a new set of apps. Please ensure you have backed up your Bangle first. Continue?",{yes:1,no:1},false)
766+
.then(() => showPrompt("Device Erasure","<b>Everything will be deleted from your Bangle.</b> Are you really sure?",{yes:1,no:1},false))
767+
.then(() => Comms.removeAllApps())
768+
.then(() => uploadApp(app, {force:true}))
769+
.catch(err => {
770+
showToast("Configuration install failed, "+err,"error");
771+
refreshMyApps();
772+
refreshLibrary();
773+
});
774+
}
775+
763776
return getInstalledApps().then(()=>{
764777
if (device.appsInstalled.some(i => i.id === app.id)) {
765778
return updateApp(app);
766779
}
767-
checkDependencies(app)
780+
return checkDependencies(app)
768781
.then(()=>Comms.uploadApp(app,{device:device, language:LANGUAGE}))
769782
.then((appJSON) => {
770783
Progress.hide({ sticky: true });
@@ -780,7 +793,7 @@ function uploadApp(app) {
780793
refreshLibrary();
781794
});
782795
}).catch(err => {
783-
showToast("Device connection failed, "+err,"error");
796+
showToast("App Upload failed, "+err,"error");
784797
// remove loading indicator
785798
refreshMyApps();
786799
refreshLibrary();

js/ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function showToast(message, type, timeout) {
9898
}, timeout || 5000);
9999
}
100100

101-
/// Show a yes/no prompt
101+
/// Show a yes/no prompt. resolve for true, reject for false
102102
function showPrompt(title, text, buttons, shouldEscapeHtml) {
103103
if (!buttons) buttons={yes:1,no:1};
104104
if (typeof(shouldEscapeHtml) === 'undefined' || shouldEscapeHtml === null) shouldEscapeHtml = true;

0 commit comments

Comments
 (0)