Skip to content

Commit

Permalink
handle 'defaultconfig' app type for default configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Feb 4, 2025
1 parent bf08b48 commit 3ec8e28
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/appinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ var AppInfo = {
// filter out empty files
fileContents = fileContents.filter(x=>x!==undefined);
// if it's a 'ram' app, don't add any app JSON file
if (app.type=="RAM") return fileContents;
if (app.type=="RAM" || app.type=="defaultconfig") return fileContents;
// Add app's info JSON
return AppInfo.createAppJSON(app, fileContents);
}).then(fileContents => {
Expand Down
2 changes: 1 addition & 1 deletion js/comms.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const Comms = {
let appInfo = undefined;
if (appInfoFile)
appInfo = JSON.parse(appInfoFile.content);
else if (app.type!="RAM")
else if (app.type!="RAM" && app.type!="defaultconfig")
reject(`${appInfoFileName} not found`);

// Upload each file one at a time
Expand Down
19 changes: 16 additions & 3 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,12 +759,25 @@ function showScreenshots(appId) {

// =========================================== My Apps

function uploadApp(app) {
function uploadApp(app, options) {
options = options||{};
if (app.type == "defaultconfig" && !options.force) {
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)
.then(() => showPrompt("Device Erasure","<b>Everything will be deleted from your Bangle.</b> Are you really sure?",{yes:1,no:1},false))
.then(() => Comms.removeAllApps())
.then(() => uploadApp(app, {force:true}))
.catch(err => {
showToast("Configuration install failed, "+err,"error");
refreshMyApps();
refreshLibrary();
});
}

return getInstalledApps().then(()=>{
if (device.appsInstalled.some(i => i.id === app.id)) {
return updateApp(app);
}
checkDependencies(app)
return checkDependencies(app)
.then(()=>Comms.uploadApp(app,{device:device, language:LANGUAGE}))
.then((appJSON) => {
Progress.hide({ sticky: true });
Expand All @@ -780,7 +793,7 @@ function uploadApp(app) {
refreshLibrary();
});
}).catch(err => {
showToast("Device connection failed, "+err,"error");
showToast("App Upload failed, "+err,"error");
// remove loading indicator
refreshMyApps();
refreshLibrary();
Expand Down
2 changes: 1 addition & 1 deletion js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function showToast(message, type, timeout) {
}, timeout || 5000);
}

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

0 comments on commit 3ec8e28

Please sign in to comment.