You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2017/04/19 08:19:31 UTC

[couchdb-fauxton] branch master updated: (#899) - remove deprecated isMounted api

This is an automated email from the ASF dual-hosted git repository.

garren pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git

The following commit(s) were added to refs/heads/master by this push:
       new  f94f674   (#899) - remove deprecated isMounted api
f94f674 is described below

commit f94f6746e0718d6bfd612743a9dc196824ac19ae
Author: garren smith <ga...@gmail.com>
AuthorDate: Wed Apr 19 10:19:29 2017 +0200

    (#899) - remove deprecated isMounted api
    
    remove deprecated isMounted api
---
 app/addons/components/components/tray.js                 |  8 +-------
 app/addons/databases/components.react.jsx                |  4 +---
 app/addons/documents/doc-editor/components.react.jsx     |  4 +---
 app/addons/documents/index-editor/components.react.jsx   |  8 ++------
 app/addons/documents/sidebar/sidebar.react.jsx           |  4 +---
 app/addons/fauxton/notifications/notifications.react.jsx |  4 +---
 app/addons/fauxton/notifications/stores.js               | 12 ++----------
 app/addons/setup/setup.react.jsx                         | 12 +++---------
 app/addons/setup/setup.stores.js                         |  8 +++++++-
 9 files changed, 19 insertions(+), 45 deletions(-)

diff --git a/app/addons/components/components/tray.js b/app/addons/components/components/tray.js
index 8602837..37d0d61 100644
--- a/app/addons/components/components/tray.js
+++ b/app/addons/components/components/tray.js
@@ -87,17 +87,11 @@ export const connectToStores = (Component, stores, getStateFromStores) => {
     },
 
     onChange () {
-      if (!this.isMounted()) {
-        return;
-      }
-
       this.setState(getStateFromStores(this.props));
     },
 
     handleStoresChanged () {
-      if (this.isMounted()) {
-        this.setState(getStateFromStores(this.props));
-      }
+      this.setState(getStateFromStores(this.props));
     },
 
     render () {
diff --git a/app/addons/databases/components.react.jsx b/app/addons/databases/components.react.jsx
index 58cf053..fface84 100644
--- a/app/addons/databases/components.react.jsx
+++ b/app/addons/databases/components.react.jsx
@@ -54,9 +54,7 @@ var DatabasesController = React.createClass({
   },
 
   onChange () {
-    if (this.isMounted()) {
-      this.setState(this.getStoreState());
-    }
+    this.setState(this.getStoreState());
   },
 
   render () {
diff --git a/app/addons/documents/doc-editor/components.react.jsx b/app/addons/documents/doc-editor/components.react.jsx
index c1932fe..3ac6e34 100644
--- a/app/addons/documents/doc-editor/components.react.jsx
+++ b/app/addons/documents/doc-editor/components.react.jsx
@@ -93,9 +93,7 @@ var DocEditorController = React.createClass({
   },
 
   onChange: function () {
-    if (this.isMounted()) {
-      this.setState(this.getStoreState());
-    }
+    this.setState(this.getStoreState());
   },
 
   saveDoc: function () {
diff --git a/app/addons/documents/index-editor/components.react.jsx b/app/addons/documents/index-editor/components.react.jsx
index fa835b3..d864e21 100644
--- a/app/addons/documents/index-editor/components.react.jsx
+++ b/app/addons/documents/index-editor/components.react.jsx
@@ -210,9 +210,7 @@ var ReduceEditor = React.createClass({
   },
 
   onChange: function () {
-    if (this.isMounted()) {
-      this.setState(this.getStoreState());
-    }
+    this.setState(this.getStoreState());
   },
 
   componentDidMount: function () {
@@ -250,9 +248,7 @@ var EditorController = React.createClass({
   },
 
   onChange: function () {
-    if (this.isMounted()) {
-      this.setState(this.getStoreState());
-    }
+    this.setState(this.getStoreState());
   },
 
   componentDidMount: function () {
diff --git a/app/addons/documents/sidebar/sidebar.react.jsx b/app/addons/documents/sidebar/sidebar.react.jsx
index 3ae98cc..c2d2ec1 100644
--- a/app/addons/documents/sidebar/sidebar.react.jsx
+++ b/app/addons/documents/sidebar/sidebar.react.jsx
@@ -479,9 +479,7 @@ var SidebarController = React.createClass({
   },
 
   onChange: function () {
-    if (this.isMounted()) {
-      this.setState(this.getStoreState());
-    }
+    this.setState(this.getStoreState());
   },
 
   showDeleteDatabaseModal: function (payload) {
diff --git a/app/addons/fauxton/notifications/notifications.react.jsx b/app/addons/fauxton/notifications/notifications.react.jsx
index 073e0a4..0f7fce5 100644
--- a/app/addons/fauxton/notifications/notifications.react.jsx
+++ b/app/addons/fauxton/notifications/notifications.react.jsx
@@ -49,9 +49,7 @@ export const NotificationController = React.createClass({
   },
 
   onChange: function () {
-    if (this.isMounted()) {
-      this.setState(this.getStoreState());
-    }
+    this.setState(this.getStoreState());
   },
 
   render: function () {
diff --git a/app/addons/fauxton/notifications/stores.js b/app/addons/fauxton/notifications/stores.js
index e320f13..79f05a0 100644
--- a/app/addons/fauxton/notifications/stores.js
+++ b/app/addons/fauxton/notifications/stores.js
@@ -133,12 +133,10 @@ Stores.NotificationStore = FauxtonAPI.Store.extend({
     switch (action.type) {
       case ActionTypes.ADD_NOTIFICATION:
         this.addNotification(action.options.info);
-        this.triggerChange();
       break;
 
       case ActionTypes.CLEAR_ALL_NOTIFICATIONS:
         this.clearNotifications();
-        this.triggerChange();
       break;
 
       case ActionTypes.CLEAR_SINGLE_NOTIFICATION:
@@ -147,49 +145,43 @@ Stores.NotificationStore = FauxtonAPI.Store.extend({
 
       case ActionTypes.START_HIDING_NOTIFICATION:
         this.startHidingNotification(action.options.notificationId);
-        this.triggerChange();
       break;
 
       case ActionTypes.HIDE_NOTIFICATION:
         this.hideNotification(action.options.notificationId);
-        this.triggerChange();
       break;
 
       case ActionTypes.HIDE_ALL_NOTIFICATIONS:
         this.hideAllNotifications();
-        this.triggerChange();
       break;
 
       case ActionTypes.SHOW_NOTIFICATION_CENTER:
         this._notificationCenterVisible = true;
-        this.triggerChange();
       break;
 
       case ActionTypes.HIDE_NOTIFICATION_CENTER:
         this._notificationCenterVisible = false;
-        this.triggerChange();
       break;
 
       case ActionTypes.SELECT_NOTIFICATION_FILTER:
         this.setNotificationFilter(action.options.filter);
-        this.triggerChange();
       break;
 
       case ActionTypes.SHOW_PERMANENT_NOTIFICATION:
         this._permanentNotificationVisible = true;
         this.setPermanentNotificationMessage(action.options.msg);
-        this.triggerChange();
       break;
 
       case ActionTypes.HIDE_PERMANENT_NOTIFICATION:
         this._permanentNotificationVisible = false;
-        this.triggerChange();
       break;
 
       default:
       return;
         // do nothing
     }
+
+    this.triggerChange();
   }
 });
 
diff --git a/app/addons/setup/setup.react.jsx b/app/addons/setup/setup.react.jsx
index 1626ef5..7bc3219 100644
--- a/app/addons/setup/setup.react.jsx
+++ b/app/addons/setup/setup.react.jsx
@@ -134,9 +134,7 @@ var SetupMultipleNodesController = React.createClass({
   },
 
   onChange: function () {
-    if (this.isMounted()) {
-      this.setState(this.getStoreState());
-    }
+    this.setState(this.getStoreState());
   },
 
   getNodeList: function () {
@@ -256,9 +254,7 @@ var SetupSingleNodeController = React.createClass({
   },
 
   onChange: function () {
-    if (this.isMounted()) {
-      this.setState(this.getStoreState());
-    }
+    this.setState(this.getStoreState());
   },
 
   alterUsername: function (e) {
@@ -323,9 +319,7 @@ var SetupFirstStepController = React.createClass({
   },
 
   onChange: function () {
-    if (this.isMounted()) {
-      this.setState(this.getStoreState());
-    }
+    this.setState(this.getStoreState());
   },
 
   render: function () {
diff --git a/app/addons/setup/setup.stores.js b/app/addons/setup/setup.stores.js
index 93946df..b033ca8 100644
--- a/app/addons/setup/setup.stores.js
+++ b/app/addons/setup/setup.stores.js
@@ -164,7 +164,13 @@ var SetupStore = FauxtonAPI.Store.extend({
       return;
     }
 
-    this.triggerChange();
+    //This is a quick and somewhat messy fix
+    //Some of the way our components are linked together can cause a component to be re-rendered
+    //even after it is unmounted.
+    // This fix stops that from happening
+    setTimeout(() => {
+      this.triggerChange();
+    });
   }
 
 });

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].