From: Dessalines Date: Fri, 10 Jul 2020 00:03:33 +0000 (-0400) Subject: Correctly hide next / prev in paginators. Fixes #914 (#927) X-Git-Url: http://these/git/%22%7Burl%7D/%7Bicon?a=commitdiff_plain;h=85c07e7154c82e5b387bb6a02aae70645cf1d8e0;p=lemmy.git Correctly hide next / prev in paginators. Fixes #914 (#927) --- diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx index 441f7bb1..10a3ab80 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 = + 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; - UserService.Instance.user.unreadCount = count; - UserService.Instance.sub.next({ - user: UserService.Instance.user, - }); + ).length + ); } } diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 9e9027d6..9063a039 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 7e679ed1..af72a397 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -893,12 +893,14 @@ export class User extends Component { {i18n.t('prev')} )} - + {this.state.comments.length + this.state.posts.length > 0 && ( + + )} ); }