support claim search async dispatch

This commit is contained in:
zeppi 2021-04-22 22:31:08 -04:00
parent 4e37ab6580
commit c2e03fa71d
2 changed files with 48 additions and 38 deletions

78
dist/bundle.es.js vendored
View file

@ -4018,44 +4018,52 @@ function doClaimSearch(options = {
page: 1 page: 1
}) { }) {
const query = createNormalizedClaimSearchKey(options); const query = createNormalizedClaimSearchKey(options);
return dispatch => { return (() => {
dispatch({ var _ref2 = _asyncToGenerator$1(function* (dispatch) {
type: CLAIM_SEARCH_STARTED, dispatch({
data: { query: query } type: CLAIM_SEARCH_STARTED,
data: { query: query }
});
const success = function (data) {
const resolveInfo = {};
const urls = [];
data.items.forEach(function (stream) {
resolveInfo[stream.canonical_url] = { stream };
urls.push(stream.canonical_url);
});
dispatch({
type: CLAIM_SEARCH_COMPLETED,
data: {
query,
resolveInfo,
urls,
append: options.page && options.page !== 1,
pageSize: options.page_size
}
});
return true;
};
const failure = function (err) {
dispatch({
type: CLAIM_SEARCH_FAILED,
data: { query },
error: err
});
return false;
};
return yield lbryProxy.claim_search(_extends$5({}, options, {
include_purchase_receipt: true
})).then(success, failure);
}); });
const success = data => { return function (_x2) {
const resolveInfo = {}; return _ref2.apply(this, arguments);
const urls = [];
data.items.forEach(stream => {
resolveInfo[stream.canonical_url] = { stream };
urls.push(stream.canonical_url);
});
dispatch({
type: CLAIM_SEARCH_COMPLETED,
data: {
query,
resolveInfo,
urls,
append: options.page && options.page !== 1,
pageSize: options.page_size
}
});
}; };
})();
const failure = err => {
dispatch({
type: CLAIM_SEARCH_FAILED,
data: { query },
error: err
});
};
lbryProxy.claim_search(_extends$5({}, options, {
include_purchase_receipt: true
})).then(success, failure);
};
} }
function doRepost(options) { function doRepost(options) {

View file

@ -65,7 +65,7 @@ export function doResolveUris(
} = {}; } = {};
return Lbry.resolve({ urls: urisToResolve, ...options }).then( return Lbry.resolve({ urls: urisToResolve, ...options }).then(
async (result: ResolveResponse) => { async(result: ResolveResponse) => {
let repostedResults = {}; let repostedResults = {};
const repostsToResolve = []; const repostsToResolve = [];
const fallbackResolveInfo = { const fallbackResolveInfo = {
@ -594,7 +594,7 @@ export function doClaimSearch(
} }
) { ) {
const query = createNormalizedClaimSearchKey(options); const query = createNormalizedClaimSearchKey(options);
return (dispatch: Dispatch) => { return async(dispatch: Dispatch) => {
dispatch({ dispatch({
type: ACTIONS.CLAIM_SEARCH_STARTED, type: ACTIONS.CLAIM_SEARCH_STARTED,
data: { query: query }, data: { query: query },
@ -618,6 +618,7 @@ export function doClaimSearch(
pageSize: options.page_size, pageSize: options.page_size,
}, },
}); });
return true;
}; };
const failure = err => { const failure = err => {
@ -626,9 +627,10 @@ export function doClaimSearch(
data: { query }, data: { query },
error: err, error: err,
}); });
return false;
}; };
Lbry.claim_search({ return await Lbry.claim_search({
...options, ...options,
include_purchase_receipt: true, include_purchase_receipt: true,
}).then(success, failure); }).then(success, failure);