Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: js/desktop-options.js

Issue 29730617: Issue 6510 - Configure notification opens options page incorrectly (Closed)
Patch Set: Created March 22, 2018, 3:27 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« css/desktop-options.scss ('K') | « css/desktop-options.scss ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: js/desktop-options.js
===================================================================
--- a/js/desktop-options.js
+++ b/js/desktop-options.js
@@ -1348,21 +1348,26 @@
{
return browser.runtime.sendMessage({
type: "filters.get",
subscriptionUrl: subscription.url});
}
function hidePref(key, value)
{
- let element = document.querySelector("[data-pref='" + key + "']");
+ let element = getPrefElement(key);
a.giammarchi 2018/03/22 18:43:28 let is OK, but why not `const` here ?
saroyanm 2018/03/22 20:43:21 Done.
if (element)
element.setAttribute("aria-hidden", value);
}
+function getPrefElement(key)
+{
+ return document.querySelector("[data-pref='" + key + "']");
a.giammarchi 2018/03/22 18:43:28 out of curiosity: are keys always sanitized or som
saroyanm 2018/03/22 20:43:21 They can contain, I don't think we are sanitizing
+}
+
function getPref(key, callback)
{
let checkPref = getPref.checks[key] || getPref.checkNone;
checkPref((isActive) =>
{
if (!isActive)
{
hidePref(key, !isActive);
@@ -1447,17 +1452,26 @@
case "addSubscription":
let subscription = message.args[0];
let dialog = E("dialog-content-predefined");
dialog.querySelector("h3").textContent = subscription.title || "";
dialog.querySelector(".url").textContent = subscription.url;
openDialog("predefined");
break;
case "focusSection":
saroyanm 2018/03/22 16:15:53 We used to set the tab view to the notifications -
- document.body.setAttribute("data-tab", message.args[0]);
+ let section = message.args[0];
+ if (section == "notifications")
+ {
+ section = "advanced";
+ let elem = getPrefElement("notifications_ignoredcategories");
+ elem.classList.add("highlight-animate");
a.giammarchi 2018/03/22 18:43:28 so, in hidePref you check if elem is there before
saroyanm 2018/03/22 20:43:21 Not necessarily, because "notifications_ignoredcat
+ elem.querySelector("button").focus();
+ }
+
+ selectTabItem(section, document.body, false);
break;
}
break;
case "filters.respond":
onFilterMessage(message.action, message.args[0]);
break;
case "prefs.respond":
onPrefMessage(message.action, message.args[0], false);
« css/desktop-options.scss ('K') | « css/desktop-options.scss ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld