Remove "settings" from appid.info

pull/312/head
Richard de Boer 2020-04-17 21:08:07 +02:00
parent 745e4d38a9
commit c7f2a18caa
4 changed files with 16 additions and 11 deletions

View File

@ -120,7 +120,7 @@
{ "id": "setting", { "id": "setting",
"name": "Settings", "name": "Settings",
"icon": "settings.png", "icon": "settings.png",
"version":"0.16", "version":"0.17",
"description": "A menu for setting up Bangle.js", "description": "A menu for setting up Bangle.js",
"tags": "tool,system", "tags": "tool,system",
"storage": [ "storage": [

View File

@ -18,3 +18,4 @@
0.14: Reduce memory usage when running app settings page 0.14: Reduce memory usage when running app settings page
0.15: Reduce memory usage when running default clock chooser (#294) 0.15: Reduce memory usage when running default clock chooser (#294)
0.16: Reduce memory usage further when running app settings page 0.16: Reduce memory usage further when running app settings page
0.17: Remove need for "settings" in appid.info

View File

@ -416,10 +416,19 @@ function showAppSettingsMenu() {
'': { 'title': 'App Settings' }, '': { 'title': 'App Settings' },
'< Back': ()=>showMainMenu(), '< Back': ()=>showMainMenu(),
} }
const apps = storage.list(/\.info$/) const apps = storage.list(/\.settings\.js$/)
.map(app => {var a=storage.readJSON(app, 1);return (a&&a.settings)?{sortorder:a.sortorder,name:a.name,settings:a.settings}:undefined}) .map(s => s.substr(0, s.length-12))
.filter(app => app) // filter out any undefined apps .map(id => {
.sort((a, b) => a.sortorder - b.sortorder) const a=storage.readJSON(id+'.info',1);
return {id:id,name:a.name,sortorder:a.sortorder};
})
.sort((a, b) => {
const n = (0|a.sortorder)-(0|b.sortorder);
if (n) return n; // do sortorder first
if (a.name<b.name) return -1;
if (a.name>b.name) return 1;
return 0;
})
if (apps.length === 0) { if (apps.length === 0) {
appmenu['No app has settings'] = () => { }; appmenu['No app has settings'] = () => { };
} }
@ -433,10 +442,7 @@ function showAppSettings(app) {
E.showMessage(`${app.name}:\n${msg}!\n\nBTN1 to go back`); E.showMessage(`${app.name}:\n${msg}!\n\nBTN1 to go back`);
setWatch(showAppSettingsMenu, BTN1, { repeat: false }); setWatch(showAppSettingsMenu, BTN1, { repeat: false });
} }
let appSettings = storage.read(app.settings); let appSettings = storage.read(app.id+'.settings.js');
if (!appSettings) {
return showError('Missing settings');
}
try { try {
appSettings = eval(appSettings); appSettings = eval(appSettings);
} catch (e) { } catch (e) {

View File

@ -60,8 +60,6 @@ var AppInfo = {
if (app.type && app.type!="app") json.type = app.type; if (app.type && app.type!="app") json.type = app.type;
if (fileContents.find(f=>f.name==app.id+".app.js")) if (fileContents.find(f=>f.name==app.id+".app.js"))
json.src = app.id+".app.js"; json.src = app.id+".app.js";
if (fileContents.find(f=>f.name==app.id+".settings.js"))
json.settings = app.id+".settings.js";
if (fileContents.find(f=>f.name==app.id+".img")) if (fileContents.find(f=>f.name==app.id+".img"))
json.icon = app.id+".img"; json.icon = app.id+".img";
if (app.sortorder) json.sortorder = app.sortorder; if (app.sortorder) json.sortorder = app.sortorder;