siteRes: GetSiteResponse;
communityId: number;
communityName: string;
- loading: boolean;
+ communityLoading: boolean;
+ postsLoading: boolean;
+ commentsLoading: boolean;
posts: Post[];
comments: Comment[];
dataType: DataType;
communityRes: undefined,
communityId: Number(this.props.match.params.id),
communityName: this.props.match.params.name,
- loading: true,
+ communityLoading: true,
+ postsLoading: true,
+ commentsLoading: true,
posts: [],
comments: [],
dataType: getDataTypeFromProps(this.props),
this.state.comments = this.isoData.routeData[1].comments;
}
this.state.categories = this.isoData.routeData[2].categories;
- this.state.loading = false;
+ this.state.communityLoading = false;
+ this.state.postsLoading = false;
+ this.state.commentsLoading = false;
} else {
this.fetchCommunity();
this.fetchData();
lastState.sort !== this.state.sort ||
lastState.page !== this.state.page
) {
- this.setState({ loading: true });
+ this.setState({ postsLoading: true, commentsLoading: true });
this.fetchData();
}
}
render() {
return (
<div class="container">
- {this.state.loading ? (
+ {this.state.communityLoading ? (
<h5>
<svg class="icon icon-spinner spin">
<use xlinkHref="#icon-spinner"></use>
listings() {
return this.state.dataType == DataType.Post ? (
- <PostListings
- posts={this.state.posts}
- removeDuplicates
- sort={this.state.sort}
- enableDownvotes={this.state.siteRes.site.enable_downvotes}
- enableNsfw={this.state.siteRes.site.enable_nsfw}
- />
+ this.state.postsLoading ? (
+ <h5>
+ <svg class="icon icon-spinner spin">
+ <use xlinkHref="#icon-spinner"></use>
+ </svg>
+ </h5>
+ ) : (
+ <PostListings
+ posts={this.state.posts}
+ removeDuplicates
+ sort={this.state.sort}
+ enableDownvotes={this.state.siteRes.site.enable_downvotes}
+ enableNsfw={this.state.siteRes.site.enable_nsfw}
+ />
+ )
+ ) : this.state.commentsLoading ? (
+ <h5>
+ <svg class="icon icon-spinner spin">
+ <use xlinkHref="#icon-spinner"></use>
+ </svg>
+ </h5>
) : (
<CommentNodes
nodes={commentsToFlatNodes(this.state.comments)}
} else if (res.op == UserOperation.GetCommunity) {
let data = res.data as GetCommunityResponse;
this.state.communityRes = data;
- if (this.state.posts.length || this.state.comments.length) {
- this.state.loading = false;
- }
+ this.state.communityLoading = false;
this.setState(this.state);
WebSocketService.Instance.communityJoin({
community_id: data.community.id,
} else if (res.op == UserOperation.GetPosts) {
let data = res.data as GetPostsResponse;
this.state.posts = data.posts;
-
- if (this.state.communityRes) {
- this.state.loading = false;
- }
+ this.state.postsLoading = false;
this.setState(this.state);
setupTippy();
} else if (
} else if (res.op == UserOperation.GetComments) {
let data = res.data as GetCommentsResponse;
this.state.comments = data.comments;
- if (this.state.communityRes) {
- this.state.loading = false;
- }
+ this.state.commentsLoading = false;
this.setState(this.state);
} else if (
res.op == UserOperation.EditComment ||