Do not show a loading spinner if thread has root post loaded (#2186)

* Do not show a loading spinner if thread has root post loaded

* Feedback review

* Remove additional condition
This commit is contained in:
Elias Nahum 2018-09-28 11:54:41 -03:00
parent bf36a7533e
commit 093484eab3
No known key found for this signature in database
GPG key ID: E038DB71E0B61702

View file

@ -86,16 +86,21 @@ class Thread extends PureComponent {
hasRootPost = () => {
return this.props.postIds.includes(this.props.rootId);
}
};
renderFooter = () => {
if (!this.hasRootPost() && this.props.threadLoadingStatus.status !== RequestStatus.STARTED) {
return (
<DeletedPost theme={this.props.theme}/>
);
} else if (this.props.threadLoadingStatus.status === RequestStatus.STARTED) {
return (
<Loading/>
);
}
return null;
}
};
onCloseChannel = () => {
this.props.navigator.resetTo({
@ -112,7 +117,7 @@ class Thread extends PureComponent {
screenBackgroundColor: 'transparent',
},
});
}
};
render() {
const {
@ -126,11 +131,8 @@ class Thread extends PureComponent {
} = this.props;
const style = getStyle(theme);
let content;
if (this.props.threadLoadingStatus.status === RequestStatus.STARTED) {
content = (
<Loading/>
);
} else {
let postTextBox;
if (this.hasRootPost()) {
content = (
<PostList
renderFooter={this.renderFooter}
@ -141,9 +143,7 @@ class Thread extends PureComponent {
navigator={navigator}
/>
);
}
let postTextBox;
if (this.hasRootPost() && this.props.threadLoadingStatus.status !== RequestStatus.STARTED) {
postTextBox = (
<PostTextbox
channelIsArchived={channelIsArchived}
@ -153,6 +153,10 @@ class Thread extends PureComponent {
onCloseChannel={this.onCloseChannel}
/>
);
} else {
content = (
<Loading/>
);
}
return (