1
0
Fork 0

Rewrite 'getInstalledApps' to minimize RAM usage

master
Gordon Williams 2020-04-15 13:58:05 +01:00
parent 40f291730e
commit a56a9792f1
2 changed files with 12 additions and 2 deletions

View File

@ -9,3 +9,4 @@ Changed for individual apps are listed in `apps/appname/ChangeLog`
* Fix issue removing an app that was just installed (fix #253)
* Add `Favourite` functionality
* Version number now clickable even when you're at the latest version (fix #291)
* Rewrite 'getInstalledApps' to minimize RAM usage

View File

@ -75,12 +75,21 @@ getInstalledApps : () => {
Progress.hide({sticky:true});
return reject("");
}
Puck.eval('require("Storage").list(/\.info$/).map(f=>{var j=require("Storage").readJSON(f,1)||{};j.id=f.slice(0,-5);return j})', (appList,err) => {
Puck.write('\x10Bluetooth.print("[");require("Storage").list(/\.info$/).forEach(f=>{var j=require("Storage").readJSON(f,1)||{};j.id=f.slice(0,-5);Bluetooth.print(JSON.stringify(j)+",")});Bluetooth.println("0]")\n', (appList,err) => {
Progress.hide({sticky:true});
try {
appList = JSON.parse(appList);
// remove last element since we added a final '0'
// to make things easy on the Bangle.js side
appList = appList.slice(0,-1);
} catch (e) {
appList = null;
err = e.toString();
}
if (appList===null) return reject(err || "");
console.log("getInstalledApps", appList);
resolve(appList);
});
}, true /* callback on newline */);
});
});
},