about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSorin Davidoi <sorin.davidoi@gmail.com>2017-07-25 01:05:44 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-07-25 01:05:44 +0200
commit23e854cb9176f7458fd7c2f66071486c21db239a (patch)
tree15f0e1d80101b405b7b5cf0e903fa0b1f5014ef0
parentde105d64d519bb7d4b9c0cac1e66c8205406782b (diff)
fix(components/bundle): Exit early in load function (#4349)
-rw-r--r--app/javascript/mastodon/features/ui/components/bundle.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/javascript/mastodon/features/ui/components/bundle.js b/app/javascript/mastodon/features/ui/components/bundle.js
index 72798f690..fc88e0c70 100644
--- a/app/javascript/mastodon/features/ui/components/bundle.js
+++ b/app/javascript/mastodon/features/ui/components/bundle.js
@@ -52,14 +52,8 @@ class Bundle extends React.Component {
   load = (props) => {
     const { fetchComponent, onFetch, onFetchSuccess, onFetchFail, renderDelay } = props || this.props;
 
-    this.setState({ mod: undefined });
     onFetch();
 
-    if (renderDelay !== 0) {
-      this.timestamp = new Date();
-      this.timeout = setTimeout(() => this.setState({ forceRender: true }), renderDelay);
-    }
-
     if (Bundle.cache[fetchComponent.name]) {
       const mod = Bundle.cache[fetchComponent.name];
 
@@ -68,6 +62,13 @@ class Bundle extends React.Component {
       return Promise.resolve();
     }
 
+    this.setState({ mod: undefined });
+
+    if (renderDelay !== 0) {
+      this.timestamp = new Date();
+      this.timeout = setTimeout(() => this.setState({ forceRender: true }), renderDelay);
+    }
+
     return fetchComponent()
       .then((mod) => {
         Bundle.cache[fetchComponent.name] = mod;