files: Tweaks to help with memory usage

master
Gordon Williams 2020-05-11 11:20:50 +01:00
parent 20892da27a
commit 2e709b4f83
3 changed files with 21 additions and 28 deletions

View File

@ -372,7 +372,7 @@
{ "id": "files", { "id": "files",
"name": "App Manager", "name": "App Manager",
"icon": "files.png", "icon": "files.png",
"version":"0.03", "version":"0.05",
"description": "Show currently installed apps, free space, and allow their deletion from the watch", "description": "Show currently installed apps, free space, and allow their deletion from the watch",
"tags": "tool,system,files", "tags": "tool,system,files",
"storage": [ "storage": [

View File

@ -1,3 +1,4 @@
0.02: Fix deletion of apps - now use files list in app.info (fix #262) 0.02: Fix deletion of apps - now use files list in app.info (fix #262)
0.03: Add support for data files 0.03: Add support for data files
0.04: Add functionality to sort apps manually or alphabetically ascending/descending. 0.04: Add functionality to sort apps manually or alphabetically ascending/descending.
0.05: Tweaks to help with memory usage

View File

@ -2,8 +2,6 @@ const store = require('Storage');
const boolFormat = (v) => v ? "On" : "Off"; const boolFormat = (v) => v ? "On" : "Off";
let m;
function showMainMenu() { function showMainMenu() {
const mainmenu = { const mainmenu = {
'': { '': {
@ -22,13 +20,13 @@ function showMainMenu() {
store.compact(); store.compact();
} catch (e) { } catch (e) {
} }
m = showMainMenu(); showMainMenu();
}, },
'Apps': ()=> m = showApps(), 'Apps': ()=> showApps(),
'Sort Apps': () => m = showSortAppsMenu(), 'Sort Apps': () => showSortAppsMenu(),
'< Back': ()=> {load();} '< Back': ()=> {load();}
}; };
return E.showMenu(mainmenu); E.showMenu(mainmenu);
} }
function isGlob(f) { function isGlob(f) {
@ -100,7 +98,7 @@ function showAppMenu(app) {
'': { '': {
'title': app.name, 'title': app.name,
}, },
'< Back': () => m = showApps(), '< Back': () => showApps(),
}; };
if (app.data) { if (app.data) {
appmenu['Erase Completely'] = () => eraseOne(app, true, true); appmenu['Erase Completely'] = () => eraseOne(app, true, true);
@ -109,7 +107,7 @@ function showAppMenu(app) {
} else { } else {
appmenu['Erase'] = () => eraseOne(app, true, false); appmenu['Erase'] = () => eraseOne(app, true, false);
} }
return E.showMenu(appmenu); E.showMenu(appmenu);
} }
function showApps() { function showApps() {
@ -117,7 +115,7 @@ function showApps() {
'': { '': {
'title': 'Apps', 'title': 'Apps',
}, },
'< Back': () => m = showMainMenu(), '< Back': () => showMainMenu(),
}; };
var list = store.list(/\.info$/).filter((a)=> { var list = store.list(/\.info$/).filter((a)=> {
@ -130,7 +128,7 @@ function showApps() {
if (list.length > 0) { if (list.length > 0) {
list.reduce((menu, app) => { list.reduce((menu, app) => {
menu[app.name] = () => m = showAppMenu(app); menu[app.name] = () => showAppMenu(app);
return menu; return menu;
}, appsmenu); }, appsmenu);
appsmenu['Erase All'] = () => { appsmenu['Erase All'] = () => {
@ -149,7 +147,7 @@ function showApps() {
onchange: ()=> {} onchange: ()=> {}
}; };
} }
return E.showMenu(appsmenu); E.showMenu(appsmenu);
} }
function showSortAppsMenu() { function showSortAppsMenu() {
@ -157,24 +155,18 @@ function showSortAppsMenu() {
'': { '': {
'title': 'App Sorter', 'title': 'App Sorter',
}, },
'< Back': () => m = showMainMenu(), '< Back': () => showMainMenu(),
'Sort: manually': ()=> m = showSortAppsManually(), 'Sort: manually': ()=> showSortAppsManually(),
'Sort: alph. ASC': () => { 'Sort: alph. ASC': () => {
E.showMessage('Sorting:\nAlphabetically\nascending ...'); E.showMessage('Sorting:\nAlphabetically\nascending ...');
try { sortAlphabet(false);
sortAlphabet(false);
} catch (e) {
}
}, },
'Sort: alph. DESC': () => { 'Sort: alph. DESC': () => {
E.showMessage('Sorting:\nAlphabetically\ndescending ...'); E.showMessage('Sorting:\nAlphabetically\ndescending ...');
try { sortAlphabet(true);
sortAlphabet(true);
} catch (e) {
}
} }
}; };
return E.showMenu(sorterMenu); E.showMenu(sorterMenu);
} }
function showSortAppsManually() { function showSortAppsManually() {
@ -182,7 +174,7 @@ function showSortAppsManually() {
'': { '': {
'title': 'Sort: manually', 'title': 'Sort: manually',
}, },
'< Back': () => m = showSortAppsMenu(), '< Back': () => showSortAppsMenu(),
}; };
let appList = getAppsList(); let appList = getAppsList();
if (appList.length > 0) { if (appList.length > 0) {
@ -203,7 +195,7 @@ function showSortAppsManually() {
onchange: ()=> {} onchange: ()=> {}
}; };
} }
return E.showMenu(appsSorterMenu); E.showMenu(appsSorterMenu);
} }
function setSortorder(app, val) { function setSortorder(app, val) {
@ -226,11 +218,11 @@ function sortAlphabet(desc) {
appsSorted.forEach((a, i) => { appsSorted.forEach((a, i) => {
setSortorder(a, i); setSortorder(a, i);
}); });
return showSortAppsMenu(); showSortAppsMenu();
} }
function sortHelper() { function sortHelper() {
return (a, b) => (a.name > b.name) - (a.name < b.name); return (a, b) => (a.name > b.name) - (a.name < b.name);
} }
m = showMainMenu(); showMainMenu();