From fb64bcadbd0fbf9cdf761e41cad6b9b2e709d894 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 9 Apr 2019 11:59:29 +0200 Subject: [PATCH] search updates for Aquarius 0.2.2 & pagination fixes --- client/src/components/molecules/Pagination.tsx | 2 +- client/src/routes/Search.tsx | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/client/src/components/molecules/Pagination.tsx b/client/src/components/molecules/Pagination.tsx index 427eec1..191d866 100644 --- a/client/src/components/molecules/Pagination.tsx +++ b/client/src/components/molecules/Pagination.tsx @@ -47,7 +47,7 @@ export default class Pagination extends PureComponent<{ }> { public render() { const { currentPage, totalPages, prevPage, setPage } = this.props - const isFirst = currentPage === 0 + const isFirst = currentPage === 1 const isLast = currentPage === totalPages return totalPages > 1 ? ( diff --git a/client/src/routes/Search.tsx b/client/src/routes/Search.tsx index 5a8dd47..85c41ec 100644 --- a/client/src/routes/Search.tsx +++ b/client/src/routes/Search.tsx @@ -28,7 +28,7 @@ export default class Search extends PureComponent { totalResults: 0, offset: 25, totalPages: 1, - currentPage: 0, + currentPage: 1, isLoading: true } @@ -59,15 +59,14 @@ export default class Search extends PureComponent { results: search.results, totalResults: search.totalResults, totalPages: search.totalPages, - currentPage: search.page, // first page is always 0 in response isLoading: false }) Logger.log(`Loaded ${this.state.results.length} assets`) } - private setPage = (page: number) => { - this.setState({ currentPage: page }) - this.searchAssets() + private setPage = async (page: number) => { + await this.setState({ currentPage: page, isLoading: true }) + await this.searchAssets() } public renderResults = () =>