Store query filters

This commit is contained in:
Ximi1970
2020-01-12 01:15:19 +01:00
parent 778f400635
commit 46a1012d4c
2 changed files with 26 additions and 5 deletions

View File

@@ -65,7 +65,7 @@ SysTrayX.Accounts = {
if (accounts[prop]) { if (accounts[prop]) {
let typeUl = document.createElement("ul"); let typeUl = document.createElement("ul");
typeUl.setAttribute("class", "nested"); typeUl.setAttribute("class", "nested active");
for (let i = 0; i < accounts[prop].length; ++i) { for (let i = 0; i < accounts[prop].length; ++i) {
let typeLi = document.createElement("li"); let typeLi = document.createElement("li");

View File

@@ -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 treeBase = document.getElementById("accountsTree");
let inputs = treeBase.querySelectorAll("input"); let inputs = treeBase.querySelectorAll("input");
let accounts = []; let accounts = [];
let filters = [];
for (let i = 0; i < inputs.length; ++i) { for (let i = 0; i < inputs.length; ++i) {
let account = JSON.parse(inputs[i].value); 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 // Store accounts
@@ -31,7 +47,12 @@ function saveOptions(e) {
accounts: accounts 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() { function restoreOptions() {