Only concatenate results if 'from !== 0'

This commit is contained in:
infinite-persistence 2021-04-07 18:50:15 +08:00 committed by Sean Yesmunt
parent 340c883ac7
commit 8111b8d9dc
3 changed files with 6 additions and 3 deletions

View file

@ -37,6 +37,7 @@ declare type SearchSuccess = {
type: ACTIONS.SEARCH_SUCCESS,
data: {
query: string,
from: number,
size: number,
uris: Array<string>,
},

View file

@ -5,7 +5,8 @@ import {
makeSelectSearchUris,
makeSelectQueryWithOptions,
selectSearchValue,
selectSearchOptions} from 'redux/selectors/search';
selectSearchOptions,
} from 'redux/selectors/search';
import handleFetchResponse from 'util/handle-fetch';
type Dispatch = (action: any) => any;
@ -93,6 +94,7 @@ export const doSearch = (rawQuery: string, searchOptions: SearchOptions) => (
type: ACTIONS.SEARCH_SUCCESS,
data: {
query: queryWithOptions,
from: from,
size: size,
uris,
},

View file

@ -27,11 +27,11 @@ export default handleActions(
searching: true,
}),
[ACTIONS.SEARCH_SUCCESS]: (state: SearchState, action: SearchSuccess): SearchState => {
const { query, uris, size } = action.data;
const { query, uris, from, size } = action.data;
const normalizedQuery = createNormalizedSearchKey(query);
let newUris = uris;
if (state.urisByQuery[normalizedQuery]) {
if (from !== 0 && state.urisByQuery[normalizedQuery]) {
newUris = Array.from(new Set(state.urisByQuery[normalizedQuery].concat(uris)));
}