summaryrefslogtreecommitdiffstats
path: root/ui/src/components/search.tsx
diff options
context:
space:
mode:
authorDessalines <dessalines@users.noreply.github.com>2020-07-09 20:03:33 -0400
committerGitHub <noreply@github.com>2020-07-09 20:03:33 -0400
commit85c07e7154c82e5b387bb6a02aae70645cf1d8e0 (patch)
tree3b5a56578b8b504faf366555466422f0b14b2770 /ui/src/components/search.tsx
parentd222c60cef289b57f0ce350e9f24ce2df4792ef5 (diff)
Correctly hide next / prev in paginators. Fixes #914 (#927)
Diffstat (limited to 'ui/src/components/search.tsx')
-rw-r--r--ui/src/components/search.tsx30
1 files changed, 15 insertions, 15 deletions
diff --git a/ui/src/components/search.tsx b/ui/src/components/search.tsx
index 2588528a..dd219ba9 100644
--- a/ui/src/components/search.tsx
+++ b/ui/src/components/search.tsx
@@ -148,7 +148,7 @@ export class Search extends Component<any, SearchState> {
{this.state.type_ == SearchType.Posts && this.posts()}
{this.state.type_ == SearchType.Communities && this.communities()}
{this.state.type_ == SearchType.Users && this.users()}
- {this.noResults()}
+ {this.resultsCount() == 0 && <span>{i18n.t('no_results')}</span>}
{this.paginator()}
</div>
);
@@ -383,26 +383,26 @@ export class Search extends Component<any, SearchState> {
{i18n.t('prev')}
</button>
)}
- <button
- class="btn btn-sm btn-secondary"
- onClick={linkEvent(this, this.nextPage)}
- >
- {i18n.t('next')}
- </button>
+
+ {this.resultsCount() > 0 && (
+ <button
+ class="btn btn-sm btn-secondary"
+ onClick={linkEvent(this, this.nextPage)}
+ >
+ {i18n.t('next')}
+ </button>
+ )}
</div>
);
}
- noResults() {
+ resultsCount(): number {
let res = this.state.searchResponse;
return (
- <div>
- {res &&
- res.posts.length == 0 &&
- res.comments.length == 0 &&
- res.communities.length == 0 &&
- res.users.length == 0 && <span>{i18n.t('no_results')}</span>}
- </div>
+ res.posts.length +
+ res.comments.length +
+ res.communities.length +
+ res.users.length
);
}