Skip to content

Commit

Permalink
Allow appending to existing search results
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Oct 17, 2016
1 parent ffbaac9 commit 265e436
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions web/client/actions/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ const TEXT_SEARCH_RESET = 'TEXT_SEARCH_RESET';
const TEXT_SEARCH_ADD_MARKER = 'TEXT_SEARCH_ADD_MARKER';
const TEXT_SEARCH_TEXT_CHANGE = 'TEXT_SEARCH_TEXT_CHANGE';

function searchResultLoaded(results) {
function searchResultLoaded(results, append=false) {
return {
type: TEXT_SEARCH_RESULTS_LOADED,
results: results.data
results: results.data,
append: append
};
}

Expand Down
6 changes: 5 additions & 1 deletion web/client/reducers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ function search(state = null, action) {
case TEXT_SEARCH_TEXT_CHANGE:
return assign({}, state, { searchText: action.searchText });
case TEXT_SEARCH_RESULTS_LOADED:
return assign({}, state, { results: action.results });
let results = action.results;
if (action.append === true && state && state.results) {
results = [...state.results, ...action.results];
}
return assign({}, state, { results: results });
case TEXT_SEARCH_RESULTS_PURGE:
return assign({}, state, { results: null });
case TEXT_SEARCH_ADD_MARKER:
Expand Down

0 comments on commit 265e436

Please sign in to comment.