implement append for multi claim_search calls

This commit is contained in:
Akinwale Ariwodola 2019-07-16 10:15:51 +01:00
parent dddb10687c
commit b2044499c5
2 changed files with 18 additions and 8 deletions

13
dist/bundle.es.js vendored
View file

@ -3652,14 +3652,19 @@ reducers[CLAIM_SEARCH_BY_TAGS_STARTED] = (state, action) => {
reducers[CLAIM_SEARCH_BY_TAGS_COMPLETED] = (state, action) => {
const fetchingClaimSearchByTags = Object.assign({}, state.fetchingClaimSearchByTags);
const claimSearchUrisByTags = Object.assign({}, state.claimSearchUrisByTags);
const { tags, uris } = action.data;
const { append, tags, uris } = action.data;
// TODO: append?
claimSearchUrisByTags[tags] = uris;
let newClaimSearchUrisByTags = [];
if (action.data.append) {
// todo: check for duplicate uris when concatenating?
newClaimSearchUrisByTags = claimSearchUrisByTags.concat(uris);
} else {
newClaimSearchUrisByTags = uris;
}
fetchingClaimSearchByTags[tags] = false; // or delete the key instead?
return Object.assign({}, state, {
claimSearchUrisByTags,
claimSearchUrisByTags: newClaimSearchUrisByTags,
fetchingClaimSearchByTags
});
};

View file

@ -327,14 +327,19 @@ reducers[ACTIONS.CLAIM_SEARCH_BY_TAGS_STARTED] = (state: State, action: any): St
reducers[ACTIONS.CLAIM_SEARCH_BY_TAGS_COMPLETED] = (state: State, action: any): State => {
const fetchingClaimSearchByTags = Object.assign({}, state.fetchingClaimSearchByTags);
const claimSearchUrisByTags = Object.assign({}, state.claimSearchUrisByTags);
const { tags, uris } = action.data;
const { append, tags, uris } = action.data;
// TODO: append?
claimSearchUrisByTags[tags] = uris;
let newClaimSearchUrisByTags = [];
if (action.data.append) {
// todo: check for duplicate uris when concatenating?
newClaimSearchUrisByTags = claimSearchUrisByTags.concat(uris);
} else {
newClaimSearchUrisByTags = uris;
}
fetchingClaimSearchByTags[tags] = false; // or delete the key instead?
return Object.assign({}, state, {
claimSearchUrisByTags,
claimSearchUrisByTags: newClaimSearchUrisByTags,
fetchingClaimSearchByTags,
});
};