diff --git a/webext/js/options_accounts.js b/webext/js/options_accounts.js index dc12a92..75d592a 100644 --- a/webext/js/options_accounts.js +++ b/webext/js/options_accounts.js @@ -65,7 +65,7 @@ SysTrayX.Accounts = { if (accounts[prop]) { let typeUl = document.createElement("ul"); - typeUl.setAttribute("class", "nested"); + typeUl.setAttribute("class", "nested active"); for (let i = 0; i < accounts[prop].length; ++i) { let typeLi = document.createElement("li"); diff --git a/webext/options.js b/webext/options.js index 720d584..f5744f7 100644 --- a/webext/options.js +++ b/webext/options.js @@ -13,17 +13,33 @@ function saveOptions(e) { }); /* - * Get accounts + * Save accounts and filters */ - console.debug("Store accounts"); + console.debug("Store accounts and filters"); let treeBase = document.getElementById("accountsTree"); let inputs = treeBase.querySelectorAll("input"); let accounts = []; + let filters = []; for (let i = 0; i < inputs.length; ++i) { let account = JSON.parse(inputs[i].value); - accounts.push({ ...account, checked: inputs[i].checked }); + let checked = inputs[i].checked; + accounts.push({ ...account, checked: checked }); + + if (checked) { + let inboxMailFolder = account.folders.find(obj => obj.type === "inbox"); + + if (inboxMailFolder) { + console.debug("Filter Id: " + inboxMailFolder.accountId); + console.debug("Filter Path: " + inboxMailFolder.path); + + filters.push({ + unread: true, + folder: inboxMailFolder + }); + } + } } // Store accounts @@ -31,7 +47,12 @@ function saveOptions(e) { accounts: accounts }); - console.debug("Store accounts done"); + // Store query filters + browser.storage.sync.set({ + filters: filters + }); + + console.debug("Store accounts and filters done"); } function restoreOptions() {