add selector for claim supports
This commit is contained in:
parent
d6ca449bd9
commit
79e41150b9
1 changed files with 22 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { normalizeURI, buildURI, parseURI } from 'lbryURI';
|
import { normalizeURI, buildURI, parseURI } from 'lbryURI';
|
||||||
import { selectSearchUrisByQuery } from 'redux/selectors/search';
|
import { selectSearchUrisByQuery } from 'redux/selectors/search';
|
||||||
|
import { selectSupportsByOutpoint } from 'redux/selectors/wallet';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { isClaimNsfw, createNormalizedClaimSearchKey } from 'util/claim';
|
import { isClaimNsfw, createNormalizedClaimSearchKey } from 'util/claim';
|
||||||
import { getSearchQueryString } from 'util/query-params';
|
import { getSearchQueryString } from 'util/query-params';
|
||||||
|
@ -531,3 +532,24 @@ export const makeSelectShortUrlForUri = (uri: string) =>
|
||||||
makeSelectClaimForUri(uri),
|
makeSelectClaimForUri(uri),
|
||||||
claim => claim && claim.short_url
|
claim => claim && claim.short_url
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const makeSelectSupportsForUri = (uri: string) =>
|
||||||
|
createSelector(
|
||||||
|
selectSupportsByOutpoint,
|
||||||
|
makeSelectClaimForUri(uri),
|
||||||
|
(byOutpoint, claim: ?StreamClaim) => {
|
||||||
|
if (!claim || !claim.is_mine) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { claim_id: claimId } = claim;
|
||||||
|
let total = parseFloat("0.0");
|
||||||
|
|
||||||
|
Object.values(byOutpoint).forEach(support => {
|
||||||
|
const { claim_id, amount } = support
|
||||||
|
total = (claim_id === claimId && amount) ? total + parseFloat(amount) : total;
|
||||||
|
});
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in a new issue