From 2b81cea27770c0bc75a6bcf9f8ef96383532bba4 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Sun, 4 Feb 2018 17:27:57 -0800 Subject: [PATCH 1/3] Search fixes --- app/scenes/Search/Search.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/scenes/Search/Search.js b/app/scenes/Search/Search.js index 8766e378..1a5f22b6 100644 --- a/app/scenes/Search/Search.js +++ b/app/scenes/Search/Search.js @@ -68,6 +68,7 @@ class Search extends Component { @observable offset: number = 0; @observable allowLoadMore: boolean = true; @observable isFetching = false; + @observable pinToTop = false; componentDidMount() { this.handleQueryChange(); @@ -103,7 +104,9 @@ class Search extends Component { handleQueryChange = () => { const query = this.props.match.params.query; - this.query = query ? decodeURIComponent(query) : ''; + this.query = query ? query : ''; + this.resultIds = []; + this.offset = 0; this.allowLoadMore = true; // To prevent "no results" showing before debounce kicks in @@ -137,6 +140,7 @@ class Search extends Component { limit: DEFAULT_PAGINATION_LIMIT, }); this.resultIds = this.resultIds.concat(newResults); + if (this.resultIds.length > 0) this.pinToTop = true; if ( newResults.length === 0 || newResults.length < DEFAULT_PAGINATION_LIMIT @@ -150,6 +154,7 @@ class Search extends Component { } } else { this.resultIds = []; + this.pinToTop = false; } this.isFetching = false; @@ -172,8 +177,8 @@ class Search extends Component { render() { const { documents, notFound } = this.props; - const hasResults = this.resultIds.length > 0; - const showEmpty = !this.isFetching && this.query && !hasResults; + const showEmpty = + !this.isFetching && this.query && this.resultIds.length === 0; return ( @@ -185,14 +190,14 @@ class Search extends Component {

We’re unable to find the page you’re accessing.

)} - + {showEmpty && No matching documents.} - + Date: Sun, 4 Feb 2018 17:28:14 -0800 Subject: [PATCH 2/3] Removed useless catch --- server/routes.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/server/routes.js b/server/routes.js index 86e968f0..4e578a01 100644 --- a/server/routes.js +++ b/server/routes.js @@ -94,8 +94,5 @@ router.get('*', async ctx => { // middleware koa.use(subdomainRedirect()); koa.use(router.routes()); -koa.use(async () => { - throw httpErrors.NotFound(); -}); export default koa; From bfb5e8e6b6531db9cb25d804730459e45351bb1f Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Sun, 4 Feb 2018 17:31:12 -0800 Subject: [PATCH 3/3] Exhaustive types --- app/scenes/Search/Search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/scenes/Search/Search.js b/app/scenes/Search/Search.js index 1a5f22b6..4b775110 100644 --- a/app/scenes/Search/Search.js +++ b/app/scenes/Search/Search.js @@ -67,8 +67,8 @@ class Search extends Component { @observable query: string = ''; @observable offset: number = 0; @observable allowLoadMore: boolean = true; - @observable isFetching = false; - @observable pinToTop = false; + @observable isFetching: boolean = false; + @observable pinToTop: boolean = false; componentDidMount() { this.handleQueryChange();