lbry-desktop/ui/page/embedWrapper/index.js
infinite-persistence 201a826381
Simplify makeSelectIsUriResolving
- Memo not required. `resolvingUris` is very dynamic and is a short array anyways.
- Changeg from using `indexOf` to `includes`, which is more concise.
2021-11-16 14:32:58 +08:00

33 lines
1.2 KiB
JavaScript

import { connect } from 'react-redux';
import EmbedWrapperPage from './view';
import { makeSelectClaimForUri, selectIsUriResolving } from 'redux/selectors/claims';
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
import { doResolveUri } from 'redux/actions/claims';
import { buildURI } from 'util/lbryURI';
import { doPlayUri } from 'redux/actions/content';
import { makeSelectCostInfoForUri, doFetchCostInfoForUri, selectBlackListedOutpoints } from 'lbryinc';
const select = (state, props) => {
const { match } = props;
const { params } = match;
const { claimName, claimId } = params;
const uri = claimName ? buildURI({ claimName, claimId }) : '';
return {
uri,
claim: makeSelectClaimForUri(uri)(state),
costInfo: makeSelectCostInfoForUri(uri)(state),
streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
isResolvingUri: selectIsUriResolving(state, uri),
blackListedOutpoints: selectBlackListedOutpoints(state),
};
};
const perform = (dispatch) => {
return {
resolveUri: (uri) => dispatch(doResolveUri(uri)),
doPlayUri: (uri) => dispatch(doPlayUri(uri)),
doFetchCostInfoForUri: (uri) => dispatch(doFetchCostInfoForUri(uri)),
};
};
export default connect(select, perform)(EmbedWrapperPage);