Bug 1409058 - Add pref to show or hide snippets in the pref panel draft bug1409058
authork88hudson <khudson@mozilla.com>
Mon, 16 Oct 2017 11:46:58 -0400
changeset 683445 3ad980d04f3e81ada340b26b26071d3fa400190d
parent 683444 7ca5c2de815431caaba0e5b4c8d660f34c0e3f74
child 736658 579be30885c010ccfce571b8ce77ca03f9a7f5f8
push id85387
push userkhudson@mozilla.com
push dateThu, 19 Oct 2017 19:17:43 +0000
bugs1409058
milestone58.0a1
Bug 1409058 - Add pref to show or hide snippets in the pref panel MozReview-Commit-ID: Ia1vpkBVDMn
browser/extensions/activity-stream/data/content/activity-stream.bundle.js
browser/extensions/activity-stream/lib/ActivityStream.jsm
--- a/browser/extensions/activity-stream/data/content/activity-stream.bundle.js
+++ b/browser/extensions/activity-stream/data/content/activity-stream.bundle.js
@@ -2758,18 +2758,18 @@ class PreferencesPane extends React.Pure
                 key: nestedPref.name,
                 prefName: nestedPref.name,
                 disabled: !enabled,
                 value: prefs[nestedPref.name],
                 onChange: this.handlePrefChange,
                 titleString: nestedPref.titleString,
                 labelClassName: `icon ${nestedPref.icon}` }))
             )),
-            React.createElement("hr", null),
-            React.createElement(PreferencesInput, { className: "showSnippets", prefName: "feeds.snippets",
+            !prefs.disableSnippets && React.createElement("hr", null),
+            !prefs.disableSnippets && React.createElement(PreferencesInput, { className: "showSnippets", prefName: "feeds.snippets",
               value: prefs["feeds.snippets"], onChange: this.handlePrefChange,
               titleString: { id: "settings_pane_snippets_header" },
               descString: { id: "settings_pane_snippets_body" } })
           ),
           React.createElement(
             "section",
             { className: "actions" },
             React.createElement(
@@ -3883,23 +3883,23 @@ function addSnippetsSubscriber(store) {
 
   let initializing = false;
 
   store.subscribe(async () => {
     const state = store.getState();
     // state.Prefs.values["feeds.snippets"]:  Should snippets be shown?
     // state.Snippets.initialized             Is the snippets data initialized?
     // snippets.initialized:                  Is SnippetsProvider currently initialised?
-    if (state.Prefs.values["feeds.snippets"] && state.Snippets.initialized && !snippets.initialized &&
+    if (state.Prefs.values["feeds.snippets"] && !state.Prefs.values.disableSnippets && state.Snippets.initialized && !snippets.initialized &&
     // Don't call init multiple times
     !initializing) {
       initializing = true;
       await snippets.init({ appData: state.Snippets });
       initializing = false;
-    } else if (state.Prefs.values["feeds.snippets"] === false && snippets.initialized) {
+    } else if ((state.Prefs.values["feeds.snippets"] === false || state.Prefs.values.disableSnippets === true) && snippets.initialized) {
       snippets.uninit();
     }
   });
 
   // These values are returned for testing purposes
   return snippets;
 }
 
@@ -3907,9 +3907,9 @@ module.exports = {
   addSnippetsSubscriber,
   SnippetsMap,
   SnippetsProvider,
   SNIPPETS_UPDATE_INTERVAL_MS
 };
 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
 
 /***/ })
-/******/ ]);
\ No newline at end of file
+/******/ ]);
--- a/browser/extensions/activity-stream/lib/ActivityStream.jsm
+++ b/browser/extensions/activity-stream/lib/ActivityStream.jsm
@@ -92,16 +92,20 @@ const PREFS_CONFIG = new Map([
   ["prerender", {
     title: "Use the prerendered version of activity-stream.html. This is set automatically by PrefsFeed.jsm.",
     value: true
   }],
   ["showSearch", {
     title: "Show the Search bar",
     value: true
   }],
+  ["disableSnippets", {
+    title: "Disable snippets on activity stream",
+    value: false
+  }],
   ["showTopSites", {
     title: "Show the Top Sites section",
     value: true
   }],
   ["collapseTopSites", {
     title: "Collapse the Top Sites section",
     value: false
   }],