]> cat aescling's git repositories - mastodon.git/commitdiff
fix(components/bundle): Exit early in load function (#4349)
authorSorin Davidoi <sorin.davidoi@gmail.com>
Mon, 24 Jul 2017 23:05:44 +0000 (01:05 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Mon, 24 Jul 2017 23:05:44 +0000 (01:05 +0200)
app/javascript/mastodon/features/ui/components/bundle.js

index 72798f6906109d6cd9b08dad01dc8d93b0f7f00d..fc88e0c70f17dcd4cb5938143541a21b8fc8e2a7 100644 (file)
@@ -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;