From ac7a4031a809bac9ba958319ad678ea70df8618a Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 19 Jan 2020 16:47:54 -0500 Subject: [PATCH] Hide next paginator. - Fixes #441 - Hide post sort radio if no comments. --- ui/src/components/communities.tsx | 27 ++++++++++++--------------- ui/src/components/community.tsx | 14 ++++++++------ ui/src/components/main.tsx | 14 ++++++++------ ui/src/components/post.tsx | 2 +- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx index 7e4a0ef8b..598a5dad6 100644 --- a/ui/src/components/communities.tsx +++ b/ui/src/components/communities.tsx @@ -18,6 +18,8 @@ import { T } from 'inferno-i18next'; declare const Sortable: any; +const communityLimit = 100; + interface CommunitiesState { communities: Array; page: number; @@ -36,14 +38,7 @@ export class Communities extends Component { super(props, context); this.state = this.emptyState; this.subscription = WebSocketService.Instance.subject - .pipe( - retryWhen(errors => - errors.pipe( - delay(3000), - take(10) - ) - ) - ) + .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) .subscribe( msg => this.parseMessage(msg), err => console.error(err), @@ -180,12 +175,14 @@ export class Communities extends Component { # )} - + {this.state.communities.length == communityLimit && ( + + )} ); } @@ -227,7 +224,7 @@ export class Communities extends Component { refetch() { let listCommunitiesForm: ListCommunitiesForm = { sort: SortType[SortType.TopAll], - limit: 100, + limit: communityLimit, page: this.state.page, }; diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index 6bcd88b1d..03766bdcd 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -192,12 +192,14 @@ export class Community extends Component { # )} - + {this.state.posts.length == fetchLimit && ( + + )} ); } diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 9e7d690dc..95eeb1df5 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -480,12 +480,14 @@ export class Main extends Component { # )} - + {this.state.posts.length == fetchLimit && ( + + )} ); } diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index d48693866..c4bfccee1 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -178,7 +178,7 @@ export class Post extends Component { postId={this.state.post.id} disabled={this.state.post.locked} /> - {this.sortRadios()} + {this.state.comments.length > 0 && this.sortRadios()} {this.commentsTree()}