mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-12-22 13:17:13 +00:00
fix(components/bundle): Exit early in load function (#4349)
This commit is contained in:
parent
de105d64d5
commit
23e854cb91
|
@ -52,14 +52,8 @@ class Bundle extends React.Component {
|
||||||
load = (props) => {
|
load = (props) => {
|
||||||
const { fetchComponent, onFetch, onFetchSuccess, onFetchFail, renderDelay } = props || this.props;
|
const { fetchComponent, onFetch, onFetchSuccess, onFetchFail, renderDelay } = props || this.props;
|
||||||
|
|
||||||
this.setState({ mod: undefined });
|
|
||||||
onFetch();
|
onFetch();
|
||||||
|
|
||||||
if (renderDelay !== 0) {
|
|
||||||
this.timestamp = new Date();
|
|
||||||
this.timeout = setTimeout(() => this.setState({ forceRender: true }), renderDelay);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Bundle.cache[fetchComponent.name]) {
|
if (Bundle.cache[fetchComponent.name]) {
|
||||||
const mod = Bundle.cache[fetchComponent.name];
|
const mod = Bundle.cache[fetchComponent.name];
|
||||||
|
|
||||||
|
@ -68,6 +62,13 @@ class Bundle extends React.Component {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setState({ mod: undefined });
|
||||||
|
|
||||||
|
if (renderDelay !== 0) {
|
||||||
|
this.timestamp = new Date();
|
||||||
|
this.timeout = setTimeout(() => this.setState({ forceRender: true }), renderDelay);
|
||||||
|
}
|
||||||
|
|
||||||
return fetchComponent()
|
return fetchComponent()
|
||||||
.then((mod) => {
|
.then((mod) => {
|
||||||
Bundle.cache[fetchComponent.name] = mod;
|
Bundle.cache[fetchComponent.name] = mod;
|
||||||
|
|
Loading…
Reference in a new issue