From 34f6e617652ad1e78505cd8b962e09ed1e182200 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 9 Jul 2020 14:44:34 -0400 Subject: [PATCH] Correctly hide next / prev in paginators. Fixes #914 --- ui/src/components/communities.tsx | 2 +- ui/src/components/community.tsx | 2 +- ui/src/components/inbox.tsx | 32 ++++++++++++++++++------------- ui/src/components/main.tsx | 2 +- ui/src/components/search.tsx | 30 ++++++++++++++--------------- ui/src/components/user.tsx | 14 ++++++++------ 6 files changed, 45 insertions(+), 37 deletions(-) diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx index 441f7bb14..10a3ab803 100644 --- a/ui/src/components/communities.tsx +++ b/ui/src/components/communities.tsx @@ -160,7 +160,7 @@ export class Communities extends Component { )} - {this.state.communities.length == communityLimit && ( + {this.state.communities.length > 0 && ( )} - {this.state.posts.length == fetchLimit && ( + {this.state.posts.length > 0 && ( )} - + {this.unreadCount() > 0 && ( + + )} ); } @@ -534,15 +536,19 @@ export class Inbox extends Component { } sendUnreadCount() { - let count = - this.state.replies.filter(r => !r.read).length + - this.state.mentions.filter(r => !r.read).length + - this.state.messages.filter( - r => !r.read && r.creator_id !== UserService.Instance.user.id - ).length; - UserService.Instance.user.unreadCount = count; + UserService.Instance.user.unreadCount = this.unreadCount(); UserService.Instance.sub.next({ user: UserService.Instance.user, }); } + + unreadCount(): number { + return ( + this.state.replies.filter(r => !r.read).length + + this.state.mentions.filter(r => !r.read).length + + this.state.messages.filter( + r => !r.read && r.creator_id !== UserService.Instance.user.id + ).length + ); + } } diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 9e9027d63..9063a0396 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -497,7 +497,7 @@ export class Main extends Component { {i18n.t('prev')} )} - {this.state.posts.length == fetchLimit && ( + {this.state.posts.length > 0 && ( )} - + + {this.resultsCount() > 0 && ( + + )} ); } - noResults() { + resultsCount(): number { let res = this.state.searchResponse; return ( -
- {res && - res.posts.length == 0 && - res.comments.length == 0 && - res.communities.length == 0 && - res.users.length == 0 && {i18n.t('no_results')}} -
+ res.posts.length + + res.comments.length + + res.communities.length + + res.users.length ); } diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx index 078ce89c8..c1d0cfce4 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -883,12 +883,14 @@ export class User extends Component { {i18n.t('prev')} )} - + {this.state.comments.length + this.state.posts.length > 0 && ( + + )} ); }