Make search page updates more efficient with batch actions
This commit is contained in:
parent
193738083f
commit
8f786baacd
1 changed files with 7 additions and 2 deletions
|
@ -4,6 +4,7 @@ import lighthouse from "lighthouse";
|
|||
import { doResolveUri } from "actions/content";
|
||||
import { doNavigate, doHistoryPush } from "actions/app";
|
||||
import { selectCurrentPage } from "selectors/app";
|
||||
import batchActions from "util/batchActions";
|
||||
|
||||
export function doSearch(query) {
|
||||
return function(dispatch, getState) {
|
||||
|
@ -25,22 +26,26 @@ export function doSearch(query) {
|
|||
dispatch(doNavigate("search", { query: query }));
|
||||
} else {
|
||||
lighthouse.search(query).then(results => {
|
||||
const actions = [];
|
||||
|
||||
results.forEach(result => {
|
||||
const uri = lbryuri.build({
|
||||
channelName: result.channel_name,
|
||||
contentName: result.name,
|
||||
claimId: result.channel_id || result.claim_id,
|
||||
});
|
||||
dispatch(doResolveUri(uri));
|
||||
actions.push(doResolveUri(uri));
|
||||
});
|
||||
|
||||
dispatch({
|
||||
actions.push({
|
||||
type: types.SEARCH_COMPLETED,
|
||||
data: {
|
||||
query,
|
||||
results,
|
||||
},
|
||||
});
|
||||
|
||||
dispatch(batchActions(...actions));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue