Problem: Susper used to render a new results page for each new character input. It should render a single page for the final query as reported in issue 371. For instance, the browser’s back button shows five pages for each of the five characters entered as a query.
Solution: This problem was arising due to code:
Before we have this one line in search-bar component which gets called on each character entry
Fix:To fix this issue we required calling router.navigate only when we receive results and not on each character input.
So, we first removed the line which was cause of this issue from search-bar component and replaced it with
This triggers a QueryServer action, and make a request to Yacy end point for search results.
Now in app.component.ts , we get subscribed to resultscomponentchange$ which gets called only when new search results are received and hence we navigate to a new page after the resultscomponentchange subscription is called.
Finally, this problem got fixed and now there is only one page being rendered for a valid search. Source code for this implementation is available in this pull.
- Introduction to ngrx/store: https://gist.github.com/btroncone/a6e4347326749f938510