mirror of https://github.com/espruino/BangleApps
Rewrite 'getInstalledApps' to minimize RAM usage
parent
40f291730e
commit
a56a9792f1
|
@ -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
|
||||
|
|
13
js/comms.js
13
js/comms.js
|
@ -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 */);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue