From: Dessalines Date: Mon, 8 Apr 2019 21:46:09 +0000 (-0700) Subject: Loading indicators. X-Git-Url: http://these/git/%7B%60/feeds/front/static/%24%7Bsrc%7D?a=commitdiff_plain;h=70ff6381039eba97a63035392f87056a023ea36b;p=lemmy.git Loading indicators. - Fixes #10 - Adding SVG symbols component --- diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx index b81b11cd..cf42238e 100644 --- a/ui/src/components/communities.tsx +++ b/ui/src/components/communities.tsx @@ -10,24 +10,26 @@ declare const Sortable: any; interface CommunitiesState { communities: Array; + loading: boolean; } export class Communities extends Component { private subscription: Subscription; private emptyState: CommunitiesState = { - communities: [] + communities: [], + loading: true } constructor(props: any, context: any) { super(props, context); this.state = this.emptyState; this.subscription = WebSocketService.Instance.subject - .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) - .subscribe( - (msg) => this.parseMessage(msg), + .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) + .subscribe( + (msg) => this.parseMessage(msg), (err) => console.error(err), () => console.log('complete') - ); + ); WebSocketService.Instance.listCommunities(); } @@ -44,40 +46,45 @@ export class Communities extends Component { render() { return (
-

Communities

-
- - - - - - - - - - - - - - {this.state.communities.map(community => + {this.state.loading ? +

: +
+

Communities

+
+
NameTitleCategorySubscribersPostsComments
+ - - - - - - - + + + + + + + - )} - -
{community.name}{community.title}{community.category_name}{community.number_of_subscribers}{community.number_of_posts}{community.number_of_comments} - {community.subscribed - ? - : - } - NameTitleCategorySubscribersPostsComments
+ + + {this.state.communities.map(community => + + {community.name} + {community.title} + {community.category_name} + {community.number_of_subscribers} + {community.number_of_posts} + {community.number_of_comments} + + {community.subscribed ? + : + + } + + + )} + + +
+ } ); } @@ -109,6 +116,7 @@ export class Communities extends Component { let res: ListCommunitiesResponse = msg; this.state.communities = res.communities; this.state.communities.sort((a, b) => b.number_of_subscribers - a.number_of_subscribers); + this.state.loading = false; this.setState(this.state); } else if (op == UserOperation.FollowCommunity) { let res: CommunityResponse = msg; diff --git a/ui/src/components/community-form.tsx b/ui/src/components/community-form.tsx index 6250ef9c..b5b222c6 100644 --- a/ui/src/components/community-form.tsx +++ b/ui/src/components/community-form.tsx @@ -4,6 +4,7 @@ import { retryWhen, delay, take } from 'rxjs/operators'; import { CommunityForm as CommunityFormI, UserOperation, Category, ListCategoriesResponse, CommunityResponse } from '../interfaces'; import { WebSocketService } from '../services'; import { msgOp } from '../utils'; +import * as autosize from 'autosize'; import { Community } from '../interfaces'; @@ -17,6 +18,7 @@ interface CommunityFormProps { interface CommunityFormState { communityForm: CommunityFormI; categories: Array; + loading: boolean; } export class CommunityForm extends Component { @@ -28,7 +30,8 @@ export class CommunityForm extends Component
-