Fixed more merging issues.

This commit is contained in:
Ajay Ramachandran
2020-01-09 19:23:05 -05:00
parent d705610855
commit d2e1373e2a

View File

@@ -41,7 +41,7 @@ async function init() {
// Add click listener // Add click listener
checkbox.addEventListener("click", () => { checkbox.addEventListener("click", () => {
setOptionValue(option, reverse ? !checkbox.checked : checkbox.checked); SB.config[option] = reverse ? !checkbox.checked : checkbox.checked;
// See if anything extra must be run // See if anything extra must be run
switch (option) { switch (option) {
@@ -83,7 +83,7 @@ function invidiousInit(checkbox, option) {
permissions: permissions permissions: permissions
}, function (result) { }, function (result) {
if (result != checkbox.checked) { if (result != checkbox.checked) {
setOptionValue(option, result); SB.config[option] = result;
checkbox.checked = result; checkbox.checked = result;
} }
@@ -162,7 +162,7 @@ function invidiousOnClick(checkbox, option) {
}); });
} }
} else { } else {
setOptionValue(option, false); SB.config[option] = false;
checkbox.checked = false; checkbox.checked = false;
chrome.declarativeContent.onPageChanged.removeRules(["invidious"]); chrome.declarativeContent.onPageChanged.removeRules(["invidious"]);
@@ -262,17 +262,11 @@ function activateTextChange(element) {
// Add this // Add this
//TODO Make the call to invidiousOnClick support passing the straight extra values, plus make the get not needed //TODO Make the call to invidiousOnClick support passing the straight extra values, plus make the get not needed
//OR merge the config PR and use that //OR merge the config PR and use that
let result = await new Promise((resolve, reject) => { if (!SB.config[option]) SB.config[option] = [];
chrome.storage.sync.get([option], resolve);
});
if (!result[option]) result[option] = []; SB.config[option].push(textBox.value);
result[option].push(textBox.value); SB.config[option] = SB.config[option];
await new Promise((resolve, reject) => {
setOptionValue(option, result[option], resolve);
});
let checkbox = document.querySelector("#support-invidious input"); let checkbox = document.querySelector("#support-invidious input");
checkbox.checked = true; checkbox.checked = true;
@@ -290,7 +284,7 @@ function activateTextChange(element) {
let resetButton = element.querySelector(".invidious-instance-reset"); let resetButton = element.querySelector(".invidious-instance-reset");
resetButton.addEventListener("click", function(e) { resetButton.addEventListener("click", function(e) {
if (confirm(chrome.i18n.getMessage("resetInvidiousInstanceAlert"))) { if (confirm(chrome.i18n.getMessage("resetInvidiousInstanceAlert"))) {
setOptionValue(option, []); SB.config[option] = [];
} }
}); });