How can I read tags of an app?

Posted on
  • So I was trying to sort apps into groups based on their tag, but when I try to get the tag by writing it to the launchCache it returns undefined when I try and use it. The other properties seem to work, so I'm not sure why the tags don't. I checked the .info files on my Bangle and they all have the tags property.

    
      let s = require("Storage");
      
      let launchCache = s.readJSON("launch.cache.json", true) || {};
      let launchHash = require("Storage").hash(/\.info/);
      if (launchCache.hash != launchHash) {
        launchCache = {
          hash: launchHash,
          apps: s.list(/\.info$/)
            .map(app => { var a = s.readJSON(app, 1); return a && { name: a.name, type: a.type, icon: a.icon, sortorder: a.sortorder, src: a.src, tags: a.tags}; }) // added tags: a.tags
            .filter(app => app && (app.type == "app" || (app.type == "clock" && settings.showClocks) || !app.type))
            .sort((a, b) => {
              var n = (0 | a.sortorder) - (0 | b.sortorder);
              if (n) return n; 
              if (a.name < b.name) return -1;
              if (a.name > b.name) return 1;
              return 0;
            })
        };
        s.writeJSON("launch.cache.json", launchCache);
      }
      let apps = launchCache.apps;
      apps.forEach(app => {
        if (app.icon)
          {app.icon = s.read(app.icon);}
          console.log(app.tags)//returns undefined
    
      });
    
  • When I run your code I get the error Uncaught ReferenceError: "settings" is not defined and I get undefined shown.

    If I just add let settings = {}; before your code and run it, it prints out all the tags:

    tool,system
    tool,system
    tool,alarm
    outdoors,exercise,ble,bluetooth,bike,cycle,bicycle
    tool,system,health
    

    Could that be it?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

How can I read tags of an app?

Posted by Avatar for ungoosed @ungoosed

Actions