From: Dessalines Date: Wed, 2 Dec 2020 15:13:01 +0000 (-0600) Subject: fixing loading on community page. Fixes #91 X-Git-Url: http://these/git/ui/assets/static/%24%7Bargs.pageFn.jump%20n%7D?a=commitdiff_plain;h=fa4a6bd3894e0238412ee89e5d5f1f8f5a810392;p=lemmy-ui.git fixing loading on community page. Fixes #91 --- diff --git a/src/shared/components/community.tsx b/src/shared/components/community.tsx index 18fa459..c7d0a27 100644 --- a/src/shared/components/community.tsx +++ b/src/shared/components/community.tsx @@ -60,7 +60,9 @@ interface State { siteRes: GetSiteResponse; communityId: number; communityName: string; - loading: boolean; + communityLoading: boolean; + postsLoading: boolean; + commentsLoading: boolean; posts: Post[]; comments: Comment[]; dataType: DataType; @@ -88,7 +90,9 @@ export class Community extends Component { 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), @@ -117,7 +121,9 @@ export class Community extends Component { 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(); @@ -220,7 +226,7 @@ export class Community extends Component { lastState.sort !== this.state.sort || lastState.page !== this.state.page ) { - this.setState({ loading: true }); + this.setState({ postsLoading: true, commentsLoading: true }); this.fetchData(); } } @@ -232,7 +238,7 @@ export class Community extends Component { render() { return (
- {this.state.loading ? ( + {this.state.communityLoading ? (
@@ -270,13 +276,27 @@ export class Community extends Component { listings() { return this.state.dataType == DataType.Post ? ( - + this.state.postsLoading ? ( +
+ + + +
+ ) : ( + + ) + ) : this.state.commentsLoading ? ( +
+ + + +
) : ( { } 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, @@ -452,10 +470,7 @@ export class Community extends Component { } 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 ( @@ -493,9 +508,7 @@ export class Community extends Component { } 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 ||