Brummolix/AutoarchiveReloaded

Heads-up: browser.accounts.list is changing

Closed this issue · 1 comments

Hi @Brummolix, in bug 1606584 we've (reluctantly) decided to change the list of folders in an account from a flat list to a hierarchy. As you're one of the very few people using this API, I thought I'd reach out.

You'll probably need to make a change to get a flat list back, but you can do it in a backwards-compatible way:

let arrayOfFolders = [];
function traverse(folders) {
  if (!folders) {
    return;
  }
  for (let f of folders) {
    arrayOfFolders.push(f);
    traverse(f.subFolders);
  }
}
browser.accounts.list().then(accounts => {
  for (let account of accounts) {
    traverse(account.folders);
  }
});

You can probably make it look a lot tidier in typeScript. I don't know typeScript or I'd send a PR.

Should be no problem to implement this once TB 74 beta is out.