Bug 1137141 - Fix for making the Loop contacts tab show and/ or hide when the user logs in or out of FxA. r=Standard8, a=sledru
authorMike de Boer <mdeboer@mozilla.com>
Fri, 27 Feb 2015 12:25:18 +0100
changeset 245438 7a4c981abfb6
parent 245437 b20bd6385474
child 245439 608bab8e4868
push id673
push userryanvm@gmail.com
push date2015-03-02 20:00 +0000
treeherdermozilla-release@608bab8e4868 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, sledru
bugs1137141
milestone36.0
Bug 1137141 - Fix for making the Loop contacts tab show and/ or hide when the user logs in or out of FxA. r=Standard8, a=sledru
browser/components/loop/content/js/panel.js
browser/components/loop/content/js/panel.jsx
--- a/browser/components/loop/content/js/panel.js
+++ b/browser/components/loop/content/js/panel.js
@@ -35,16 +35,28 @@ loop.panel = (function(_, mozL10n) {
       };
     },
 
     shouldComponentUpdate: function(nextProps, nextState) {
       var tabChange = this.state.selectedTab !== nextState.selectedTab;
       if (tabChange) {
         this.props.mozLoop.notifyUITour("Loop:PanelTabChanged", nextState.selectedTab);
       }
+
+      if (!tabChange && nextProps.buttonsHidden) {
+        if (nextProps.buttonsHidden.length !== this.props.buttonsHidden.length) {
+          tabChange = true;
+        } else {
+          for (var i = 0, l = nextProps.buttonsHidden.length; i < l && !tabChange; ++i) {
+            if (this.props.buttonsHidden.indexOf(nextProps.buttonsHidden[i]) === -1) {
+              tabChange = true;
+            }
+          }
+        }
+      }
       return tabChange;
     },
 
     getInitialState: function() {
       // XXX Work around props.selectedTab being undefined initially.
       // When we don't need to rely on the pref, this can move back to
       // getDefaultProps (bug 1100258).
       return {
--- a/browser/components/loop/content/js/panel.jsx
+++ b/browser/components/loop/content/js/panel.jsx
@@ -35,16 +35,28 @@ loop.panel = (function(_, mozL10n) {
       };
     },
 
     shouldComponentUpdate: function(nextProps, nextState) {
       var tabChange = this.state.selectedTab !== nextState.selectedTab;
       if (tabChange) {
         this.props.mozLoop.notifyUITour("Loop:PanelTabChanged", nextState.selectedTab);
       }
+
+      if (!tabChange && nextProps.buttonsHidden) {
+        if (nextProps.buttonsHidden.length !== this.props.buttonsHidden.length) {
+          tabChange = true;
+        } else {
+          for (var i = 0, l = nextProps.buttonsHidden.length; i < l && !tabChange; ++i) {
+            if (this.props.buttonsHidden.indexOf(nextProps.buttonsHidden[i]) === -1) {
+              tabChange = true;
+            }
+          }
+        }
+      }
       return tabChange;
     },
 
     getInitialState: function() {
       // XXX Work around props.selectedTab being undefined initially.
       // When we don't need to rely on the pref, this can move back to
       // getDefaultProps (bug 1100258).
       return {